/* ===================== ProExpenses — styles =====================
   Calm, neutral workspace. One accent (deep harbour teal) for forward actions;
   status colours appear only as small dots and pills.                        */
:root {
  --bg: #f3f5f5;
  --surface: #ffffff;
  --surface-2: #f7f8f8;
  --surface-3: #eef1f1;
  --line: #e2e6e6;
  --line-2: #d3d9d9;
  --ink: #111517;
  --ink-2: #374042;
  --muted: #6b7576;
  --faint: #98a1a2;

  --accent: #0d6460;
  --accent-hover: #0a524f;
  --accent-ink: #ffffff;
  --accent-soft: #e4f0ee;
  --focus: rgba(13, 100, 96, 0.28);

  --danger: #c2362b;
  --danger-soft: #fbeceb;

  --st-draft: #8a9495;   --st-draft-bg: #eef1f1;
  --st-sub: #3866c9;     --st-sub-bg: #ebf0fb;
  --st-pend: #b8710c;    --st-pend-bg: #fbf2e3;
  --st-reim: #2c8655;    --st-reim-bg: #e7f4ec;

  --shadow-xs: 0 1px 2px rgba(17, 21, 23, 0.05);
  --shadow-sm: 0 1px 2px rgba(17, 21, 23, 0.04), 0 2px 6px rgba(17, 21, 23, 0.04);
  --shadow-lg: 0 1px 3px rgba(17, 21, 23, 0.06), 0 24px 60px -16px rgba(17, 21, 23, 0.22);
  --btn-hi: inset 0 1px 0 rgba(255, 255, 255, 0.14);

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-lg: 14px;
  --r: 10px;
  --r-sm: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f10; --surface: #151819; --surface-2: #191c1e; --surface-3: #1f2325;
    --line: #262b2d; --line-2: #343a3d;
    --ink: #eceeee; --ink-2: #c7cccd; --muted: #8e9799; --faint: #646d6f;
    --accent: #3fb0a8; --accent-hover: #57c2ba; --accent-ink: #061413; --accent-soft: #10302d;
    --focus: rgba(63, 176, 168, 0.35);
    --danger: #f07167; --danger-soft: #3a1714;
    --st-draft: #8e9799; --st-draft-bg: #22272a;
    --st-sub: #7da3f2;   --st-sub-bg: #172338;
    --st-pend: #e3a548;  --st-pend-bg: #33240f;
    --st-reim: #5cc48a;  --st-reim-bg: #12291c;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 30px 70px -20px rgba(0, 0, 0, 0.8);
    --btn-hi: inset 0 1px 0 rgba(255, 255, 255, 0.18);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f10; --surface: #151819; --surface-2: #191c1e; --surface-3: #1f2325;
  --line: #262b2d; --line-2: #343a3d;
  --ink: #eceeee; --ink-2: #c7cccd; --muted: #8e9799; --faint: #646d6f;
  --accent: #3fb0a8; --accent-hover: #57c2ba; --accent-ink: #061413; --accent-soft: #10302d;
  --focus: rgba(63, 176, 168, 0.35);
  --danger: #f07167; --danger-soft: #3a1714;
  --st-draft: #8e9799; --st-draft-bg: #22272a;
  --st-sub: #7da3f2;   --st-sub-bg: #172338;
  --st-pend: #e3a548;  --st-pend-bg: #33240f;
  --st-reim: #5cc48a;  --st-reim-bg: #12291c;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 30px 70px -20px rgba(0, 0, 0, 0.8);
  --btn-hi: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  overflow-x: hidden;
  font-feature-settings: "ss01";
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.aurora { display: none; }

/* ---------- buttons ---------- */
.btn {
  --b-bg: var(--surface); --b-fg: var(--ink); --b-bd: var(--line-2); --b-hv: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--r);
  border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg);
  font-weight: 550; font-size: 13.5px; letter-spacing: -0.005em; line-height: 1;
  cursor: pointer; white-space: nowrap; user-select: none;
  box-shadow: var(--shadow-xs);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .08s ease;
}
.btn:hover:not(:disabled) { background: var(--b-hv); }
.btn:active:not(:disabled) { transform: translateY(0.5px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .ic { width: 15px; height: 15px; }
.btn-primary {
  --b-bg: var(--accent); --b-fg: var(--accent-ink); --b-bd: transparent; --b-hv: var(--accent-hover);
  box-shadow: var(--btn-hi), 0 1px 2px rgba(10, 60, 58, 0.25);
}
.btn-secondary { /* default look */ }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; --b-hv: var(--surface-3); box-shadow: none; color: var(--ink-2); }
.btn-danger { --b-bg: var(--danger); --b-fg: #fff; --b-bd: transparent; --b-hv: var(--danger); box-shadow: var(--btn-hi); }
.btn-danger:hover:not(:disabled) { filter: brightness(1.06); }
.btn-lg { height: 44px; font-size: 14.5px; border-radius: 11px; width: 100%; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: var(--r-sm); }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r); display: inline-grid; place-items: center;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); cursor: pointer;
  box-shadow: var(--shadow-xs); transition: background-color .15s, color .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: var(--r-sm); }
