:root,
[data-theme="chimney"] {
  --bg: #252e52;
  --wash: #2f3a66;
  --card: #3a4575;
  --ink: #ffffff;
  --muted: #c5cbe0;
  --line: rgba(230, 214, 84, 0.22);
  --gold: #e6d654;
  --gold-soft: rgba(230, 214, 84, 0.22);
  --navy-ink: #252e52;
  --danger: #ff8a7a;
  --ok: #9ed39a;
  --glow: #3a4678;
  --drop: rgba(230, 214, 84, 0.55);
  --shadow: 0 12px 32px rgba(15, 18, 36, 0.28);
  --radius: 18px;
  --pad: 22px;
  --touch: 52px;
  --mark-disc: #2f3a66;
  --mark-fill: #e6d654;
  --mark-stroke: #ffffff;
  color-scheme: dark;
}
[data-theme="tokyo-night"] {
  --bg: #1a1b26;
  --wash: #16161e;
  --card: #24283b;
  --ink: #c0caf5;
  --muted: #a9b1d6;
  --line: rgba(122, 162, 247, 0.32);
  --gold: #7aa2f7;
  --gold-soft: rgba(122, 162, 247, 0.2);
  --navy-ink: #1a1b26;
  --danger: #f7768e;
  --ok: #9ece6a;
  --glow: #414868;
  --drop: rgba(122, 162, 247, 0.55);
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  --mark-disc: #16161e;
  --mark-fill: #7aa2f7;
  --mark-stroke: #c0caf5;
  color-scheme: dark;
}
[data-theme="momentum"] {
  --bg: #0b1220;
  --wash: #121c2e;
  --card: #1a2740;
  --ink: #eaf2f7;
  --muted: #8fa3b8;
  --line: rgba(46, 230, 166, 0.28);
  --gold: #2ee6a6;
  --gold-soft: rgba(46, 230, 166, 0.18);
  --navy-ink: #071018;
  --danger: #ff6b7a;
  --ok: #2ee6a6;
  --glow: #16324a;
  --drop: rgba(46, 230, 166, 0.5);
  --shadow: 0 14px 36px rgba(4, 10, 18, 0.45);
  --radius: 14px;
  --mark-disc: #121c2e;
  --mark-fill: #2ee6a6;
  --mark-stroke: #eaf2f7;
  color-scheme: dark;
}
[data-theme="paper"] {
  --bg: #efe8d8;
  --wash: #fffaf0;
  --card: #ffffff;
  --ink: #2a2620;
  --muted: #6b6560;
  --line: rgba(42, 38, 32, 0.14);
  --gold: #c4a035;
  --gold-soft: rgba(196, 160, 53, 0.2);
  --navy-ink: #2a2620;
  --danger: #c23b2e;
  --ok: #3d7a3d;
  --glow: #e4d8bc;
  --drop: rgba(196, 160, 53, 0.55);
  --shadow: 0 10px 24px rgba(80, 60, 20, 0.08);
  --radius: 16px;
  --mark-disc: #fffaf0;
  --mark-fill: #c4a035;
  --mark-stroke: #2a2620;
  color-scheme: light;
}
[data-theme="matcha"] {
  --bg: #1c2418;
  --wash: #2a3324;
  --card: #3a4532;
  --ink: #f3f0e4;
  --muted: #c5cbb0;
  --line: rgba(212, 192, 90, 0.28);
  --gold: #d4c05a;
  --gold-soft: rgba(212, 192, 90, 0.22);
  --navy-ink: #1c2418;
  --danger: #e07a6a;
  --ok: #8fbf7a;
  --glow: #3a4532;
  --drop: rgba(212, 192, 90, 0.5);
  --shadow: 0 12px 28px rgba(10, 14, 8, 0.3);
  --radius: 16px;
  --mark-disc: #2a3324;
  --mark-fill: #d4c05a;
  --mark-stroke: #f3f0e4;
  color-scheme: dark;
}
[data-theme="catppuccin-mocha"] {
  --bg: #1e1e2e;
  --wash: #181825;
  --card: #313244;
  --ink: #cdd6f4;
  --muted: #a6adc8;
  --line: rgba(249, 226, 175, 0.28);
  --gold: #f9e2af;
  --gold-soft: rgba(249, 226, 175, 0.2);
  --navy-ink: #1e1e2e;
  --danger: #f38ba8;
  --ok: #a6e3a1;
  --glow: #45475a;
  --drop: rgba(249, 226, 175, 0.5);
  --shadow: 0 12px 28px rgba(8, 8, 16, 0.4);
  --radius: 14px;
  --mark-disc: #181825;
  --mark-fill: #f9e2af;
  --mark-stroke: #cdd6f4;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "IBM Plex Sans Thai", "Noto Sans Thai", "Sarabun", "IBM Plex Sans", system-ui, sans-serif;
  min-height: 100dvh;
  line-height: 1.45;
}
a { color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
button, .drop, summary, label.file-btn {
  min-height: var(--touch);
  touch-action: manipulation;
}
button {
  border: 1px solid var(--line);
  background: var(--wash);
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
}
.primary {
  background: var(--gold);
  color: var(--navy-ink);
  border-color: var(--gold);
  font-weight: 600;
}
.danger {
  border-color: var(--danger);
  color: var(--danger);
  background: transparent;
}
.ghost { background: transparent; }

.top {
  position: sticky;
  top: 0;
  z-index: 8;
  background: var(--wash);
  padding: 6px 10px 2px;
  padding-top: calc(6px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.chimney-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--mark-disc, var(--wash));
  border: 1px solid var(--line);
  display: inline-grid;
  place-items: center;
  overflow: hidden;
}
.chimney-mark img.mark-img {
  width: 78%;
  height: 78%;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  background: transparent;
  display: block;
}
[data-theme="chimney"] .chimney-mark img.mark-img {
  filter: none;
}
[data-theme="tokyo-night"] .chimney-mark img.mark-img,
[data-theme="momentum"] .chimney-mark img.mark-img,
[data-theme="paper"] .chimney-mark img.mark-img,
[data-theme="matcha"] .chimney-mark img.mark-img,
[data-theme="catppuccin-mocha"] .chimney-mark img.mark-img {
  filter: grayscale(0.15) saturate(1.15);
}
.digitize-sheet .chimney-mark {
  width: 56px;
  height: 56px;
  margin: 0 0 8px;
  display: block;
}
.theme-swatch .chimney-mark {
  width: 48px;
  height: 48px;
}
.brand span { min-width: 0; }
.brand small, .hello p {
  display: block;
  color: var(--muted);
  font-size: 13px;
}
.brand strong, .brand > span {
  letter-spacing: 0.06em;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
}
.hello { margin: 4px 0 0; }
.hello h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.hello p { display: none; }
.top-chrome {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
}
.brand.mobile-only {
  flex: 1 1 auto;
  min-width: 0;
  gap: 6px;
}
.brand.mobile-only .chimney-mark {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}
.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  letter-spacing: 0;
  font-size: inherit;
  font-weight: inherit;
}
.brand-lock {
  display: block;
  letter-spacing: 0.01em;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--gold);
  font-family: "IBM Plex Sans", "IBM Plex Sans Thai", sans-serif;
}
.brand.mobile-only small {
  font-size: 10px;
  line-height: 1.15;
  margin-top: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chrome-tools {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: auto;
  flex-shrink: 0;
}
button.chrome-chip {
  min-height: 24px;
  height: 24px;
  padding: 0 6px;
  font-size: 10px;
  border-radius: 999px;
  line-height: 1;
}
button.chrome-chip.theme-cycle {
  width: 24px;
  padding: 0;
  justify-content: center;
}
#logout {
  white-space: nowrap;
}
button.chrome-chip.theme-cycle .theme-dot {
  width: 10px;
  height: 10px;
  margin: 0;
}
.session-chip {
  min-width: 0;
  flex: 0 1 auto;
  max-width: 38%;
}
.session-chip b {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-actions { display: none; }
.user-mail { display: none; color: var(--muted); font-size: 12px; }

.shell { min-height: 100dvh; }
.rail { display: none; }
.rail-tag {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 12px;
}
.rail-nav { display: grid; gap: 6px; }
.rail-nav.nav {
  display: grid;
  overflow: visible;
  padding: 0;
  flex-wrap: nowrap;
}
.rail-nav button { width: 100%; text-align: left; }
.rail-foot { margin-top: auto; padding-top: 18px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 4px;
}
.user-chip .avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--navy-ink);
  display: grid;
  place-items: center;
  font-weight: 600;
  flex-shrink: 0;
  overflow: hidden;
}
.user-chip img { width: 36px; height: 36px; object-fit: cover; }
.user-chip small { display: block; color: var(--muted); font-size: 12px; word-break: break-all; }
.mobile-only { display: flex; }

.nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 0;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav button {
  flex: 0 0 auto;
  min-width: auto;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 13px;
  white-space: nowrap;
  scroll-snap-align: start;
}
.tab-strip.nav { padding: 2px 0 0; gap: 4px; }
.tab-strip button,
.tab-strip .nav-more summary {
  min-height: 32px;
  padding: 4px 8px;
  font-size: 12px;
}
.nav button.active {
  background: var(--gold);
  color: var(--navy-ink);
  border-color: var(--gold);
  font-weight: 600;
}
.nav button small, .rail-nav button small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  opacity: 0.78;
  margin-top: 2px;
}
.locale-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--gold);
  border-color: transparent;
}
.locale-toggle .on { font-weight: 700; }
.locale-toggle .off { opacity: 0.45; color: var(--ink); }

.wrap {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 24px 20px 110px;
  padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 22px;
}

.panel, .stat, .invoice-card, .confirm-card, .draft-card, .receipt-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--pad);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.panel h2, .section-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 600;
}
.hint, .muted { color: var(--muted); }
.hint { margin: 0 0 14px; font-size: 14px; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.top .nav button small { display: none; }
.nav-more {
  flex: 0 0 auto;
  scroll-snap-align: start;
  position: relative;
}
.nav-more summary {
  min-height: 40px;
  list-style: none;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
}
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more.on summary,
.nav-more[open] summary {
  background: var(--gold-soft);
  border-color: var(--gold);
}
.nav-more-list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 9;
  display: grid;
  gap: 4px;
  min-width: 148px;
  padding: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.nav-more-list button { width: 100%; min-width: 0; }
.stat b { display: block; font-size: 1.35rem; margin-top: 4px; color: var(--gold); }

.drop {
  border: 2px dashed var(--drop);
  border-radius: var(--radius);
  padding: 22px 14px;
  text-align: center;
  background: var(--wash);
}
.drop input { width: 100%; margin-top: 10px; }
.form-grid { display: grid; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: var(--touch);
  width: 100%;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-height: 22px;
  accent-color: var(--gold);
}
input[type="file"] { padding: 10px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.file-picks { display: grid; gap: 10px; }
.file-btn {
  display: grid;
  place-items: center;
  min-height: var(--touch);
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--gold);
  background: var(--gold);
  color: var(--navy-ink);
  font-weight: 600;
  cursor: pointer;
}
.file-picks .file-btn + .file-btn {
  background: var(--wash);
  color: var(--ink);
  border-color: var(--line);
}
.check-row {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  min-height: var(--touch);
  color: var(--muted);
}
.paid-bar {
  position: sticky;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 8;
}
.paid-bar .primary {
  width: 100%;
  min-height: 52px;
}
.confirm-actions .primary, .draft-actions .primary {
  min-height: 52px;
}
.desktop-only { display: none; }

.confirm-stack, .invoice-list, .draft-list, .receipt-list { display: grid; gap: 18px; }
.fold, .more-fold {
  border-radius: var(--radius);
}
.fold > summary, .more-fold > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 0;
  font-weight: 600;
  min-height: var(--touch);
}
.fold > summary::-webkit-details-marker,
.more-fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after, .more-fold > summary::after {
  content: " +";
  color: var(--gold);
}
.fold[open] > summary::after, .more-fold[open] > summary::after { content: " –"; }
.more-fold { margin-top: 4px; }
.more-fold > summary { color: var(--muted); font-weight: 500; font-size: 14px; padding: 10px 0; }
.more-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}
.more-actions a, .more-actions button {
  min-height: 44px;
}
.confirm-kicker, .draft-kicker, .state-chip {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}
.state-chip {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
}
.state-chip.unmatched { background: rgba(255, 255, 255, 0.1); color: var(--muted); }
.state-chip.confirm, .state-chip.suggest { background: var(--gold-soft); color: var(--gold); }
.state-chip.paid { background: rgba(158, 211, 154, 0.18); color: var(--ok); }

