/* =====================================================================
   Invoice Extractor — UI
   A restrained, international SaaS look: white app bar, slate neutrals,
   one accent colour, cards on a soft grey canvas, spreadsheet-style grid.
   ===================================================================== */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e6ec;
  --border-soft: #eceef3;
  --border-strong: #d3d7e0;
  --text: #17191f;
  --text-2: #3f4452;
  --muted: #6b7180;
  --muted-2: #8b91a0;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-active: #3730a3;
  --primary-soft: #eef0ff;
  --primary-soft-2: #e0e4ff;
  --primary-soft-text: #4338ca;
  --accent: var(--primary);

  --warn-bg: #fff7e0;
  --warn-border: #f0c96a;
  --warn-text: #8a5a05;
  --error: #d92d20;
  --error-bg: #fdecea;
  --success: #12844a;
  --success-bg: #e3f6ea;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-xs: 0 1px 1px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.07), 0 1px 3px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, 0.16), 0 4px 10px rgba(16, 24, 40, 0.06);
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.18);

  --grid-line: #d6dbe1;          /* Excel-style crisp gridlines */
  --grid-head: #2fd57a;          /* live green header (bright, fresh) */
  --grid-head-2: #16b85c;
  --grid-head-line: #0f9a4b;
  --grid-gutter: #f1f3f5;        /* row-number gutter, like Excel's row headers */
  --grid-hover: #f2faf5;
  --grid-band: #f6fbf8;          /* banded rows */
  --excel-green: #16b85c;
  --excel-green-soft: #e2f8ea;

  --topbar-h: 60px;
  --page-w: 1520px;
}

/* Self-hosted (no external network call at runtime — see fonts/README) */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/inter-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/inter-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/inter-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/inter-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 800; font-display: swap; src: url("fonts/inter-latin-800-normal.woff2") format("woff2"); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", "Noto Sans", "Khmer OS Battambang", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

h1, h2, h3 { letter-spacing: -0.015em; }
a { color: var(--primary); }

.hidden { display: none !important; }
/* The HTML `hidden` attribute must win over any display rule (buttons are
   inline-flex, separators are flex) — otherwise a "hidden" Google button
   still shows on a server where Google sign-in isn't set up. */
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.center { text-align: center; }
.error-text { color: var(--error); font-size: 0.88rem; font-weight: 500; }
.notice-text { color: var(--success); font-size: 0.88rem; font-weight: 500; }
.full-width { width: 100%; }

/* ---------------------------------------------------------------- buttons */
button {
  font: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  background: #eceef3;
  color: var(--text);
  font-weight: 500;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
}
button:hover { background: #e3e6ed; }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:active { background: #d9dde6; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button svg { width: 16px; height: 16px; flex-shrink: 0; }

button.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
button.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
button.primary:active:not(:disabled) { background: var(--primary-active); }

button.ghost {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text-2);
  box-shadow: var(--shadow-xs);
}
button.ghost:hover { background: #f7f8fa; border-color: var(--border-strong); color: var(--text); }

button.small-btn { padding: 6px 12px; font-size: 0.8rem; border-radius: var(--radius-xs); }
button.danger { background: var(--error-bg); color: var(--error); }
button.danger:hover { background: #fbd9d5; }

/* ---------------------------------------------------------------- loading */
.loading-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
}
.spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--primary-soft-2);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- brand */
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; }
.brand-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex-shrink: 0;
  border-radius: 9px;
  background: linear-gradient(150deg, #6366f1 0%, var(--primary) 60%, #4338ca 100%);
  color: #fff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}
.brand-icon svg { width: 18px; height: 18px; }
.brand h1 { margin: 0; font-size: 1.02rem; font-weight: 700; }
.brand-name { font-weight: 700; font-size: 1.02rem; }

/* ================================================================ AUTH / PUBLIC SITE */
/* The public page uses the same light palette as the app. */
.login-screen {
  --site-bg: #f5f6f8;
  --site-card: #ffffff;
  --site-border: var(--border);
  --site-text: var(--text);
  --site-muted: var(--muted);
  --site-input: #ffffff;
  min-height: 100vh;
  color: var(--site-text);
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(99, 102, 241, 0.14), transparent 60%),
    radial-gradient(700px 500px at 0% 20%, rgba(129, 140, 248, 0.10), transparent 60%),
    var(--site-bg);
}
.login-screen .muted { color: var(--site-muted); }
.login-screen a { color: var(--primary); }

