/* SlipVerify dashboard — clean, spacious, one primary action per screen. Light and dark. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #1c2230;
  --muted: #667085;
  --brand: #e2557a;
  --brand-ink: #ffffff;
  --brand-soft: #fde8ee;
  --ok: #128a5a;
  --ok-soft: #e3f6ee;
  --warn: #b26a00;
  --warn-soft: #fff4dc;
  --bad: #c8333f;
  --bad-soft: #fde7e8;
  --dup: #6e4bd8;
  --dup-soft: #efeafd;
  --mis: #c4581c;
  --mis-soft: #fdeede;
  --info: #2563c9;
  --info-soft: #e7effc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #171b23;
    --surface-2: #1e2430;
    --border: #2a3140;
    --text: #e8ebf1;
    --muted: #98a1b3;
    --brand: #f0729a;
    --brand-ink: #1a0d12;
    --brand-soft: #3a1f29;
    --ok: #4cc98f;
    --ok-soft: #133226;
    --warn: #f0b44c;
    --warn-soft: #3a2d12;
    --bad: #f07a83;
    --bad-soft: #3a1a1e;
    --dup: #a993f5;
    --dup-soft: #2a2245;
    --mis: #f39a5c;
    --mis-soft: #3a2615;
    --info: #7fa8f0;
    --info-soft: #1a2a45;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans Thai", "IBM Plex Sans Thai", "Leelawadee UI", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a {
  color: inherit;
}

h1 {
  font-size: 1.55rem;
  line-height: 1.25;
  margin: 0.15rem 0 0.25rem;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.05rem;
  margin: 0;
}

code,
.mono {
  font-family: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.88em;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.85rem;
}

.break {
  word-break: break-all;
}

.nowrap {
  white-space: nowrap;
}

/* Top bar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 800;
  font-size: 0.95rem;
}

.brand-mark.lg {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  font-size: 1.35rem;
}

.nav {
  display: flex;
  gap: 0.15rem;
  overflow-x: auto;
  flex: 1;
  scrollbar-width: none;
}

.nav a {
  padding: 0.4rem 0.75rem;
  border-radius: 9px;
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
}

.nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav a.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.logout {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Layout */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

.container.narrow {
  max-width: 440px;
  padding-top: 8vh;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-head p {
  margin: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.1rem;
}

.card-title {
  margin-bottom: 0.9rem;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.1rem;
}

.grid-2 > .card {
  margin-bottom: 0;
}

.grid-2 + .card,
.grid-2 {
  margin-bottom: 1.1rem;
}

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.8rem;
}

.stat {
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border: 1px solid transparent;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0.15rem;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.stat-ok .stat-value {
  color: var(--ok);
}

.stat-warn .stat-value {
  color: var(--warn);
}

.stat-dup .stat-value {
  color: var(--dup);
}

.stat-bad .stat-value {
  color: var(--bad);
}

.stat-mis .stat-value {
  color: var(--mis);
}

/* Chart */
.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-axis {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-label {
  fill: var(--muted);
  font-size: 11px;
}

.seg-ok {
  fill: var(--ok);
  background: var(--ok);
}

.seg-warn {
  fill: var(--warn);
  background: var(--warn);
}

.seg-dup {
  fill: var(--dup);
  background: var(--dup);
}

.seg-bad {
  fill: var(--bad);
  background: var(--bad);
}

.legend {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 0.35rem;
}

/* Callouts and flash */
.callout,
.flash {
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.1rem;
  border: 1px solid transparent;
}

.callout-warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
}

.callout-ok,
.flash-ok {
  background: var(--ok-soft);
  border-color: color-mix(in srgb, var(--ok) 25%, transparent);
}

.callout-info,
.flash-info {
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 25%, transparent);
}

.flash-error {
  background: var(--bad-soft);
  border-color: color-mix(in srgb, var(--bad) 25%, transparent);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 0 -0.35rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: none;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.7rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--surface-2);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row-muted td {
  opacity: 0.6;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 2rem 0;
  margin: 0;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}

.badge-verified {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-unverified {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge-duplicate {
  background: var(--dup-soft);
  color: var(--dup);
}

.badge-invalid-qr,
.badge-invalid-image,
.badge-error {
  background: var(--bad-soft);
  color: var(--bad);
}

.badge-amount-mismatch,
.badge-receiver-mismatch {
  background: var(--mis-soft);
  color: var(--mis);
}

.badge-decoded {
  background: var(--info-soft);
  color: var(--info);
}

.tag {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 0.35rem;
}

/* Forms */
label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.88rem;
  font-weight: 500;
}

input,
select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  min-height: 40px;
  width: 100%;
}

input:focus,
select:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--brand);
}

.hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.8rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-row label {
  min-width: 120px;
}

.form-row .grow {
  flex: 1;
  min-width: 180px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
}

.form-actions {
  grid-column: 1 / -1;
}

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 0.7rem;
  align-items: center;
}

.search {
  display: flex;
  gap: 0.5rem;
  min-width: min(440px, 100%);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 600;
  border-radius: 10px;
  padding: 0.55rem 1rem;
  min-height: 40px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm {
  min-height: 32px;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--brand);
  color: var(--brand-ink);
}

.btn-primary:hover {
  filter: brightness(0.95);
}

.btn-secondary {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover,
.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-danger {
  background: var(--bad-soft);
  color: var(--bad);
}

.link {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
}

.link:hover {
  text-decoration: underline;
}

/* "More" menu */
details.menu {
  position: relative;
}

details.menu > summary {
  list-style: none;
}

details.menu > summary::-webkit-details-marker {
  display: none;
}

.menu-body {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  width: 250px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.disclosure summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 600;
  margin: 0.8rem 0;
}

/* Key/value lists */
.kvs {
  margin: 0;
}

.kv {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--border);
}

.kv:last-child {
  border-bottom: none;
}

.kv dt {
  color: var(--muted);
  font-size: 0.88rem;
}

.kv dd {
  margin: 0;
  min-width: 0;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border);
}

pre.code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0 0 1rem;
}

.copy-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.key-value {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  word-break: break-all;
  font-size: 0.95rem;
}

.pager {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* Sign-in card */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
}

.auth-head {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-head h1 {
  margin-top: 0.75rem;
}

.auth-head p {
  margin: 0;
}

/* Responsive */
@media (max-width: 960px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-2,
  .grid-form {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .filters input[type="search"] {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
  }

  .hide-sm {
    display: none;
  }

  .container {
    padding: 1.1rem 0.9rem 3rem;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }

  .search {
    min-width: 100%;
  }
}
