/* Admin. Dense and calm: tables first, one accent, color only where status matters. */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; }
.side .brand { padding: 0 8px; }
.side nav { display: grid; gap: 2px; }
.side nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 500; font-size: 15px; }
.side nav a:hover { background: var(--surface-2); color: var(--ink); }
.side nav a[aria-current='page'] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.side-foot { margin-top: auto; display: grid; gap: 8px; font-size: 14px; }
.side-foot a { color: var(--muted); }
.badge { font: 600 12px/1.5 var(--font-mono); background: var(--signal); color: #fff; border-radius: 999px; padding: 0 8px; }
main { padding: 28px clamp(16px, 3vw, 40px) 64px; min-width: 0; }

.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { font-size: 1.9rem; }
.page-head .sub { color: var(--muted); font-size: 14.5px; margin-top: 4px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input[type='search'], .toolbar select { width: auto; min-width: 190px; }
.toolbar .grow { flex: 1 1 200px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 24px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.tile .k { font: 500 12px/1.3 var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.tile .v { font: 700 1.75rem/1.1 var(--font-display); margin-top: 8px; font-variant-numeric: tabular-nums; }
.tile .s { font-size: 13px; color: var(--muted); margin-top: 4px; }
.tile.warn .v { color: var(--signal); }
.tile.bad .v { color: var(--danger); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.panel > h2 { font-size: 1.05rem; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.panel .body { padding: 16px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.list li:last-child { border-bottom: 0; }
.list li:hover { background: var(--surface-2); }
.list .main { min-width: 0; }
.list .main b { display: block; font-weight: 600; }
.list .main span { color: var(--muted); font-size: 13.5px; }
.empty { padding: 22px 16px; color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th { text-align: left; font: 600 12px/1.3 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr[data-row] { cursor: pointer; }
tbody tr[data-row]:hover { background: var(--surface-2); }
tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line); }
td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.muted, .muted { color: var(--muted); }
td.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.dim td { opacity: 0.55; }

.chip { display: inline-block; font: 600 12px/1 var(--font-mono); padding: 5px 9px; border-radius: 999px; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--signal-soft); color: var(--signal); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

/* Dialogs */
dialog { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--surface); color: var(--ink); width: min(780px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35); }
dialog::backdrop { background: rgba(8, 16, 15, 0.55); }
.dlg-body { padding: 22px; display: grid; gap: 16px; max-height: calc(100vh - 26px); overflow: auto; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dlg-head h2 { font-size: 1.35rem; }
.icon-btn { appearance: none; width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 8px; cursor: pointer; font-size: 20px; line-height: 1; flex: none; }
.icon-btn:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.grid2, .grid3, .grid4 { display: grid; gap: 14px; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; padding-top: 4px; }
.actions .spacer { margin-right: auto; }
.hint { font-size: 13.5px; color: var(--muted); font-weight: 400; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.section-title { font: 600 12px/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.inline-box { display: grid; gap: 12px; padding: 14px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--surface-2); }
.inline-box[hidden] { display: none; }

/* Line items */
.items { display: grid; gap: 8px; }
.items-head, .item { display: grid; grid-template-columns: minmax(0, 3fr) 100px 96px 88px 96px 36px; gap: 8px; align-items: center; }
.items-head { font: 600 11px/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.item input, .item select { min-height: 40px; padding: 8px 10px; font-size: 15px; }
.item output { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.empty-note { color: var(--muted); padding: 10px 0; }
.totals { display: grid; gap: 6px; justify-self: end; min-width: min(320px, 100%); font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; gap: 18px; }
.totals .grand { font: 700 1.25rem var(--font-display); padding-top: 8px; border-top: 1px solid var(--line); }
.travel-row { display: grid; grid-template-columns: 150px auto minmax(0, 1fr); gap: 10px; align-items: end; }
.travel-row .hint { padding-bottom: 12px; }

/* Receipts */
.receipts { display: grid; gap: 8px; }
.receipt { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.receipt a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Financial */
.fin { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.rows { display: grid; }
.rows > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 16px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.rows > div:last-child { border-bottom: 0; }
.rows .sub { padding-left: 32px; color: var(--muted); font-size: 14px; }
.rows .strong { font-weight: 700; background: var(--surface-2); }
.rows .neg b { color: var(--danger); }
.rows b { font-family: var(--font-mono); font-weight: 500; white-space: nowrap; }
.rows .strong b { font-weight: 600; }
.note { font-size: 13.5px; color: var(--muted); padding: 12px 16px; }
details.panel summary { cursor: pointer; padding: 14px 16px; font: 600 1.05rem var(--font-display); }
.bracket-row { display: grid; grid-template-columns: 1fr 120px; gap: 10px; margin-bottom: 8px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 32px 32px; }
.login form { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: grid; gap: 16px; box-shadow: var(--shadow); }
.login h1 { font-size: 1.6rem; }
.login .err { color: var(--danger); font-weight: 600; min-height: 1.4em; font-size: 14.5px; }

#toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 10px; font-weight: 600; font-size: 14.5px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 1000; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: #fff; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .side .brand-name { display: none; }
  .side nav { display: flex; gap: 4px; }
  .side nav a { white-space: nowrap; padding: 8px 12px; }
  .side-foot { display: none; }
  .fin { grid-template-columns: minmax(0, 1fr); }
  .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid2, .grid3, .grid4 { grid-template-columns: minmax(0, 1fr); }
  .items-head { display: none; }
  .item { grid-template-columns: minmax(0, 1fr) 1fr 1fr 36px; }
  .item > :nth-child(1) { grid-column: 1 / -1; }
  .item > :nth-child(2) { grid-column: 1 / 2; }
  .item output { grid-column: 3 / 4; }
  .travel-row { grid-template-columns: minmax(0, 1fr); }
  .dlg-body { padding: 16px; }
}