.site-nav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--site-border);
}
.site-nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  height: 66px; display: flex; align-items: center; gap: 28px;
}
.login-screen .site-brand { text-decoration: none; color: var(--site-text); justify-content: flex-start; }
.site-brand .brand-name { font-size: 1.08rem; }
.site-links { display: flex; gap: 6px; margin-left: 12px; }
.site-links a {
  color: var(--site-muted); text-decoration: none; font-weight: 500; font-size: 0.94rem;
  padding: 8px 12px; border-radius: 8px;
}
.site-links a:hover { color: var(--site-text); background: #f1f2f6; }
.site-nav-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.nav-plain {
  background: transparent; color: var(--site-text); border-color: transparent;
  font-weight: 500; padding: 9px 14px;
}
.nav-plain:hover, .nav-plain.active { background: #f1f2f6; color: var(--text); }
.nav-pill, button.primary.gradient {
  color: #fff; border: none; font-weight: 600;
  background: linear-gradient(90deg, #6366f1 0%, var(--primary) 60%, #4338ca 100%);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}
.nav-pill { padding: 10px 22px; border-radius: 999px; }
.nav-pill:hover, button.primary.gradient:hover:not(:disabled) {
  /* re-state the gradient: the generic button:hover grey would otherwise win */
  background: linear-gradient(90deg, #6366f1 0%, var(--primary) 60%, #4338ca 100%);
  filter: brightness(1.06); box-shadow: 0 6px 16px rgba(79, 70, 229, 0.38);
}
.nav-pill.active { box-shadow: 0 0 0 3px var(--primary-soft-2), 0 4px 12px rgba(79, 70, 229, 0.3); }
/* Both navbar buttons share one footprint so swapping which one is the
   filled pill doesn't move anything. */
.site-nav-actions .auth-tab { padding: 10px 22px; border-radius: 999px; min-width: 92px; }
button.primary.gradient { border-radius: 999px; padding: 12px 16px; }
@media (max-width: 720px) {
  .site-links { display: none; }
  .site-nav-inner { padding: 0 16px; gap: 12px; }
  .nav-plain { padding: 9px 10px; }
  .nav-pill { padding: 9px 16px; }
}

.site-main { max-width: 1200px; margin: 0 auto; padding: 0 24px 40px; }

/* home page */
.site-home { display: grid; grid-template-columns: minmax(0, 11fr) minmax(0, 9fr); gap: 48px; align-items: center; padding: 72px 0 36px; }
.eyebrow { margin: 0 0 14px; font-size: 0.76rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary-soft-text); }
.site-headline { margin: 0 0 18px; font-size: 3rem; line-height: 1.08; font-weight: 800; letter-spacing: -0.035em; }
.site-headline span { color: var(--primary); }
.site-lead { margin: 0; font-size: 1.1rem; line-height: 1.6; color: var(--text-2); max-width: 540px; }
.site-cta { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 28px; }
.cta-main { padding: 13px 26px !important; font-size: 1rem; }
.cta-secondary {
  display: inline-flex; align-items: center; padding: 12px 22px; border-radius: 999px;
  background: #fff; border: 1px solid var(--border); color: var(--text) !important; text-decoration: none; font-weight: 500; box-shadow: var(--shadow-xs);
}
.cta-secondary:hover { border-color: var(--border-strong); background: #f7f8fa; text-decoration: none; }
.site-cta-note { margin: 14px 0 0; }
.site-home-visual { position: relative; }
/* A small, straight picture of the product: an invoice goes in, a clean sheet comes out. */
.app-window {
  background: #fff; border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.06);
}
.app-window-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: #f6f7f9; border-bottom: 1px solid var(--border); }
.app-window-bar span { width: 10px; height: 10px; border-radius: 50%; background: #d9dde5; }
.app-window-bar span:first-child { background: #f87171; } .app-window-bar span:nth-child(2) { background: #fbbf24; } .app-window-bar span:nth-child(3) { background: #34d399; }
.app-window-bar em { margin-left: 10px; font-style: normal; font-size: 0.74rem; color: var(--muted); font-weight: 500; }
.app-window-body { padding: 16px; display: grid; grid-template-columns: 140px 48px 1fr; gap: 10px; align-items: center; }
.paper {
  position: relative; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 12px 12px 10px;
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.08); font-size: 0.6rem;
}
.paper-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.paper-head strong { font-size: 0.6rem; letter-spacing: 0.02em; }
.paper-head span { color: var(--muted); }
.paper-line { height: 5px; border-radius: 3px; background: #e6e8ee; margin: 4px 0; }
.paper-table { margin: 8px 0 6px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 5px 0; }
.paper-row { display: flex; gap: 4px; margin: 4px 0; }
.paper-row span { height: 4px; border-radius: 2px; background: #e6e8ee; }
.paper-row span:last-child { background: #cfd4de; }
.w15 { width: 15%; } .w20 { width: 20%; } .w40 { width: 40%; } .w45 { width: 45%; } .w50 { width: 50%; } .w55 { width: 55%; } .w60 { width: 60%; }
.paper-total { display: flex; justify-content: space-between; font-size: 0.62rem; }
.paper-total strong { font-size: 0.7rem; }
.paper-stamp {
  position: absolute; right: -8px; top: -8px; transform: rotate(8deg);
  background: var(--excel-green-soft); color: #0f6b38; border: 1px solid #9fe2bd;
  font-size: 0.58rem; font-weight: 700; padding: 3px 7px; border-radius: 999px;
}
.flow-arrow { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--primary); }
.flow-arrow svg { width: 40px; height: 20px; }
.flow-arrow span { font-size: 0.58rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.mini-sheet { border: 1px solid var(--grid-line); border-radius: 8px; overflow: hidden; font-size: 0.66rem; font-variant-numeric: tabular-nums; min-width: 0; }
.mini-sheet-head, .mini-sheet-row { display: grid; grid-template-columns: 24px 1fr 64px 74px; }
.mini-sheet-head span, .mini-sheet-row span { padding: 6px 6px; border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sheet-head span:last-child, .mini-sheet-row span:last-child { border-right: none; }
.mini-sheet-head span { background: linear-gradient(180deg, var(--grid-head) 0%, var(--grid-head-2) 100%); color: #fff; font-weight: 600; }
.mini-sheet-row span:first-child { background: var(--grid-gutter); color: var(--muted-2); text-align: center; font-weight: 600; }
.mini-sheet-row span:nth-child(3), .mini-sheet-row span:nth-child(4) { text-align: right; }
.mini-sheet-row:nth-child(odd) span:not(:first-child) { background: var(--grid-band); }
.mini-sheet-total span { background: var(--excel-green-soft) !important; color: #0f6b38; font-weight: 700; border-top: 2px double var(--excel-green); border-bottom: none !important; }
.app-window-foot { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.chip { font-size: 0.68rem; font-weight: 600; border-radius: 999px; padding: 5px 10px; border: 1px solid transparent; }
.chip-ok { background: var(--success-bg); color: var(--success); }
.chip-warn { background: var(--warn-bg); color: var(--warn-text); }
.chip-export { background: var(--primary); color: #fff; margin-left: auto; }
@media (max-width: 1100px) { .app-window-body { grid-template-columns: 1fr; } .paper { max-width: 220px; } .flow-arrow { flex-direction: row; } .flow-arrow svg { transform: rotate(90deg); } }
@media (max-width: 900px) {
  .site-home { grid-template-columns: 1fr; gap: 40px; padding: 44px 0 20px; }
  .site-headline { font-size: 2.1rem; }
  .site-home-visual { margin: 0 8px; }
}
.auth-hero { display: flex; flex-direction: column; align-items: center; padding: 72px 0 40px; }
.auth-hero-sub { max-width: 560px; margin: 26px 0 0; text-align: center; color: var(--site-muted); font-size: 0.95rem; line-height: 1.55; }

.login-card {
  background: var(--site-card);
  border: 1px solid var(--site-border);
  border-radius: 16px;
  padding: 30px 34px 30px;
  width: 460px; max-width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 1.55rem; margin: 4px 0 6px; font-weight: 800; letter-spacing: -0.025em; }
.auth-switch { margin: 0 0 18px; text-align: center; font-size: 0.9rem; color: var(--site-muted); }
.auth-switch a { color: var(--primary); font-weight: 600; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.auth-form { margin-top: 0; text-align: left; }
.auth-form .field { margin-bottom: 16px; }
.auth-form .field span { color: var(--site-text); font-size: 0.86rem; }
.auth-form .field input {
  background: var(--site-input); color: var(--site-text);
  border-color: var(--border); padding: 12px 14px;
}
.auth-form .field input:focus { border-color: var(--primary); box-shadow: var(--ring); }
/* Password field with a show/hide eye at the right edge. */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 46px; }
.eye-btn {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  width: 34px; height: 34px; padding: 0; border: none; border-radius: 8px;
  background: transparent; color: var(--muted-2); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: none;
}
.eye-btn:hover { background: #f1f2f6; color: var(--text); }
.eye-btn[aria-pressed="true"] { color: var(--primary); }
.eye-btn svg { width: 20px; height: 20px; }
.eye-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.auth-form button.primary { margin-top: 6px; }
.auth-form > .muted.small { margin: 14px 0 0; }
.link-row { text-align: center; margin: 14px 0 0; font-size: 0.85rem; }
.link-row a { color: var(--primary); text-decoration: none; font-weight: 500; }
.link-row a:hover { text-decoration: underline; }
#auth-error, #auth-notice { margin: 14px 0 0; }
.or-sep { display: flex; align-items: center; gap: 12px; margin: 16px 0 12px; color: var(--muted-2); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.or-sep::before, .or-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.google-btn { padding: 10px 16px; border-radius: 999px; font-weight: 600; color: var(--text); gap: 12px; }
.google-btn svg { color: var(--primary); width: 22px; height: 22px; }
.google-btn .google-g { width: 24px; height: 24px; display: block; }
.login-screen .error-text { color: var(--error); }
.login-screen .notice-text { color: var(--success); }

.site-section { padding: 48px 0 8px; }
.site-h2 { text-align: center; font-size: 1.6rem; font-weight: 800; margin: 0 0 8px; letter-spacing: -0.02em; }
.site-sub { text-align: center; color: var(--site-muted); margin: 0 0 24px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 26px; }
.feature { background: var(--site-card); border: 1px solid var(--site-border); border-radius: 14px; padding: 22px 22px 20px; box-shadow: var(--shadow-sm); }
.feature-icon { font-size: 1.5rem; display: block; margin-bottom: 10px; }
.feature h3 { margin: 0 0 6px; font-size: 1.02rem; font-weight: 700; }
.feature p { margin: 0; color: var(--site-muted); font-size: 0.92rem; line-height: 1.5; }
.steps { list-style: none; padding: 0; margin: 26px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; background: var(--site-card); border: 1px solid var(--site-border); border-radius: 14px; padding: 20px; box-shadow: var(--shadow-sm); }
.steps strong { display: block; margin-bottom: 4px; }
.steps p { margin: 0; color: var(--site-muted); font-size: 0.92rem; line-height: 1.5; }
.step-no {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.9rem; color: #fff;
  background: linear-gradient(135deg, #6366f1, #4338ca);
}
.public-plans { margin-top: 26px; }
.public-plans .plan-card { background: var(--site-card); border-color: var(--site-border); color: var(--site-text); }
.public-plans .plan-card:hover { border-color: #c7caf5; box-shadow: var(--shadow-md); }
.public-plans .plan-card p, .public-plans .plan-price span { color: var(--site-muted); }
.public-plans .plan-card button { margin-top: 14px; }
.site-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 56px; color: var(--muted-2); font-size: 0.84rem; }

/* ------------------------------------------------------------- form fields */
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 0.94rem;
  background: #fff; color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input::placeholder { color: var(--muted-2); }
.field input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

/* ================================================================ APP SHELL */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--page-w);
  margin: 0 auto;
  padding: 0 24px;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 22px;
}
.topbar .brand { justify-content: flex-start; flex-shrink: 0; }
.topnav { display: flex; align-items: center; gap: 2px; margin-left: 6px; }
.nav-link {
  background: transparent; border: none;
  padding: 7px 12px; border-radius: var(--radius-xs);
  font-size: 0.9rem; font-weight: 500; color: var(--muted);
}
.nav-link:hover { background: #f1f2f6; color: var(--text); }
.nav-link.active { color: var(--text); font-weight: 600; background: #f1f2f6; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
#export-btn { padding: 8px 14px; font-size: 0.88rem; white-space: nowrap; }

.usage-pill {
  font-size: 0.78rem; font-weight: 500; color: var(--text-2);
  background: #f1f2f6; border: 1px solid transparent;
  border-radius: 999px; padding: 6px 12px; white-space: nowrap;
}
.usage-pill:empty { display: none; }
.usage-pill.low { color: var(--warn-text); background: var(--warn-bg); border-color: var(--warn-border); }

.menu-btn { width: 38px; height: 38px; padding: 0; border-radius: var(--radius-sm); }
.menu-btn svg { width: 18px; height: 18px; }
.account-menu { position: relative; }
.account-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  min-width: 230px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  animation: pop 0.12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.account-dropdown p { margin: 0; padding: 4px 10px; word-break: break-all; }
.account-dropdown .menu-heading { padding-top: 8px; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); }
.account-dropdown #account-email { padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border-soft); font-weight: 500; color: var(--text-2); }
.menu-item {
  display: block; width: 100%; text-align: left;
  background: transparent; border: none;
  padding: 8px 10px; border-radius: var(--radius-xs);
  font-weight: 500; font-size: 0.9rem; color: var(--text);
}
.menu-item:hover { background: #f1f2f6; }
.menu-sep { height: 1px; background: var(--border-soft); margin: 4px 0; }
#logout-btn.menu-item { color: var(--error); }
#logout-btn.menu-item:hover { background: var(--error-bg); }

@media (max-width: 760px) {
  .topnav { display: none; }
  .topbar-inner { gap: 12px; padding: 0 16px; }
  .usage-pill { display: none; }
  #export-btn span { display: none; }
  #export-btn { padding: 8px 10px; }
}

/* ---------------------------------------------------------------- page */
.page { max-width: var(--page-w); margin: 0 auto; padding: 28px 24px 60px; }
@media (max-width: 760px) { .page { padding: 18px 16px 40px; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 0 0 16px; }
.page-title { margin: 0; font-size: 1.45rem; font-weight: 700; }
.page-sub { margin: 4px 0 0; font-size: 0.9rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.card-head h2 { margin: 0 0 2px; font-size: 1.1rem; font-weight: 700; }
.card-head p { margin: 0; }

.page-foot { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; text-align: center; margin-top: 40px; color: var(--muted-2); }

/* ---------------------------------------------------------------- renewal banner */
.renewal-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--warn-bg); border: 1px solid var(--warn-border);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px;
}
.renewal-banner p { margin: 0; color: var(--warn-text); font-size: 0.9rem; font-weight: 500; }
.renewal-banner button { white-space: nowrap; }

/* ---------------------------------------------------------------- paywall / plans */
.paywall, .plans-panel { padding: 24px 26px 26px; margin-bottom: 20px; }
.paywall h2 { margin-top: 0; font-size: 1.2rem; }
.plans-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.plans-panel-header h2 { margin: 0; font-size: 1.1rem; }

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 18px;
}
.plan-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 6px;
  background: #fff;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}
.plan-card:hover { border-color: #c7caf5; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.plan-card h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.plan-card .plan-term-note { font-size: 0.82rem; color: var(--muted); margin: 0; }
.plan-card .plan-save { display: inline-block; font-size: 0.74rem; font-weight: 600; color: var(--success); background: var(--success-bg); border-radius: 999px; padding: 2px 8px; margin-left: 6px; }
/* 1 / 3 / 6 / 12-month switch above the plan cards */
.term-switch { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: #f1f2f6; border: 1px solid var(--border); margin: 0 0 14px; }
.term-switch button {
  border: none; background: transparent; color: var(--text-2); font-weight: 600; font-size: 0.86rem;
  padding: 7px 14px; border-radius: 999px; cursor: pointer; box-shadow: none; display: inline-flex; gap: 6px; align-items: center;
}
.term-switch button:hover { background: #e3e6ed; color: var(--text); }
.term-switch button.active { background: linear-gradient(90deg, #6366f1 0%, var(--primary) 60%, #4338ca 100%); color: #fff; box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3); }
.term-switch button .save-pill { font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,0.22); }
.term-switch button:not(.active) .save-pill { background: var(--success-bg); color: var(--success); }
.public-plans-wrap .term-switch { margin-bottom: 18px; }
.khqr-term { margin: -6px 0 10px; }
.billing-history-head { margin-top: 26px; }
#billing-history td.actions-col a { font-size: 0.82rem; }
/* Admin: plans table + discount row + editor */
.admin-subhead-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-subhead-row .admin-subhead { margin-bottom: 0; }
#admin-plans td.plan-desc { max-width: 320px; color: var(--text-2); font-size: 0.86rem; }
#admin-plans td.plan-order-col { white-space: nowrap; width: 72px; }
#admin-plans td.plan-order-col .icon-btn { width: 28px; height: 28px; font-size: 0.7rem; padding: 0; }
#admin-plans td.plan-order-col .icon-btn:disabled { opacity: 0.3; cursor: default; }
#admin-plans tr.plan-off td { color: var(--muted); }
.billing-terms { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin: 10px 0 22px; padding: 10px 14px; background: #f7f8fb; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.billing-terms-label { font-size: 0.86rem; font-weight: 600; color: var(--text-2); }
.billing-terms .field.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.billing-terms .field.inline span { margin: 0; }
.billing-terms .field.inline input { width: 72px; padding: 6px 8px; }
.billing-terms .field.inline em { font-style: normal; color: var(--muted); }
.billing-terms .error-text { width: 100%; margin: 0; }
/* Admin: one section per tab */
.admin-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--border); margin: 6px 0 18px; }
.admin-tab {
  border: none; background: transparent; box-shadow: none; border-radius: 8px 8px 0 0; padding: 10px 16px;
  font-weight: 600; font-size: 0.92rem; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.admin-tab:hover { background: #f4f5f9; color: var(--text); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: transparent; }
.admin-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.tab-badge { font-size: 0.7rem; font-weight: 700; min-width: 18px; padding: 1px 6px; border-radius: 999px; background: var(--error); color: #fff; text-align: center; }
.admin-pane > .admin-subhead:first-child, .admin-pane > .admin-subhead-row:first-child .admin-subhead { margin-top: 0; }
.admin-pane-shared .admin-filters { margin-bottom: 18px; }
.admin-overview-extra { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.overview-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: #fff; }
.overview-card h4 { margin: 0 0 8px; font-size: 0.9rem; }
.overview-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.88rem; }
.overview-card li { display: flex; justify-content: space-between; gap: 10px; }
.overview-card li a { color: var(--primary); text-decoration: none; font-weight: 500; cursor: pointer; }
.overview-card li a:hover { text-decoration: underline; }
.overview-card .warn-text { color: var(--error); font-weight: 600; }
.library-form { display: grid; grid-template-columns: 120px 1.2fr 1fr 1.4fr auto; gap: 8px; margin: 8px 0 10px; align-items: center; }
.library-form input, .library-form select { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; font-size: 0.88rem; background: #fff; min-width: 0; }
.library-form .error-text { grid-column: 1 / -1; margin: 0; }
.library-wrap { max-height: 340px; overflow: auto; margin-bottom: 18px; }
.library-wrap thead th { position: sticky; top: 0; }
#admin-library td, #admin-corrections td { white-space: normal; vertical-align: top; }
#admin-library tr.hint-off td { color: var(--muted); }
#admin-corrections td.ai-value { color: var(--error); }
#admin-corrections td.fixed-value { color: #0f6b38; font-weight: 500; }
.corrections-help { margin: -4px 0 8px; max-width: 900px; }
@media (max-width: 900px) { .library-form { grid-template-columns: 1fr 1fr; } }
.plan-card-form .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.plan-card-form .modal-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.plan-card .plan-price { font-size: 1.75rem; font-weight: 800; margin-top: 2px; letter-spacing: -0.03em; }
.plan-card .plan-price span { font-size: 0.8rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.plan-card p { margin: 0; font-size: 0.85rem; color: var(--muted); }
.plan-card p:last-of-type { margin-bottom: 8px; }
.plan-card button { margin-top: auto; padding-top: 10px; padding-bottom: 10px; }

/* ---------------------------------------------------------------- batch bar */
.batch-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px 10px 16px;
  margin-bottom: 14px;
}
.batch-bar-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.batch-bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.batch-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary-soft); color: var(--primary);
}
.batch-icon svg { width: 17px; height: 17px; }
.batch-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted-2); }
.batch-name {
  font-weight: 600; font-size: 0.98rem;
  padding: 4px 8px; border-radius: 6px;
  border: 1px solid transparent; outline: none; min-width: 60px; cursor: text;
}
.batch-name:hover { border-color: var(--border); background: #fff; }
.batch-name:focus { border-color: var(--primary); box-shadow: var(--ring); background: #fff; }
.batch-status {
  font-size: 0.75rem; font-weight: 500; color: var(--text-2);
  background: #f1f2f6; border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.batch-status::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); margin-right: 6px; vertical-align: 1px; }
.batch-status.exported { color: var(--success); background: var(--success-bg); }
.batch-status.exported::before { background: var(--success); }
.batch-status:empty { display: none; }
.save-indicator { font-size: 0.78rem; font-weight: 500; color: var(--muted); }
.save-indicator.saving { color: var(--muted); }
.save-indicator.saved { color: var(--success); }
.save-indicator.error { color: var(--error); }

.batches-panel { padding: 20px 22px 22px; margin-bottom: 14px; }

/* ---------------------------------------------------------------- ledger */
/* While the Invoices ledger (or Admin) is open, the workspace steps aside. */
.app--ledger .page-head, .app--ledger #batch-bar, .app--ledger #batches-panel, .app--ledger #dropzone, .app--ledger #upload-choice,
.app--ledger #queue, .app--ledger #results, .app--ledger #plans-panel, .app--ledger #export-btn,
.app--admin .page-head, .app--admin #export-btn, .app--admin #batch-bar, .app--admin #dropzone, .app--admin #upload-choice, .app--admin #queue, .app--admin #results { display: none !important; }
#ledger-table td.flags-cell { min-width: 150px; max-width: 220px; }
#ledger-table td:nth-child(5) { min-width: 150px; }
#ledger-table td:nth-child(7) { min-width: 150px; }
.invoices-panel { padding: 20px 22px 22px; margin-bottom: 14px; }
.ledger-filters {
  display: grid; grid-template-columns: 130px 140px 150px 150px 150px minmax(180px, 1fr) auto;
  gap: 0 12px; align-items: end; margin-top: 16px;
  padding: 14px 16px 6px; background: #f7f8fa; border: 1px solid var(--border-soft); border-radius: 10px;
}
.ledger-filters .field { margin-bottom: 10px; }
.ledger-filters .field input, .ledger-filters .field select { padding: 8px 10px; font-size: 0.9rem; }
.ledger-filter-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.ledger-filter-actions button { padding: 8px 14px; font-size: 0.88rem; }
.ledger-presets { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
.chip-btn { background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 0.78rem; font-weight: 500; color: var(--text-2); }
.chip-btn:hover { border-color: var(--primary); color: var(--primary-soft-text); background: var(--primary-soft); }
.ledger-summary { margin: 14px 0 8px; }
#ledger-table td { white-space: normal; }
#ledger-table td.num, #ledger-table td[data-col="date"], #ledger-table td[data-col="inv"] { white-space: nowrap; }
#ledger-table td[data-col="batch"] { font-size: 0.78rem; color: var(--muted); max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#ledger-table td[data-col="batch"] a { color: var(--primary); text-decoration: none; font-weight: 500; }
#ledger-table td[data-col="batch"] a:hover { text-decoration: underline; }
.kind-pill { display: inline-block; font-size: 0.7rem; font-weight: 600; border-radius: 999px; padding: 2px 8px; letter-spacing: 0.02em; }
.kind-pill.expense { background: #fff1e3; color: #c2540a; }
.kind-pill.sale { background: #e3f6ea; color: #12844a; }
@media (max-width: 1100px) { .ledger-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } .ledger-search { grid-column: span 2; } }
@media (max-width: 640px) { .ledger-filters { grid-template-columns: 1fr 1fr; } .ledger-search { grid-column: span 2; } }
.batches-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.batches-list > .muted { padding: 8px 0; }
.batch-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  transition: border-color 0.15s, background 0.15s;
}
.batch-row:hover { border-color: var(--border-strong); }
.batch-row.current { border-color: #c7caf5; background: var(--primary-soft); }
.batch-row-main { flex: 1; min-width: 180px; display: block; }
.batch-row-main > .muted { display: block; margin-top: 2px; }
.batch-current-tag {
  display: inline-block; margin-left: 8px;
  font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--primary-soft-text); background: #fff; border: 1px solid #c7caf5; border-radius: 999px; padding: 1px 7px;
}
.batch-row-actions { display: flex; gap: 6px; }

/* ---------------------------------------------------------------- admin */
.admin-panel { padding: 20px 22px 24px; margin-bottom: 20px; }
.admin-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 18px 0 6px; }
.admin-tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.admin-tile strong { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.admin-tile-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); }
.admin-subhead { margin: 22px 0 8px; font-size: 0.92rem; font-weight: 700; }
.admin-subhead .muted { font-weight: 500; margin-left: 8px; }
.admin-filters { grid-template-columns: 130px 140px 150px 150px minmax(200px, 1fr) auto; }
.ai-settings { background: #f7f8fa; border: 1px solid var(--border-soft); border-radius: 10px; padding: 14px 16px 10px; }
.ai-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }
.ai-settings .field small { display: block; margin-top: 4px; font-size: 0.74rem; line-height: 1.35; }
.ai-settings-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.ai-settings-foot p { margin: 0; }
.ai-settings-foot .batch-bar-actions { align-items: center; }
.admin-panel tfoot td { padding: 10px 12px; font-weight: 700; color: #0f6b38; background: var(--excel-green-soft); border-top: 3px double var(--excel-green); }
.admin-panel tfoot td .muted { font-weight: 500; }
@media (max-width: 1100px) { .admin-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.admin-panel .table-wrap, .plans-panel .table-wrap { box-shadow: none; }
.admin-panel table, .plans-panel table { border-collapse: collapse; width: 100%; font-size: 0.86rem; }
.admin-panel thead th, .plans-panel thead th {
  text-align: left; background: linear-gradient(180deg, var(--grid-head) 0%, var(--grid-head-2) 100%); color: #fff;
  font-weight: 600; font-size: 0.78rem;
  padding: 10px 12px; border-bottom: 2px solid var(--grid-head-line); white-space: nowrap;
}
.admin-panel tbody td, .plans-panel tbody td { padding: 9px 12px; border-bottom: 1px solid var(--grid-line); vertical-align: middle; font-variant-numeric: tabular-nums; }
.admin-panel tbody tr:last-child td, .plans-panel tbody tr:last-child td { border-bottom: none; }
.admin-panel tbody tr:hover td, .plans-panel tbody tr:hover td { background: var(--grid-hover); }
.admin-panel th.num, .admin-panel td.num { text-align: right; white-space: nowrap; }
.admin-panel td.num .muted { font-size: 0.74rem; }
.profit-pos { color: #0f6b38; font-weight: 600; }
.profit-neg { color: var(--error); font-weight: 600; }
.admin-totals { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.flag-badge.flag-info { color: #1e4fa3; background: #e8f0fe; border-left-color: #4f86f7; }
.admin-actions { min-width: 170px; }
.admin-actions button { margin: 0 4px 4px 0; white-space: nowrap; }
.admin-tag {
  display: inline-block; margin-left: 6px;
  font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--primary-soft-text); background: var(--primary-soft); border-radius: 999px; padding: 1px 7px;
}
.status-pill { display: inline-block; font-size: 0.74rem; font-weight: 500; border-radius: 999px; padding: 3px 9px; background: #f1f2f6; color: var(--text-2); }
.status-pill.ok { background: var(--success-bg); color: var(--success); }
.status-pill.warn { background: var(--warn-bg); color: var(--warn-text); }
.status-pill.danger { background: var(--error-bg); color: var(--error); }
tr.row-disabled td { color: var(--muted); }
.danger-text { color: var(--error); }
.link-btn { padding: 1px 7px; font-size: 0.74rem; vertical-align: middle; }
.payment-events-row td { background: var(--surface-2, #f7f8fb); border-top: 0; }
.payment-events { padding: 6px 4px 8px; }
.payment-events p { margin: 0 0 6px; }
.payment-events ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.payment-events li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 4px 8px; border-left: 3px solid var(--border-strong); background: #fff; border-radius: 4px; }
.payment-events li strong { font-weight: 600; }

/* ---------------------------------------------------------------- dropzone */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px 16px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.dropzone:hover { border-color: #b4b8f0; }
.dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--ring); }
.dropzone-inner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dropzone-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--primary-soft); color: var(--primary); flex-shrink: 0;
}
.dropzone-icon svg { width: 18px; height: 18px; }
.dropzone-inner p { margin: 0; font-size: 0.92rem; color: var(--text-2); }
.dropzone-inner p strong { color: var(--text); font-weight: 600; }
.dropzone-hint { margin-left: auto !important; font-size: 0.78rem !important; color: var(--muted-2) !important; }
.file-picker {
  display: inline-flex; align-items: center;
  background: var(--primary); color: #fff;
  padding: 7px 14px; border-radius: var(--radius-sm);
  cursor: pointer; font-weight: 500; font-size: 0.88rem;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.28);
  transition: background 0.15s;
}
.file-picker:hover { background: var(--primary-hover); }

/* ---------------------------------------------------------------- expense or sale? */
.upload-choice { margin-top: 14px; padding: 18px 20px 20px; border-color: #c7caf5; box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow-md); animation: pop 0.16s ease-out; }
.upload-choice-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.upload-choice-title { margin: 0 0 2px; font-size: 1.05rem; font-weight: 700; }
.upload-choice-head p { margin: 0; max-width: 640px; }
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 16px; }
.file-chip {
  display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.78rem; font-weight: 500; color: var(--text-2);
  background: #f1f2f6; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px;
}
.kind-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.kind-option {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 16px 18px; border-radius: 12px;
  background: #fff; border: 1.5px solid var(--border); box-shadow: var(--shadow-xs);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s, background 0.15s;
}
.kind-option:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); background: #fff; }
.kind-option:active { transform: none; }
.kind-expense:hover { border-color: #f0a35c; }
.kind-sale:hover { border-color: #3fb27f; }
.kind-icon { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0; }
.kind-icon svg { width: 22px; height: 22px; }
.kind-expense .kind-icon { background: #fff1e3; color: #c2540a; }
.kind-sale .kind-icon { background: #e3f6ea; color: #12844a; }
.kind-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.kind-text strong { font-size: 1rem; font-weight: 700; }
.kind-text span { font-size: 0.82rem; color: var(--muted); font-weight: 400; line-height: 1.35; }
.kind-text em { font-style: normal; font-weight: 600; color: var(--text-2); }
.kind-cta { font-size: 0.8rem; font-weight: 600; white-space: nowrap; padding: 7px 12px; border-radius: 7px; flex-shrink: 0; }
.kind-expense .kind-cta { background: #fff1e3; color: #c2540a; }
.kind-sale .kind-cta { background: #e3f6ea; color: #12844a; }
.kind-expense:hover .kind-cta { background: #ea7c1d; color: #fff; }
.kind-sale:hover .kind-cta { background: #16a35b; color: #fff; }
@media (max-width: 600px) { .kind-cta { display: none; } }
.dropzone.has-staged { border-color: #c7caf5; }

/* ---------------------------------------------------------------- upload queue */
.queue { margin-top: 14px; padding: 4px 0; }
.queue-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; font-size: 0.9rem;
  border-bottom: 1px solid var(--border-soft);
}
.queue-row:last-child { border-bottom: none; }
.queue-row > span:first-child { min-width: 0; word-break: break-word; }
.queue-status { font-size: 0.78rem; font-weight: 600; white-space: nowrap; margin-left: 12px; border-radius: 999px; padding: 3px 10px; background: #f1f2f6; }
.queue-note { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 2px; font-weight: 400; }
.status-queued { color: var(--muted); }
.status-processing { color: var(--primary-soft-text); background: var(--primary-soft); }
.status-done { color: var(--success); background: var(--success-bg); }
.status-error { color: var(--error); background: var(--error-bg); }
.status-rejected { color: var(--warn-text); background: var(--warn-bg); }

/* ---------------------------------------------------------------- KPI strip */
.results { margin-top: 20px; }
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi-strip:empty { display: none; }
.kpi {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; box-shadow: var(--shadow-xs);
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.kpi-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); }
.kpi-value { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value small { font-size: 0.78rem; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.kpi-sub { font-size: 0.78rem; color: var(--muted); }
.kpi.warn .kpi-value { color: var(--warn-text); }
.kpi.ok .kpi-value { color: var(--success); }

/* ---------------------------------------------------------------- review card + tabs */
.review-card { padding: 14px 14px 16px; }
.results-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.tab-rows { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tabs { display: inline-flex; gap: 2px; background: #eef0f4; border-radius: 9px; padding: 3px; }
.tab {
  background: transparent; border: none;
  border-radius: 7px; padding: 7px 16px;
  font-weight: 600; font-size: 0.9rem; color: var(--muted);
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.55); }
.tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.tabs-view .tab { padding: 7px 14px; font-size: 0.84rem; }
.tabs-view .tab.active { color: var(--primary-soft-text); }
.tab-count {
  display: inline-block; min-width: 20px; margin-left: 6px; padding: 1px 6px;
  border-radius: 999px; background: #dfe2ea; color: var(--text-2);
  font-size: 0.7rem; text-align: center; font-weight: 600;
}
.tab.active .tab-count { background: var(--primary-soft); color: var(--primary-soft-text); }

.legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 0.76rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--grid-line); background: #fff; }
.swatch-edit { border-color: var(--excel-green); box-shadow: inset 0 0 0 1px var(--excel-green); }
.swatch-derived { background: #f4f6f8; }
.swatch-warn { background: #fff4d6; border-color: #f0c96a; }
.swatch-error { background: #fde3e0; border-color: #f2a39b; }
.grid-help { margin: 0 0 6px; color: var(--muted-2); }

.grid-title { margin: 14px 0 8px; font-size: 0.88rem; font-weight: 700; color: var(--text-2); }
.grid-title .muted { font-weight: 500; margin-left: 6px; color: var(--muted-2); }
.empty-cell { text-align: center; padding: 26px 12px !important; height: auto !important; white-space: normal !important; color: var(--muted); background: #fff !important; }

/* ---------------------------------------------------------------- column header menu */
.date-head { white-space: nowrap !important; }
.th-menu-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; padding: 0; margin-left: 4px; vertical-align: middle;
  border-radius: 4px; border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.18); color: #fff; font-size: 0.7rem; line-height: 1;
  text-shadow: none;
}
.th-menu-btn:hover, .th-menu-btn.open { background: #fff; color: var(--grid-head-2); }
.th-menu {
  position: absolute; z-index: 70; min-width: 230px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 6px; box-shadow: var(--shadow-lg); animation: pop 0.12s ease-out;
}
.th-menu .menu-heading { margin: 0; padding: 6px 10px 4px; font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); }
.th-menu-note { margin: 4px 0 2px; padding: 6px 10px 4px; border-top: 1px solid var(--border-soft); font-size: 0.74rem; line-height: 1.35; }
.th-menu .menu-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.th-menu .menu-item .example { font-size: 0.78rem; color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.th-menu .menu-item.active { background: var(--excel-green-soft); color: #0f6b38; }
.th-menu .menu-item::after { content: ""; width: 14px; text-align: right; flex-shrink: 0; }
.th-menu .menu-item .example { margin-left: auto; }
.th-menu .menu-item.active::after { content: "\2713"; font-weight: 700; }

/* ---------------------------------------------------------------- spreadsheet grid */
.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--grid-line);
  border-radius: 10px;
}
table.grid {
  border-collapse: separate; border-spacing: 0;
  width: 100%;
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
table.grid th, table.grid td {
  border-right: 1px solid var(--grid-line);
  border-bottom: 1px solid var(--grid-line);
  padding: 0 6px;
  height: 36px;
  vertical-align: middle;
  white-space: nowrap;
}
table.grid th:last-child, table.grid td:last-child { border-right: none; }
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tfoot td { border-bottom: none; border-top: 2px solid var(--border-strong); }
table.grid thead th {
  position: sticky; top: 0; z-index: 2;
  text-align: left;
  background: linear-gradient(180deg, var(--grid-head) 0%, var(--grid-head-2) 100%);
  color: #fff;
  font-weight: 600; font-size: 0.78rem; letter-spacing: 0.01em;
  border-right: 1px solid rgba(255, 255, 255, 0.22);
  border-bottom: 2px solid var(--grid-head-line);
  white-space: normal; line-height: 1.2;
  padding-top: 9px; padding-bottom: 9px;
  vertical-align: middle;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
}
table.grid thead th:last-child { border-right: none; }
table.grid th.num, table.grid td.num { text-align: right; }
table.grid td.num { min-width: 58px; }
table.grid .rownum {
  width: 36px; min-width: 36px; text-align: center;
  color: #5b6472; font-size: 0.74rem; font-weight: 600;
  background: var(--grid-gutter); padding: 0 4px;
  border-right: 1px solid #c9cfd6;
}
/* Banded rows, like an Excel table style */
table.grid tbody tr:nth-child(even) td { background: var(--grid-band); }
table.grid th.rownum { background: linear-gradient(180deg, var(--grid-head) 0%, var(--grid-head-2) 100%); color: rgba(255, 255, 255, 0.85); }
table.grid .expand-col { width: 44px; min-width: 44px; padding: 0 6px; text-align: center; }
table.grid .actions-col { width: 88px; min-width: 88px; text-align: center; padding: 0 2px; white-space: nowrap; }
table.grid td.actions-col { font-size: 0; line-height: 0; }
table.grid .actions-col .icon-btn { width: 26px; height: 26px; margin: 0 1px; font-size: 0.9rem; line-height: 1; }
.icon-btn.edit-btn svg { width: 15px; height: 15px; }
table.grid td[data-field="vendor_name"] { min-width: 108px; white-space: normal; }
table.grid td[data-field="customer_name"] { min-width: 108px; white-space: normal; }
table.grid td[data-field="invoice_number"] { min-width: 112px; white-space: nowrap; }
table.grid td[data-field="invoice_date"] { min-width: 88px; }
table.grid td[data-field="currency"] { width: 64px; text-transform: uppercase; }
table.grid td[data-field="description"] { min-width: 110px; white-space: normal; }
table.grid td[data-field="vendor_tin"], table.grid td[data-field="customer_tin"] { min-width: 88px; }
table.grid td[data-field="exchange_rate"] { min-width: 60px; }
table.grid td.flags-cell { white-space: normal; min-width: 132px; max-width: 200px; padding: 5px 6px; font-size: 0.78rem; }
table.grid td.source-file { white-space: normal; min-width: 96px; max-width: 120px; font-size: 0.72rem; line-height: 1.25; }
table.grid tbody tr:hover td { background: var(--grid-hover); }
table.grid tbody tr:hover td.rownum { background: var(--excel-green-soft); color: #0f6b38; }
table.grid tbody tr:focus-within td.rownum { background: var(--excel-green-soft); color: #0f6b38; font-weight: 700; }

.icon-btn {
  width: 28px; height: 28px; padding: 0;
  border-radius: 6px; font-size: 0.92rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn.ghost { border: 1px solid var(--border); background: #fff; color: var(--muted); margin-right: 3px; box-shadow: none; }
.icon-btn.ghost:hover { color: var(--primary); border-color: #c7caf5; background: var(--primary-soft); }
.icon-btn.danger { background: transparent; color: var(--muted-2); }
.icon-btn.danger:hover { background: var(--error-bg); color: var(--error); }

/* Rows are never tinted: a problem is shown as a note in the Check column
   (and only there), so the sheet reads like a clean spreadsheet. */
table.grid tbody tr.has-flags td.rownum::after,
table.grid tbody tr.row-error td.rownum::after {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #e9b949; margin-left: 4px; vertical-align: 1px;
}
table.grid tbody tr.row-error td.rownum::after { background: var(--error); }

/* Editable cells: a crisp selection outline, like a spreadsheet's active cell */
td[contenteditable="true"] { outline: none; cursor: cell; transition: none; }
td[contenteditable="true"]:hover { background: #eef7f2 !important; }
td[contenteditable="true"]:focus {
  background: #fff !important;
  outline: 2px solid var(--excel-green);
  outline-offset: -2px;
  box-shadow: none;
  position: relative; z-index: 1;
}
/* the little fill-handle square Excel draws on the active cell */
td[contenteditable="true"]:focus::after {
  content: ""; position: absolute; right: -1px; bottom: -1px;
  width: 6px; height: 6px; background: var(--excel-green); border: 1px solid #fff;
}
td.cell-invalid { background: var(--error-bg) !important; color: var(--error); font-weight: 500; position: relative; }
td.cell-invalid::after {
  content: ""; position: absolute; top: 0; right: 0;
  border: 5px solid transparent; border-top-color: var(--error); border-right-color: var(--error);
}

th.select-col, td.select-col { width: 34px; min-width: 34px; text-align: center; padding: 0 4px; background: var(--grid-gutter); }
th.select-col { background: linear-gradient(180deg, var(--grid-head) 0%, var(--grid-head-2) 100%); }
.select-col input { width: 15px; height: 15px; accent-color: var(--excel-green); cursor: pointer; margin: 0; vertical-align: middle; }
th.select-col input { accent-color: #fff; }

.totals-row td { background: var(--excel-green-soft) !important; font-weight: 700; color: #0f6b38; }
table.grid tfoot td { border-top: 3px double var(--excel-green); }
.totals-row td.rownum { font-size: 0.9rem; }
table.grid td.derived { color: var(--text-2); background: #f4f6f8; cursor: default; }
table.grid tbody tr:nth-child(even) td.derived { background: #eff3f1; }
table.grid tbody tr:hover td.derived { background: #e9f3ee; }
table.grid td.derived-text { color: var(--text-2); background: #f4f6f8; max-width: 150px; white-space: normal; font-size: 0.8rem; }
table.grid tbody tr:nth-child(even) td.derived-text { background: #eff3f1; }
table.grid td.converted { background: #f3f7ff; }
table.grid td.khr { font-weight: 500; }
/* Exchange rate: a default rate is shown muted with a small "default" tag so it
   is never mistaken for a rate printed on the invoice. */
table.grid td.rate-default { color: var(--muted); font-style: italic; }
table.grid td.rate-default::before { content: "default"; display: block; font-size: 0.6rem; font-style: normal; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted-2); line-height: 1; margin-bottom: 2px; }
table.grid td.rate-default:focus { color: var(--text); font-style: normal; }
table.grid td.rate-default:focus::before { display: none; }
.part-chip {
  display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary-soft-text);
  font-size: 0.66rem; font-weight: 700;
}
.cur-chip {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px;
  background: #e8eaf2; color: var(--text-2);
  font-size: 0.64rem; font-weight: 700; letter-spacing: 0.04em;
  vertical-align: middle; user-select: none; pointer-events: none;
}
table.grid td.flags-cell .source-file { display: block; margin-top: 2px; }
table.grid tr.detail-row td { height: 32px; }
table.grid tr.detail-first td { border-top: 2px solid var(--border-strong); }
table.grid tr.detail-row:not(.detail-first) td.rownum,
table.grid tr.detail-row:not(.detail-first) td.derived-text { color: transparent; }
table.grid tr.detail-row:not(.detail-first):hover td.derived-text { color: #b0b4c4; }

.flag-badge {
  display: block;
  font-size: 0.74rem; font-weight: 500; line-height: 1.3;
  color: var(--warn-text);
  background: #fff1c9;
  border-left: 3px solid #e9b949;
  padding: 3px 8px; border-radius: 0 5px 5px 0;
  margin: 3px 0;
  white-space: normal;
}
.flag-badge.flag-error { color: var(--error); background: #fdeceb; border-left-color: #ef4444; }
.row-error-msg { color: var(--error); font-size: 0.82rem; font-weight: 500; white-space: normal; }
.source-file { font-size: 0.74rem; color: var(--muted-2); word-break: break-all; }

.line-items-toggle { font-size: 0.78rem; color: var(--primary); font-weight: 600; cursor: pointer; background: none; padding: 2px 4px; border-radius: 4px; }
.line-items-toggle:hover { background: var(--primary-soft); }
.line-items-toggle .li-count { margin-left: 3px; }
.line-items-panel { font-size: 0.82rem; padding: 8px 12px 10px 76px; background: #f9fafc; white-space: normal; height: auto; }
table.line-items-grid { width: auto; min-width: 480px; max-width: 720px; font-size: 0.82rem; border: 1px solid var(--grid-line); border-radius: 6px; overflow: hidden; background: #fff; }
table.line-items-grid th, table.line-items-grid td { height: 30px; padding: 0 8px; }
table.line-items-grid thead th { position: static; font-size: 0.68rem; }
table.line-items-grid td[data-field="description"] { min-width: 220px; white-space: normal; }
table.line-items-grid td.num { min-width: 72px; }
table.line-items-grid tbody tr:last-child td { border-bottom: none; }

/* ---------------------------------------------------------------- modals */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(17, 19, 31, 0.5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal-card {
  position: relative;
  background: var(--panel);
  border-radius: 14px;
  padding: 28px;
  width: 380px; max-width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: pop 0.14s ease-out;
}
.modal-close { position: absolute; top: 14px; right: 14px; }

.settings-card { text-align: left; width: 460px; }
.settings-card h2 { margin: 0 0 6px; font-size: 1.15rem; font-weight: 700; padding-right: 70px; }
.settings-card > p { margin: 0 0 14px; }
.settings-card .error-text { margin: 0 0 10px; }
.settings-card button.primary { margin-top: 4px; padding: 11px 16px; }

/* edit one invoice */
.invoice-edit-card { text-align: left; width: 760px; max-height: calc(100vh - 40px); overflow-y: auto; }
.invoice-edit-card h2 { margin: 0 0 4px; font-size: 1.15rem; font-weight: 700; padding-right: 70px; }
.invoice-edit-card > p.muted { margin: 0 0 14px; }
.edit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.edit-grid .field { margin-bottom: 12px; }
.edit-grid .edit-wide { grid-column: span 2; }
.edit-grid .field span em { font-style: normal; color: var(--primary-soft-text); }
.field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 0.94rem; background: #fff; color: var(--text); box-shadow: var(--shadow-xs);
}
.field select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input-invalid { border-color: var(--error) !important; background: var(--error-bg) !important; }
.edit-lines-head { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 8px; }
.edit-lines-head h3 { margin: 0; font-size: 0.92rem; font-weight: 700; }
.edit-lines-wrap { max-height: 260px; overflow-y: auto; }
table.edit-lines td { padding: 3px 4px; height: auto; }
table.edit-lines thead th { position: static; }
table.edit-lines input {
  width: 100%; padding: 7px 8px; border: 1px solid transparent; border-radius: 6px;
  font: inherit; font-size: 0.86rem; background: transparent;
}
table.edit-lines td.num input { text-align: right; }
table.edit-lines input:hover { border-color: var(--border); background: #fff; }
table.edit-lines input:focus { outline: none; border-color: var(--excel-green); box-shadow: 0 0 0 2px var(--excel-green-soft); background: #fff; }
table.edit-lines .actions-col { width: 40px; min-width: 40px; }
table.edit-lines th:first-child { width: 46%; }
.edit-notes { margin: 12px 0 0; padding: 8px 10px; background: #f6f7f9; border-radius: 8px; }
.invoice-edit-card .error-text { margin: 12px 0 0; }
.edit-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@media (max-width: 720px) { .edit-grid { grid-template-columns: 1fr 1fr; } .edit-grid .edit-wide { grid-column: span 2; } }

.khqr-card h2 { margin: 0 0 6px; font-size: 1.15rem; font-weight: 700; }
.khqr-amount { font-weight: 600; margin: 0 0 16px; color: var(--muted); }
.khqr-qr-wrap {
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; display: inline-flex; margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
#khqr-qr-image { width: 220px; height: 220px; display: block; transition: opacity 0.15s; }
#khqr-qr-image.khqr-qr-faded { opacity: 0.25; }
.khqr-status { font-weight: 600; margin: 14px 0 2px; }
.khqr-status-pending { color: var(--muted); }
.khqr-status-paid { color: var(--success); }
.khqr-status-expired { color: var(--error); }
.khqr-status-mismatch { color: var(--error); }
#khqr-expiry { margin: 0 0 18px; }
#khqr-check-now-btn, #khqr-regenerate-btn { margin-top: 8px; }

/* ---------------------------------------------------------------- print */
@media print {
  .topbar, .dropzone, .batch-bar-actions, .page-foot, .legend, .grid-help, .actions-col { display: none !important; }
  .page { padding: 0; }
  .card { box-shadow: none; }
}

/* ---------------------------------------------------------------- empty state */
/* With nothing in the batch yet, the upload area becomes the hero of the page. */
.page:has(#results.hidden):has(#queue.hidden):has(#upload-choice.hidden) .dropzone { padding: 44px 24px; background: #fff; }
.page:has(#results.hidden):has(#queue.hidden):has(#upload-choice.hidden) .dropzone-inner { flex-direction: column; justify-content: center; text-align: center; gap: 10px; }
.page:has(#results.hidden):has(#queue.hidden):has(#upload-choice.hidden) .dropzone-icon { width: 56px; height: 56px; border-radius: 16px; margin-bottom: 4px; }
.page:has(#results.hidden):has(#queue.hidden):has(#upload-choice.hidden) .dropzone-icon svg { width: 26px; height: 26px; }
.page:has(#results.hidden):has(#queue.hidden):has(#upload-choice.hidden) .dropzone-inner p { font-size: 1rem; }
.page:has(#results.hidden):has(#queue.hidden):has(#upload-choice.hidden) .dropzone-hint { margin-left: 0 !important; margin-top: 6px !important; }
.page:has(#results.hidden):has(#queue.hidden):has(#upload-choice.hidden) .file-picker { padding: 10px 20px; font-size: 0.92rem; }

/* Detail view: the invoice-level columns are read-only labels; keep dates,
   numbers and TINs on one line and let only the vendor name wrap. */
#detail-table td.derived-text { white-space: nowrap; max-width: none; }
#detail-table td.derived-text:nth-child(4) { white-space: normal; max-width: 180px; min-width: 130px; }
#detail-table td[data-field="description"] { min-width: 200px; }
#detail-table td.derived-text.muted { white-space: normal; }

/* Search above the grid + the translate switch in Vendor / Description cells */
.grid-search { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.grid-search select, .grid-search input { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; font-size: 0.86rem; background: #fff; }
.grid-search input { width: 220px; }
.grid-search input:focus, .grid-search select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.grid-search #grid-search-clear { padding: 5px 8px; }
.results-header .legend { margin-left: 16px; }
@media (max-width: 1100px) { .grid-search { margin-left: 0; width: 100%; } .grid-search input { flex: 1; width: auto; } }
.tr-btn {
  display: inline-flex; align-items: center; justify-content: center; margin-left: 6px; padding: 0 5px; min-width: 22px; height: 18px;
  font-size: 0.66rem; font-weight: 700; line-height: 1; color: var(--primary); background: var(--primary-soft, #eef2ff);
  border: 1px solid #c7caf5; border-radius: 5px; cursor: pointer; vertical-align: middle; box-shadow: none; user-select: none;
}
.tr-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* A file being read: spinner, live status, moving bar */
.queue-row { position: relative; }
.queue-row.is-reading { background: linear-gradient(90deg, #fff 0%, var(--primary-soft, #eef2ff) 50%, #fff 100%); background-size: 200% 100%; animation: reading-sheen 2.4s linear infinite; }
.queue-name { min-width: 0; }
.reading-line { display: block; margin-left: 0; color: var(--primary); font-weight: 500; }
.queue-status { display: inline-flex; align-items: center; gap: 7px; }
.queue-status .reading-time { font-variant-numeric: tabular-nums; font-weight: 500; opacity: 0.8; }
.queue-tick { font-weight: 800; }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(79, 70, 229, 0.25); border-top-color: var(--primary); animation: spin 0.8s linear infinite; flex: none; }
.queue-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; overflow: hidden; background: rgba(79, 70, 229, 0.12); border-radius: 0 0 var(--radius) var(--radius); }
.queue-bar i { position: absolute; top: 0; bottom: 0; width: 35%; border-radius: 3px; background: linear-gradient(90deg, #6366f1, var(--primary), #22c55e); animation: bar-slide 1.6s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bar-slide { 0% { left: -35%; } 100% { left: 100%; } }
@keyframes reading-sheen { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  .queue-row.is-reading, .spinner, .queue-bar i { animation-duration: 6s; }
}

/* ------------------------------------------------ header stays while scrolling */
/* The table scrolls inside its own frame, so the green header row stays in
   view however long the list of invoices is. */
.table-wrap { overflow: auto; max-height: calc(100vh - 130px); }
.table-wrap > table > thead th { position: sticky; top: 0; z-index: 3; }
.table-wrap > table.grid > tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--panel); }
.edit-lines-wrap, .library-wrap { max-height: 340px; }
@media print { .table-wrap { max-height: none; overflow: visible; } }

/* ------------------------------------------------ admin adjust / confirm / idle */
.adjust-card { width: 460px; text-align: left; }
.adjust-row { display: grid; grid-template-columns: 72px auto auto 1fr auto auto; gap: 6px; align-items: center; margin: 10px 0; }
.adjust-row span { font-weight: 600; font-size: 0.9rem; }
.adjust-row input { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; text-align: center; min-width: 0; width: 100%; }
.adjust-preview { background: var(--excel-green-soft); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.88rem; line-height: 1.6; margin: 10px 0; }
.adjust-card .modal-actions, .confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.confirm-card { text-align: left; }
.idle-warning {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200;
  display: flex; align-items: center; gap: 14px;
  background: #1f2433; color: #fff; padding: 12px 16px; border-radius: 12px;
  box-shadow: var(--shadow-lg); font-size: 0.9rem; max-width: calc(100vw - 32px);
}

/* The batch summary tiles sit directly under the Workspace title. */
.app--ledger #kpi-strip, .app--admin #kpi-strip, .app--plans #kpi-strip { display: none !important; }