.icon-btn.flat { border-color: transparent; box-shadow: none; background: transparent; }
.icon-btn.flat:hover { background: var(--surface-3); }
.icon-btn.spin .ic { animation: spin .9s linear infinite; }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; color: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; font-weight: 600; padding: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 32px 28px 24px; box-shadow: var(--shadow-lg); display: grid; gap: 12px;
}
.auth-card h1 { margin: 10px 0 0; font-size: 24px; font-weight: 650; letter-spacing: -0.025em; }
.auth-sub { margin: 0 0 8px; color: var(--muted); }
.auth-sub br { display: none; }
.ms { width: 16px; height: 16px; }
.logo, .logo-lg {
  display: grid; place-items: center; background: var(--ink); color: var(--bg);
  font-family: var(--mono); font-weight: 600; letter-spacing: -0.04em;
}
.logo { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
.logo-lg { width: 44px; height: 44px; border-radius: 12px; font-size: 15px; }
.notice { font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 13px; color: var(--ink-2); }
.notice-error { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.notice code { font-family: var(--mono); font-size: 12px; }

/* ---------- layout ---------- */
.app {
  max-width: 1120px; margin: 0 auto;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: 110px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 26px; }
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-name { font-weight: 650; font-size: 15.5px; letter-spacing: -0.02em; line-height: 1.2; }
.brand-sub { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.brand-sub .ic { display: none; }
.brand-sub::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: none; }
.brand-sub.ok::before { background: var(--st-reim); }
.brand-sub.busy::before { background: var(--st-pend); animation: pulse 1.1s ease-in-out infinite; }
.brand-sub.err { color: var(--danger); }
.brand-sub.err::before { background: var(--danger); }
@keyframes pulse { 50% { opacity: .25; } }
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-actions .icon-btn { border-color: transparent; box-shadow: none; background: transparent; color: var(--muted); }
.top-actions .icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.user-chip {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 4px; margin-left: 4px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.user-chip:hover { background: var(--surface-2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 650; }
.user-name { font-weight: 550; font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-banner {
  margin: -10px 0 20px; padding: 9px 13px; border-radius: var(--r); background: var(--surface);
  border: 1px dashed var(--line-2); color: var(--muted); font-size: 13px;
}
.demo-banner .link { color: var(--ink); }

/* ---------- page heading ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- tiles ---------- */
.tiles {
  display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 28px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.tile { padding: 18px 20px 18px; display: flex; flex-direction: column; gap: 10px; min-width: 0; position: relative; }
.tile + .tile { border-left: 1px solid var(--line); }
.tile-top { display: flex; align-items: center; gap: 8px; }
.tile-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.tile-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.tile-value { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.tile-foot { font-size: 12.5px; color: var(--muted); }
.tile-foot b { font-weight: 600; color: var(--ink-2); }
.tile-foot .warn { color: var(--st-pend); font-weight: 600; }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; flex: 1; justify-content: flex-end; min-width: 0; }
.seg {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--surface-3);
  overflow-x: auto; max-width: 100%; scrollbar-width: none;
}
.seg button {
  border: 0; background: transparent; height: 30px; padding: 0 12px; border-radius: 8px; cursor: pointer;
  font-weight: 550; font-size: 13px; color: var(--muted); display: inline-flex; gap: 7px; align-items: center; white-space: nowrap;
  transition: color .15s, background-color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button b { font-weight: 550; font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--line); }
.seg button.on b { color: var(--muted); }
.search {
  display: flex; align-items: center; gap: 8px; padding: 0 11px; height: 36px; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--faint); flex: 0 1 260px; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.search input { border: 0; outline: 0; background: transparent; width: 100%; min-width: 0; color: var(--ink); font-size: 13.5px; }
.search input::placeholder { color: var(--faint); }

.toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.daterange {
  display: inline-flex; align-items: center; gap: 0; height: 36px; padding: 0 2px 0 0; border-radius: var(--r);
  border: 1px solid var(--line-2); background: var(--surface); box-shadow: var(--shadow-xs); min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.daterange:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.daterange.on { border-color: var(--accent); }
.dr-field { display: inline-flex; align-items: center; gap: 6px; height: 100%; padding: 0 4px 0 11px; cursor: text; min-width: 0; }
.dr-field + .dr-field { border-left: 1px solid var(--line); }
.dr-field span { font-size: 12px; color: var(--muted); font-weight: 500; }
.dr-field input {
  border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; height: 100%;
  width: 124px; min-width: 0; padding: 0; font-variant-numeric: tabular-nums;
}
.dr-field input::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; margin-left: 2px; }
.daterange .icon-btn { width: 28px; height: 28px; margin-left: 2px; }
.range-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: -2px 0 12px; padding: 0 2px;
  font-size: 12.5px; color: var(--muted);
}
.range-note span { display: inline-flex; align-items: center; gap: 6px; }
.range-note .ic { width: 14px; height: 14px; color: var(--accent); }
.range-note b { color: var(--ink); font-weight: 600; }
.reauth {
  position: fixed; z-index: 90; left: 50%; transform: translateX(-50%);
  top: max(14px, calc(env(safe-area-inset-top, 0px) + 10px));
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 14px; width: max-content; max-width: calc(100% - 32px);
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; animation: pop .18s ease;
}

/* ---------- list ---------- */
.list {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.list:has(> .empty) { background: transparent; border: 0; box-shadow: none; }
.list-head, .row {
  display: grid; grid-template-columns: minmax(170px, 1.3fr) 120px minmax(120px, 1.2fr) 120px 290px; gap: 16px; align-items: center;
}
.list-head {
  padding: 10px 18px; font-size: 12px; font-weight: 500; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.list-head span:nth-child(4) { text-align: right; }
.row { padding: 13px 14px 13px 18px; border-bottom: 1px solid var(--line); transition: background-color .12s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row.busy { opacity: .55; pointer-events: none; }
.row .no { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; font-family: var(--mono); font-size: 13.5px; }
.row .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.row .sub span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { font-weight: 600; font-size: 14.5px; text-align: right; letter-spacing: -0.01em; }
.row .actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 21px; padding: 0 8px 0 7px; border-radius: 6px;
  font-size: 11.5px; font-weight: 550; white-space: nowrap; flex: none;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.draft { color: var(--ink-2); background: var(--st-draft-bg); }
.chip.draft::before { background: var(--st-draft); }
.chip.submitted { color: var(--st-sub); background: var(--st-sub-bg); }
.chip.pending { color: var(--st-pend); background: var(--st-pend-bg); }
.chip.reimbursed { color: var(--st-reim); background: var(--st-reim-bg); }

.empty { text-align: center; padding: 56px 20px; border: 1px dashed var(--line-2); border-radius: var(--r-lg); color: var(--muted); background: var(--surface); }
.empty h3 { color: var(--ink); margin: 14px 0 4px; font-size: 15px; font-weight: 600; }
.empty p { margin: 0 0 18px; }
.empty .big { width: 40px; height: 40px; margin: 0 auto; border-radius: 11px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.empty .big .ic { width: 20px; height: 20px; }

/* ---------- menu ---------- */
.menu {
  position: fixed; z-index: 60; min-width: 230px; padding: 5px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  animation: pop .12s ease;
}
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border: 0; background: transparent; border-radius: 7px; cursor: pointer; text-align: left; font-weight: 500; font-size: 13.5px; color: var(--ink-2); }
.menu button .ic { color: var(--muted); }
.menu button:hover { background: var(--surface-3); color: var(--ink); }
.menu button.danger, .menu button.danger .ic { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.menu .menu-info { padding: 8px 10px 7px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.menu .menu-info b { color: var(--ink); font-weight: 600; font-size: 13px; }
@keyframes pop { from { opacity: 0; transform: scale(.98) translateY(-3px); } }

/* ---------- dialogs ---------- */
dialog { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: none; max-height: none; }
dialog::backdrop { background: rgba(8, 12, 13, .42); backdrop-filter: blur(2px); }
.modal[open] { display: grid; place-items: center; width: 100%; height: 100%; }
.modal-inner { width: min(400px, calc(100% - 32px)); background: var(--surface); border-radius: 16px; padding: 22px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); animation: pop .14s ease; }
.modal-inner h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.modal-inner p { margin: 0 0 20px; color: var(--muted); white-space: pre-line; font-size: 13.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.sheet[open] { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 24px; }
.sheet-inner {
  width: min(1020px, 100%); max-height: calc(100dvh - 48px); display: flex; flex-direction: column;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  overflow: hidden; animation: sheetIn .2s cubic-bezier(.2,.8,.3,1);
}
@keyframes sheetIn { from { opacity: 0; transform: translateY(10px); } }
.ed-head { padding: 18px 22px; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); }
.ed-title { display: grid; gap: 4px; min-width: 0; }
.ed-title h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; font-family: var(--mono); }
.ed-title .sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ed-total { text-align: right; }
.ed-total .lbl { font-size: 12px; color: var(--muted); }
.ed-total .val { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.2; }
.ed-body { padding: 20px 22px; overflow: auto; display: grid; gap: 20px; background: var(--surface); }
.ed-foot { padding: 12px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; background: var(--surface-2); }
.ed-foot .grp { display: flex; gap: 8px; flex-wrap: wrap; }
.save-state { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.save-state .ic { width: 14px; height: 14px; }
.save-state.ok .ic { color: var(--st-reim); }

/* entry form */
.entry { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 16px 14px; background: var(--surface-2); }
.entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; min-height: 28px; }
.entry-head h4 { margin: 0; font-size: 13.5px; font-weight: 600; display: flex; gap: 9px; align-items: center; }
.sr-badge {
  display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 6px; border-radius: 6px;
  background: var(--surface-3); color: var(--ink-2); font-size: 12px; font-weight: 600; font-family: var(--mono);
}
.entry .sr-badge { background: var(--ink); color: var(--surface); }
.grid-form { display: grid; grid-template-columns: 1.3fr .9fr 1.2fr .8fr; gap: 12px 12px; }
.grid-form .wide { grid-column: span 2; }
.grid-form .full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field label .opt { color: var(--faint); font-weight: 400; }
.field input, .field textarea {
  width: 100%; height: 38px; border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r-sm); padding: 0 11px;
  outline: none; transition: border-color .15s, box-shadow .15s; min-width: 0; font-size: 14px; box-shadow: var(--shadow-xs);
}
.field textarea { height: auto; min-height: 38px; padding: 8px 11px; resize: vertical; line-height: 1.4; }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field input:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.field input.bad { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.amount-wrap { position: relative; }
.amount-wrap span { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.amount-wrap input { padding-left: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.drop {
  display: flex; align-items: center; gap: 10px; padding: 0 6px 0 11px; height: 38px; border: 1px dashed var(--line-2); border-radius: var(--r-sm);
  background: var(--surface); cursor: pointer; transition: border-color .15s, background-color .15s; min-width: 0;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .ic { color: var(--muted); }
.drop .t { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop .s { color: var(--faint); font-size: 12px; white-space: nowrap; margin-left: auto; padding-right: 6px; }
.drop > div { min-width: 0; display: flex; align-items: baseline; gap: 8px; flex: 1; }
.drop input { display: none; }
.drop .clear { margin-left: 0; height: 28px; }
.entry-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.progress { height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 12px; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* rows table */
.items { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.items table { width: 100%; border-collapse: collapse; }
.items th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.items td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: top; font-size: 13.5px; }
.items tbody:first-of-type tr:first-child td { border-top: 0; }
.items tbody tr + tr td { border-top-color: transparent; }
.items tbody tr + tr td:not(.c-ves) { border-top: 1px dashed var(--line); }
.items td.c-ves { border-right: 1px solid var(--line); }
.items td.c-ves { font-weight: 550; }
.items td.c-date { color: var(--ink-2); white-space: nowrap; }
.items tr.m-head { display: none; }
.items tr.editing td:not(.c-ves) { background: var(--accent-soft); }
.items .r { text-align: right; }
.items .c { text-align: center; }
.items .desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; font-weight: 400; }
.items .acts { display: flex; gap: 2px; justify-content: flex-end; margin: -5px -6px -5px 0; }
.items .acts .icon-btn { color: var(--muted); }
.items .acts .icon-btn:hover { color: var(--ink); }
.items tfoot td { font-weight: 600; background: var(--surface-2); font-size: 14px; border-top: 1px solid var(--line); }
.items td.c-amt { font-weight: 550; white-space: nowrap; }
.pdf-link {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink-2); font-size: 12.5px; cursor: pointer; max-width: 190px;
  margin: -3px 0;
}
.pdf-link:hover { border-color: var(--accent); color: var(--accent); }
.pdf-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pdf-link .ic { width: 14px; height: 14px; color: var(--danger); }
.muted { color: var(--faint); }
.no-items { padding: 36px; text-align: center; color: var(--muted); }
.locked { display: flex; gap: 10px; align-items: center; padding: 11px 13px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-size: 13.5px; }
.locked .ic { color: var(--st-sub); }
.locked.pending .ic { color: var(--st-pend); }
.locked.reimbursed .ic { color: var(--st-reim); }
.timeline { display: flex; gap: 0; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.timeline span + span::before { content: "→"; margin: 0 8px; color: var(--faint); }
.timeline b { color: var(--ink-2); font-weight: 550; }

/* ---------- toasts / fab ---------- */
.toasts { position: fixed; z-index: 80; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; width: min(400px, calc(100% - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; padding: 11px 14px; border-radius: 11px; background: var(--ink); color: var(--surface);
  font-weight: 500; font-size: 13.5px; box-shadow: var(--shadow-lg); animation: pop .18s ease; display: flex; gap: 10px; align-items: center;
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok .ic { color: var(--st-reim); }
.fab {
  display: none; position: fixed; right: max(18px, calc(env(safe-area-inset-right) + 12px)); bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); z-index: 40;
  height: 50px; padding: 0 20px 0 16px; border-radius: 14px; border: 0; color: var(--accent-ink); background: var(--accent);
  box-shadow: var(--btn-hi), 0 10px 24px -8px rgba(10, 60, 58, .55); cursor: pointer; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14.5px;
}
.fab .ic { width: 18px; height: 18px; stroke-width: 2.2; }

/* ---------- responsive ---------- */
@media (min-width: 761px) and (max-width: 1100px) {
  .toolbar-right { flex-basis: 100%; }
  .search { flex: 1 1 auto; }
}
@media (min-width: 761px) and (max-width: 1060px) {
  .list-head, .row { grid-template-columns: minmax(150px, 1fr) 110px 110px 270px; }
  .row .c-items, .list-head span:nth-child(3) { display: none; }
}
@media (max-width: 980px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile:nth-child(3) { border-left: 0; }
  .tile:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .grid-form .wide { grid-column: 1 / -1; }
}
@media (min-width: 761px) { .c-meta { display: none !important; } }
@media (max-width: 760px) {
  .app { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .topbar { padding-bottom: 18px; }
  .hide-sm { display: none !important; }
  .fab { display: inline-flex; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: stretch; }
  .search { flex: 1; }
  .seg { width: 100%; }
  .seg button { flex: 1; justify-content: center; padding: 0 6px; }
  .toolbar-left { flex-direction: column; align-items: stretch; width: 100%; min-width: 0; }
  .daterange { display: flex; width: 100%; min-width: 0; height: 40px; }
  .dr-field { flex: 1 1 0; min-width: 0; padding-left: 10px; gap: 6px; }
  .dr-field input { flex: 1 1 0; width: 0; min-width: 0; font-size: 14px; }
  .dr-field input::-webkit-calendar-picker-indicator { margin-left: 0; }
  .list-head { display: none; }
  .row { grid-template-columns: 1fr auto; gap: 6px 12px; padding: 14px; }
  .row:hover { background: transparent; }
  .row .c-no { grid-column: 1; }
  .row .c-amt { grid-column: 2; grid-row: 1; align-self: start; }
  .row .c-date, .row .c-items { display: none; }
  .row .c-meta { display: flex !important; grid-column: 1 / -1; gap: 6px; color: var(--muted); font-size: 12.5px; align-items: center; }
  .row .c-meta span { white-space: nowrap; }
  .row .c-meta .t { min-width: 0; flex: 1; }
  .row .actions { grid-column: 1 / -1; justify-content: stretch; margin-top: 6px; }
  .row .actions .btn { flex: 1; }
  .user-name { display: none; }
  .user-chip { padding: 0 4px; }
  .tile { padding: 14px 14px; gap: 6px; }
  .tile-value { font-size: 20px; }
  .tile-foot { font-size: 12px; }
  .sheet[open] { padding: 0; align-items: flex-end; }
  .sheet-inner { max-height: 94dvh; border-radius: 18px 18px 0 0; width: 100%; border-bottom: 0; }
  .ed-head, .ed-body, .ed-foot { padding-left: 16px; padding-right: 16px; }
  .ed-head { padding-top: 16px; padding-bottom: 14px; align-items: flex-start; }
  .ed-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .ed-foot, .ed-foot .grp { width: 100%; }
  .ed-foot .grp .btn { flex: 1; }
  .ed-title h2 { font-size: 16px; }
  .ed-total .val { font-size: 18px; }
  .drop .s { display: none; }
  /* items: one card per site/date group */
  .items { border: 0; border-radius: 0; overflow: visible; display: grid; gap: 10px; }
  .items table { display: grid; gap: 10px; }
  .items thead { display: none; }
  .items tbody, .items tfoot { display: block; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
  .items tr { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 11px 12px; }
  .items tbody tr + tr { border-top: 1px dashed var(--line); }
  .items tbody tr.m-head + tr { border-top: 0; }
  .items td, .items tbody tr + tr td:not(.c-ves) { padding: 0; border: 0; display: block; background: transparent !important; }
  .items td.c-ves { display: none; }
  .items tr.m-head { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 12.5px; }
  .items tr.m-head td { display: block; }
  .items tr.m-head .mv { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .items tr.m-head .md { color: var(--muted); white-space: nowrap; }
  .items td.c-sr { grid-column: 1; grid-row: 1 / span 2; }
  .items td.c-act:empty { display: none; }
  .items td.c-item { grid-column: 2; grid-row: 1; font-weight: 500; }
  .items td.c-amt { grid-column: 3; grid-row: 1; text-align: right; }
  .items td.c-date { grid-column: 2; grid-row: 2; font-size: 12.5px; color: var(--muted); align-self: center; }
  .items td.c-pdf { grid-column: 2; grid-row: 3; margin-top: 6px; }
  .items td.c-act { grid-column: 3; grid-row: 2 / span 2; align-self: end; }
  .items td.c-pdf:has(.muted) { display: none !important; }
  .items .acts { margin: 0 -6px 0 0; }
  .items tr.editing { background: var(--accent-soft); }
  .items tfoot tr { display: flex; justify-content: space-between; background: var(--surface-2); }
  .items tfoot td { background: transparent; border: 0; padding: 0; }
  .items tfoot td.sp { display: none; }
}
@media (max-width: 440px) { .seg button b { display: none; } }
@media (max-width: 380px) {
  .tile-value { font-size: 18px; }
  .seg button { font-size: 12.5px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