.confirm-vendor, .draft-title, .invoice-desc {
  margin: 0 0 8px;
  font-size: 1.1rem;
  word-break: break-word;
}
.confirm-amount, .draft-amount, .invoice-amt {
  margin: 0 0 10px;
  font-size: 1.85rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.confirm-actions, .draft-actions, .row-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.draft-meta, .invoice-meta { color: var(--muted); font-size: 14px; margin: 0 0 8px; }
.draft-edit, .invoice-attach { display: none; grid-gap: 10px; margin-top: 10px; }
.draft-card.editing .draft-edit,
.invoice-card.attaching .invoice-attach { display: grid; }

.invoice-card { display: grid; gap: 10px; }
details.item-fold.invoice-card,
details.item-fold.receipt-card,
details.item-fold.draft-card {
  display: block;
  padding: 0;
  overflow: hidden;
}
.item-fold-sum {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
  min-height: 48px;
}
.item-fold-sum::-webkit-details-marker { display: none; }
.item-fold-id {
  min-width: 0;
  font-family: ui-monospace, monospace;
  font-weight: 600;
  color: var(--gold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.item-fold-amt {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
}
.item-fold-sum .state-chip {
  margin: 0;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-fold[open] > .item-fold-sum { border-bottom: 1px solid var(--line); }
.item-fold-body { padding: 10px 12px 12px; display: grid; gap: 8px; }
.invoice-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.invoice-id { font-family: ui-monospace, monospace; color: var(--gold); font-weight: 600; }
.row-actions { grid-template-columns: 1fr; }
.row-actions .wide, button.wide {
  width: 100%;
  min-height: 52px;
}
.row-actions a {
  text-align: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-decoration: none;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--wash);
}
.badge.pending, .badge.transfer_pending { color: var(--gold); background: var(--gold-soft); border-color: transparent; }
.badge.paid { color: var(--ok); background: rgba(158, 211, 154, 0.18); border-color: transparent; }
.badge.rejected, .badge.questions { color: var(--danger); background: rgba(255, 138, 122, 0.16); border-color: transparent; }

.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.loading-copy {
  min-height: 44px;
  margin: 8px 0 0;
}
.user-list { display: grid; gap: 10px; margin-top: 12px; }
.users-admin-panel .invite-form {
  display: grid;
  gap: 12px;
  margin: 0 0 16px;
}
.users-admin-panel .invite-form .primary {
  min-height: 48px;
  width: 100%;
}
.users-count { margin: 0 0 8px; }
.users-status { margin: 12px 0 0; }
.users-status .ghost { min-height: 44px; }
.user-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.user-row-main { flex: 1 1 12rem; min-width: 0; }
.user-row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.user-row-title strong { overflow-wrap: anywhere; }
.user-email {
  margin: 4px 0 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.user-meta {
  margin: 6px 0 0;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.user-row-aside {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.user-row-aside .danger,
.user-row-aside .ghost { min-height: 44px; }
.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.role-badge-owner {
  color: var(--navy-ink);
  background: var(--gold);
}
.role-badge-manager {
  color: var(--gold);
  background: var(--gold-soft);
}
.role-badge-employee {
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
}
.you-chip {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 2px 8px;
}
.search-row { margin-bottom: 12px; }
.history-toolbar .hint { margin-top: 0; }
.history-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 12px;
}
.history-filters .ghost {
  min-height: 44px;
  padding: 8px 10px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.2;
  text-align: center;
}
.history-filters .on {
  background: var(--gold);
  color: var(--navy-ink);
  border-color: var(--gold);
  font-weight: 600;
}
.history-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 12px;
}
.history-presets .ghost,
.history-apply .ghost,
.history-apply .primary {
  min-height: 44px;
}
.history-presets .on {
  background: var(--gold);
  color: var(--navy-ink);
  border-color: var(--gold);
  font-weight: 600;
}
.history-dates,
.history-selects { margin-bottom: 12px; }
.history-apply {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tree { font-size: 15px; }
.tree details { margin: 6px 0 6px 8px; }
.tree summary { padding: 8px 0; }
.file-list { display: grid; gap: 8px; margin-top: 10px; }
.file-list .file-row {
  display: grid;
  gap: 8px;
  background: var(--wash);
  border-radius: 14px;
  padding: 10px 12px;
}

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, var(--glow), var(--bg) 55%);
}
.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 24px;
  padding: 28px 22px;
  border: 1px solid var(--line);
}
.login-card h1 { font-weight: 600; margin: 12px 0 8px; }
.deny-banner {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--danger);
  background: rgba(255, 138, 122, 0.14);
  color: var(--ink);
  font-size: 14px;
}
.nav button.home-tab:not(.active) {
  border-color: var(--gold);
}
.stack-btns { display: grid; gap: 10px; margin-top: 16px; }

.digitize-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: auto;
}
.digitize-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 32, 0.55);
}
.digitize-sheet {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  top: auto;
  max-height: min(88dvh, 720px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--gold);
  border-radius: 20px;
  padding: 16px 16px 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}
