:root {
  color-scheme: light;
  font-family: "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  background: #f4f6f8;
  color: #1d2430;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

body { margin: 0; background: #f8f9fa; }

body.guest {
  background: #f2f2f2;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  font-family: Arial, sans-serif;
}

body.guest .topbar,
body.guest main { display: none; }

.login-container {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  margin: 16px;
  text-align: center;
}

.login-container h1 { font-size: 24px; margin-bottom: 10px; }

.brand { color: #ffb500; }

.login-lead { color: #777; margin-bottom: 20px; }

.input-group { margin-bottom: 20px; text-align: left; }

.login-container label { font-size: 16px; font-weight: 400; color: #333; }

.login-container input[type="text"],
.login-container input[type="password"] {
  margin-top: 5px;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 10px;
}

.login-container button[type="submit"] {
  width: 100%;
  margin-top: 10px;
  background: #ffb500;
  border-radius: 5px;
  box-shadow: 0 4px 8px -4px rgba(0, 0, 0, 0.3);
}

.login-container button[type="submit"]:hover { background: #e6951b; }

.create-account { margin-top: 20px; }

.create-account a { color: #ffb500; font-weight: 700; text-decoration: none; }

.login-container .banner { text-align: left; margin-bottom: 16px; }

h1, h2, p { margin: 0; }

h1 { font-size: 28px; }

h2 { font-size: 20px; margin-bottom: 12px; }

button, input, select {
  font: inherit;
  font-size: 16px;
}

button {
  border: 0;
  border-radius: 8px;
  background: #1463d8;
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
}

button.ghost, button.small {
  background: #e8edf5;
  color: #1d2430;
}

button.danger { background: #c62828; }

button:disabled,
button.danger:disabled {
  background: #c5d0de;
  color: #fff;
  cursor: not-allowed;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.card-head h2 { margin: 0; }

.topbar, main {
  width: 100%;
  margin: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 24px 0 8px;
}

.topbar p { color: #526074; margin-top: 4px; }

.guide-pre {
  background: #0f172a;
  color: #f1f5f9;
  padding: 12px;
  border-radius: 8px;
  overflow: auto;
  font-size: 14px;
  white-space: pre-wrap;
  margin: 8px 0 16px;
}

.card {
  width: 100%;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin-top: 10px;
}

label, legend { display: block; font-weight: 600; margin-bottom: 6px; }

input, select {
  width: 100%;
  border: 1px solid #c5d0de;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.inline-form, .stack-form { display: flex; gap: 12px; align-items: end; margin-bottom: 16px; }

.stack-form { flex-direction: column; align-items: stretch; }

.inline-form input, .inline-form select { min-width: 220px; }

/* Ô nhập đi theo nội dung của nó, không theo bề ngang màn hình. */
.inline-form:not(.connect-form) input,
.inline-form:not(.connect-form) select { max-width: 360px; }

/* Nút không bị flex bóp xuống hai dòng. */
.inline-form button { flex: 0 0 auto; white-space: nowrap; }

/* Nhãn + ô nhập là một cụm co giãn, nút đứng cùng hàng ở cuối. */
.inline-form { flex-wrap: wrap; }

.inline-form > label {
  flex: 1 1 240px;
  max-width: 360px;
  margin-bottom: 0;
}

.inline-form.connect-form {
  align-items: center;
  flex-wrap: wrap;
}

.inline-form.connect-form input {
  flex: 1 1 auto;
  width: auto;
  min-width: 180px;
  height: 40px;
}

.inline-form.connect-form select {
  flex: 0 0 72px;
  width: 72px;
  min-width: 72px;
  height: 40px;
  padding: 0 8px;
}

.inline-form.connect-form select.partner-select {
  flex: 0 1 180px;
  width: 180px;
  min-width: 140px;
}

.inline-form.connect-form button {
  flex: 0 0 auto;
  height: 40px;
  padding: 0 14px;
  white-space: nowrap;
}

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }

.tab { background: #e8edf5; color: #1d2430; }

.tab.active { background: #1463d8; color: #fff; }

.table-wrap {
  display: block;
  width: 100%;
  overflow-x: auto;
}

.card table,
.table-wrap table {
  width: 100%;
  min-width: 640px;
  max-width: 100%;
  margin-bottom: 0;
  color: #212529;
  background: #fff;
  border-collapse: collapse;
  border: 1px solid #dee2e6;
  font-size: 16px;
}

.card th,
.card td,
.table-wrap th,
.table-wrap td {
  padding: 10px 14px;
  border-top: 1px solid #dee2e6;
  border-bottom: 0;
  vertical-align: middle;
  text-align: left;
  white-space: nowrap;
}

.card thead th,
.table-wrap thead th {
  border-bottom: 2px solid #dee2e6;
  background: #f8f9fa;
  border-right: 1px solid #dee2e6;
  text-align: left;
  color: #212529;
  font-size: 16px;
  font-weight: 700;
}

.card thead th:last-child,
.table-wrap thead th:last-child {
  border-right: none;
}

.card tbody tr:hover,
.table-wrap tbody tr:hover {
  background: #f5f5f5;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 700;
  background: #eceff3;
}

.badge.ok { background: #e5f6ea; color: #146c2e; }

.badge.warn { background: #fff3e0; color: #b26a00; }

.badge.bad { background: #fdecea; color: #b42318; }

.banner, .secret {
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  word-break: break-all;
}

.banner { background: #fff3e0; }

.secret { background: #e8f5e9; }

.checks { display: flex; flex-wrap: wrap; gap: 10px 16px; }

.checks label { font-weight: 500; display: flex; gap: 8px; align-items: center; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.status-live { color: #146c2e; font-weight: 700; }
.status-wait { color: #b26a00; font-weight: 700; }
.status-bad { color: #b42318; font-weight: 700; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
}

.modal[hidden] { display: none; }

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-head h2 { margin: 0; }

.modal-note { color: #526074; margin-bottom: 12px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: #fff;
  border: 1px solid #d9e0ea;
  border-radius: 12px;
  padding: 20px;
}

.stat-card .label { font-size: 15px; color: #526074; }

.stat-card .value { font-size: 32px; font-weight: 700; margin-top: 8px; }

.stat-card.ok .value { color: #146c2e; }

.stat-card.warn .value { color: #b26a00; }

thead th input:not([type="checkbox"]),
thead th select,
td select.partner-edit {
  min-width: 140px;
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 32px 0 10px;
  line-height: normal;
  font-size: 16px;
  color: #1d2430;
  background-color: #fff;
}

#shopTable,
#logTable {
  width: 100%;
  min-width: 100%;
}

#logTable .col-stt { width: 64px; text-align: center; }

#logTable thead th input.log-search { padding-right: 10px; min-width: 180px; }

#logTable tbody tr[data-log-key] { cursor: pointer; }

#logTable td.log-summary { min-width: 280px; }

#logTable tr.log-detail td {
  white-space: normal;
  background: #f8f9fa;
  cursor: default;
}

#logTable .log-meta {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 6px 12px;
  font-size: 14px;
}

#logTable td.empty { color: #526074; text-align: center; }

#shopTable .col-stt { width: 64px; text-align: center; }

#shopTable thead select { max-width: 250px; }
#shopTable td.empty, #usersTable td.empty { color: #526074; text-align: center; }
#usersTable .muted { color: #526074; font-size: 13px; }
#usersTable .user-shops { min-width: 170px; max-width: 260px; white-space: normal; }
#usersTable .user-webhooks { min-width: 220px; max-width: 320px; white-space: normal; overflow-wrap: anywhere; }
#usersTable .user-detail + .user-detail { margin-top: 8px; }

.webhook-secret-control { min-width: 180px; white-space: normal; }
.webhook-secret-control [data-secret-panel] { margin-top: 8px; }
.webhook-secret-control label { display: block; font-size: 12px; overflow-wrap: anywhere; }
.webhook-secret-control input { width: 100%; min-width: 180px; max-width: 420px; font-family: monospace; }
.webhook-secret-control [data-secret-panel][hidden] { display: none; }
.webhook-secret-message { display: block; color: #526074; font-size: 13px; overflow-wrap: anywhere; }

.shop-add-row td { white-space: normal; }

.shop-add-row input,
.shop-add-row select,
td select.partner-edit {
  min-width: 120px;
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 28px 0 10px;
  line-height: normal;
  font-size: 16px;
}

.shop-add-row input { padding-right: 10px; }

td.actions { white-space: nowrap; }

button.small.danger {
  background: #c62828;
  color: #fff;
}

.stt-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

thead th.col-stt input,
.stt-cell input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
}

.scope-chip {
  display: inline-block;
  margin: 4px 8px 4px 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e5f6ea;
  color: #146c2e;
  font-size: 14px;
  font-weight: 700;
}

/* Guide công khai: không có sidebar nên bỏ phần chừa chỗ cho nó. */
.main-content.no-sidebar {
  margin-left: 0;
  padding: 20px;
}