body.digitize-open,
body.markpaid-open {
  overflow: hidden;
}
.markpaid-layer {
  position: fixed;
  inset: 0;
  z-index: 42;
  pointer-events: auto;
}
.markpaid-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 32, 0.55);
}
.markpaid-sheet {
  position: absolute;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: min(22rem, 46vw);
  max-width: 46vw;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-height: min(70dvh, 420px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--gold);
  border-radius: 20px;
  padding: 16px 18px 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
}
.markpaid-sheet h2 { margin: 0 0 8px; font-size: 1.15rem; }
.markpaid-txs {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gold);
  word-break: break-word;
}
.markpaid-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.markpaid-actions .primary,
.markpaid-actions .ghost {
  width: fit-content;
  max-width: none;
  white-space: nowrap;
}
.markpaid-actions .primary {
  min-width: 13rem;
  min-height: 48px;
  padding: 10px 22px;
}
.markpaid-actions .ghost {
  min-width: 12rem;
  min-height: 40px;
  padding: 8px 20px;
}
.digitize-sheet h2 { margin: 0 0 6px; font-size: 1.2rem; }
.digitize-brand {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--gold);
  font-weight: 600;
}
.digitize-preview {
  width: 100%;
  height: min(36vh, 320px);
  min-height: 180px;
  border: 0;
  border-radius: 14px;
  background: #fff;
  margin: 10px 0 14px;
  display: block;
  pointer-events: none;
}
.digitize-actions {
  display: grid;
  gap: 8px;
}
.digitize-actions .primary,
.digitize-actions .ghost,
.digitize-actions a {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
}
.digitize-stub {
  background: var(--wash);
  border-radius: 14px;
  padding: 14px;
  margin: 10px 0 14px;
  min-height: 80px;
}
.digitize-fields { margin: 8px 0 4px; }
.digitize-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.digitize-row span { color: var(--muted); }
.digitize-row b { color: var(--gold); font-weight: 600; text-align: right; }

.studio-credit {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.studio-credit p { margin: 0 0 4px; }

@media (max-width: 430px) {
  .top {
    padding: 5px 8px 2px;
    padding-top: calc(5px + env(safe-area-inset-top, 0px));
  }
  .top-chrome { gap: 3px; }
  .brand.mobile-only small { font-size: 9px; line-height: 1.1; }
  .brand-lock { font-size: 14px; }
  .hello { margin: 3px 0 0; }
  .hello h1 { font-size: 1.05rem; }
  .tab-strip.nav { padding: 2px 0 0; gap: 3px; }
  .tab-strip button,
  .tab-strip .nav-more summary {
    min-height: 30px;
    padding: 3px 7px;
    font-size: 12px;
  }
  .wrap { padding-top: 12px; gap: 14px; }
  html[data-locale="th"] .session-chip { max-width: 28%; }
  html[data-locale="th"] .brand.mobile-only { flex: 1 1 42%; }
  .history-filters { gap: 6px; }
  .history-filters .ghost { min-height: 44px; font-size: 13px; padding: 8px 6px; }
  .history-apply .primary,
  .history-apply .ghost,
  .reports-panel .primary,
  .users-admin-panel .invite-form .primary { min-height: 48px; }
  .user-row { flex-direction: column; }
  .user-row-aside { width: 100%; justify-content: space-between; }
  .user-row-aside .danger { flex: 1 1 auto; }
  .cat-chip-actions { grid-template-columns: 1fr; }
  .digitize-sheet {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    max-height: min(92dvh, 100%);
    padding: 14px 12px 16px;
    border-radius: 16px;
  }
  .digitize-sheet h2 { font-size: 1.1rem; }
  .digitize-brand { font-size: 11px; }
  .digitize-preview { height: min(28vh, 200px); min-height: 140px; }
  .digitize-row { flex-wrap: wrap; font-size: 13px; padding: 8px 0; }
  .digitize-actions .primary,
  .digitize-actions .ghost,
  .digitize-actions a { min-height: 48px; }
  .markpaid-sheet {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(18.5rem, 78vw);
    max-width: 78vw;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    padding: 14px 14px 16px;
    border-radius: 16px;
  }
  .markpaid-sheet h2 { font-size: 1.1rem; }
  .markpaid-actions .primary {
    min-width: 12.5rem;
    min-height: 44px;
    white-space: nowrap;
  }
  .markpaid-actions .ghost {
    min-width: 11.5rem;
    min-height: 40px;
    white-space: nowrap;
  }
}

.snap-cards {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}
.snap-card {
  background: var(--wash);
  border-radius: 16px;
  padding: 14px 16px;
}
.snap-card span { color: var(--muted); font-size: 13px; }
.snap-card b { display: block; font-size: 1.35rem; margin: 4px 0 2px; }
.snap-card small { color: var(--muted); }
.reports-panel h2 { margin-bottom: 6px; font-size: 1.2rem; }
.reports-panel .hint,
.history-toolbar .hint { overflow-wrap: anywhere; }
.reports-panel .primary { min-height: 48px; width: 100%; }
.reports-cos { margin: 0 0 16px; overflow-wrap: anywhere; }
.chart-card {
  background: var(--wash);
  border-radius: 16px;
  padding: 14px 14px 16px;
  margin: 0 0 12px;
}
.chart-card h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
}
.chart-pair { display: grid; gap: 12px; }
.chart-bars { display: grid; gap: 12px; }
.chart-bar-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  margin-bottom: 6px;
}
.chart-bar-top span { min-width: 0; overflow-wrap: anywhere; }
.chart-bar-track {
  height: 22px;
  border-radius: 999px;
  background: var(--card);
  overflow: hidden;
}
.chart-bar-fill {
  display: block;
  height: 100%;
  background: var(--gold);
  border-radius: 999px;
  min-width: 8px;
}
.chart-bar-row small { color: var(--muted); font-size: 12px; }
.chart-round {
  display: grid;
  justify-items: center;
  gap: 12px;
}
.chart-donut, .chart-pie {
  width: min(168px, 56vw);
  height: auto;
}
.chart-donut .chart-track {
  fill: none;
  stroke: var(--card);
  stroke-width: 5;
}
.chart-donut .chart-arc {
  fill: none;
  stroke-width: 5;
  transform: rotate(-90deg);
  transform-origin: 18px 18px;
}
.chart-stroke-0 { stroke: var(--gold); }
.chart-stroke-1 { stroke: var(--ok); }
.chart-stroke-2 { stroke: var(--danger); }
.chart-stroke-3 { stroke: var(--muted); }
.chart-fill-0 { fill: var(--gold); background: var(--gold); }
.chart-fill-1 { fill: var(--ok); background: var(--ok); }
.chart-fill-2 { fill: var(--danger); background: var(--danger); }
.chart-fill-3 { fill: var(--muted); background: var(--muted); }
.chart-segbar {
  display: flex;
  width: 100%;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--card);
}
.chart-seg { display: block; min-width: 4px; height: 100%; }
.chart-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: grid;
  gap: 8px;
}
.chart-legend li {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: baseline;
  font-size: 13px;
}
.chart-legend span { overflow-wrap: anywhere; min-width: 0; }
.chart-legend i {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  grid-row: 1 / span 2;
  align-self: center;
}
.chart-legend small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}
.chart-legend b { white-space: nowrap; }
.chart-empty { padding: 18px 8px; }
.error-copy { color: var(--danger); }
.cat-chip {
  display: grid;
  gap: 8px;
  margin: 4px 0 8px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--gold);
  background: var(--gold-soft);
}
.cat-chip-low { border-style: dashed; }
.cat-chip-kicker {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--gold);
}
.cat-chip-bilingual { margin: 0; overflow-wrap: anywhere; }
.cat-chip-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.cat-chip-actions .primary,
.cat-chip-actions .ghost { min-height: 44px; }
.cat-applied { overflow-wrap: anywhere; }
.narrative-card .narrative-copy {
  margin: 0 0 10px;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.5;
}

.theme-picks {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 12px 0 18px;
}
.theme-swatch {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 12px;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--wash);
}
.theme-swatch.on {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
.theme-swatch small {
  display: block;
  opacity: 0.75;
  font-size: 12px;
}
.theme-preview {
  display: grid;
  grid-template-columns: 1fr 14px;
  height: 36px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--swatch-bg, #252e52);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.theme-preview i:nth-child(1) { background: var(--swatch-card, #3a4575); }
.theme-preview i:nth-child(2) { background: var(--swatch-gold, #e6d654); }
.theme-cycle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.theme-cycle .theme-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-soft);
}
.scanner-home .attach-drop {
  margin-top: 12px;
}

.help-doc p { margin: 0 0 14px; max-width: 42rem; }
.help-doc h2 { margin: 22px 0 8px; font-size: 1.15rem; }
.help-doc h2:first-child { margin-top: 0; }

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  background: var(--wash);
  color: var(--ink);
  border: 1px solid var(--gold);
  padding: 14px 16px;
  border-radius: 14px;
  z-index: 15;
  text-align: center;
  pointer-events: none;
}

@media (min-width: 700px) {
  button.chrome-chip {
    min-height: 40px;
    height: 40px;
    padding: 0 14px;
    font-size: 14px;
  }
  button.chrome-chip.theme-cycle {
    width: 40px;
  }
  button.chrome-chip.theme-cycle .theme-dot {
    width: 14px;
    height: 14px;
  }
}

@media (min-width: 800px) {
  .shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100dvh;
  }
  .rail {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    background: var(--wash);
    padding: 24px 18px 18px;
    border-right: 1px solid var(--line);
    overflow: hidden;
  }
  .rail-nav,
  .rail-nav.nav {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .rail-foot {
    flex-shrink: 0;
  }
  .mobile-only, .top .nav, .top .tab-strip, .top .session-chip { display: none; }
  .top-chrome { justify-content: flex-end; }
  .top {
    position: static;
    background: transparent;
    border-bottom: 0;
    padding: 28px 24px 0;
  }
  .wrap { padding: 8px 24px 48px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .user-mail { display: block; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .full { grid-column: 1 / -1; }
  .confirm-actions, .draft-actions { grid-template-columns: 1fr 1fr; }
  .row-actions { grid-template-columns: 1fr; }
  .hello h1 { font-size: 1.9rem; }
  .user-list { grid-template-columns: 1fr 1fr; }
  .history-filters { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .users-admin-panel .invite-form {
    grid-template-columns: 1fr minmax(8rem, 11rem) auto;
    align-items: end;
  }
  .users-admin-panel .invite-form .primary {
    width: auto;
    min-width: 10rem;
  }
  .paid-bar { position: static; }
  .file-picks { grid-template-columns: 1fr 1fr; }
  .desktop-only { display: block; }
  .theme-picks { grid-template-columns: 1fr 1fr; }
  .snap-cards { grid-template-columns: repeat(3, 1fr); }
  .chart-pair { grid-template-columns: 1fr 1fr; }
  .reports-panel .primary { width: auto; min-width: 12rem; }
  .chart-card h3 { font-size: 1.05rem; }
  .digitize-sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(560px, calc(100vw - 48px));
    max-height: min(86vh, 760px);
  }
  .digitize-preview { height: 360px; min-height: 280px; }
}
