/* SarlBox: professional, restrained UI. Plain modern CSS: no framework, no build step, no JavaScript. */

@view-transition { navigation: auto; }

:root {
  color-scheme: light dark;
  --bg: #f6f7f9;  --panel: #ffffff;  --ink: #111827;  --ink-2: #374151;  --muted: #6b7280;  --faint: #9ca3af;
  --line: #e5e7eb;  --line-2: #f0f1f3;  --hover: #f3f4f6;
  --accent: #1f3a5f;  --brand: #d52b1e;
  --red: #b42318;  --red-bg: #fef3f2;  --amber: #b54708;  --amber-bg: #fffaeb;
  --green: #067647; --green-bg: #ecfdf3;  --blue-bg: #eff4fb;
  --radius: 10px;  --sidebar: 248px;
  font: 14px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --panel: #151a21; --ink: #e6e8eb; --ink-2: #c4c8ce; --muted: #8b929c; --faint: #6b727c;
    --line: #262c35; --line-2: #1c222a; --hover: #1b2129; --accent: #8fb3e0;
    --red: #f2a19a; --red-bg: #2a1614; --amber: #f5c27a; --amber-bg: #2a2010; --green: #7fd4a8; --green-bg: #102419; --blue-bg: #142030;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; &:hover { text-decoration: underline; } }
code, .mono { font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--red); }
.pos { color: var(--green); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ---------- App shell: sidebar + main ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: auto;
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 22px;
  view-transition-name: sidebar;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--ink); font-weight: 700; font-size: 15px;
  &:hover { text-decoration: none; }
  & .mark { width: 22px; height: 22px; border-radius: 5px; background: var(--brand); position: relative; flex: none;
    &::before, &::after { content: ""; position: absolute; background: #fff; border-radius: 1px; }
    &::before { width: 12px; height: 4px; left: 5px; top: 9px; }
    &::after  { width: 4px; height: 12px; left: 9px; top: 5px; } } }
.entity { padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
  & strong { display: block; font-size: 13px; } & span { color: var(--muted); font-size: 12px; } }
.nav { display: grid; gap: 2px;
  & .label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 8px 10px 4px; }
  & a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--ink-2); font-weight: 500;
    &:hover { background: var(--hover); text-decoration: none; }
    &[aria-current="page"] { background: var(--blue-bg); color: var(--accent); font-weight: 600; }
    & .count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--line-2); border-radius: 999px; padding: 0 7px; } } }
.sidebar footer { margin-top: auto; padding: 0 10px; color: var(--faint); font-size: 11.5px; line-height: 1.6; }

main { min-width: 0; padding: 28px 36px 64px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px;
  & h1 { font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -.015em; margin: 0; }
  & p { margin: 4px 0 0; color: var(--muted); }
  & .asof { color: var(--muted); font-size: 12.5px; white-space: nowrap; } }
.crumbs { font-size: 12.5px; margin-bottom: 6px; }

@media (width < 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 16px; gap: 12px;
    & .entity, & footer, & .nav .label { display: none; }
    & .nav { display: flex; flex-wrap: wrap; } }
  main { padding: 20px 16px 48px; }
}

/* ---------- Panels, sections ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel + .panel, .panel + section, section + section { margin-top: 20px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line);
  & h2 { font-size: 14px; font-weight: 650; margin: 0; }
  & span { color: var(--muted); font-size: 12.5px; } }
.panel-body { padding: 16px 18px; }
.panel-foot { padding: 10px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }

/* ---------- Key figures ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.kpi { background: var(--panel); padding: 14px 18px;
  & .k { font-size: 12px; color: var(--muted); font-weight: 500; }
  & .v { font-size: 20px; font-weight: 650; letter-spacing: -.01em; margin-top: 4px; font-variant-numeric: tabular-nums; }
  & .s { font-size: 12px; color: var(--muted); margin-top: 2px; } }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 18px; text-align: left; vertical-align: top; border-top: 1px solid var(--line-2); }
thead th { border-top: 0; border-bottom: 1px solid var(--line); background: var(--bg); color: var(--muted);
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding-top: 8px; padding-bottom: 8px; }
tbody tr:hover { background: var(--hover); }
td .sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
td .warn { display: block; color: var(--red); font-size: 12.5px; margin-top: 2px; }
td:first-child, th:first-child { white-space: nowrap; }
tfoot td, tr.total td, tr.total th { border-top: 1px solid var(--line); font-weight: 650; }

/* ---------- Status, urgency ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 1px 8px;
  border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); background: var(--panel); white-space: nowrap;
  &.open    { }
  &.pending { color: var(--amber); background: var(--amber-bg); border-color: transparent; }
  &.done    { color: var(--green); background: var(--green-bg); border-color: transparent; }
  &.draft   { color: var(--amber); background: var(--amber-bg); border-color: transparent; font-weight: 600; } }
.due { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  &::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
  &.late::before  { background: var(--red); }
  &.soon::before  { background: var(--amber); }
  &.month::before { background: #ca8a04; }
  &.later::before { background: var(--faint); }
  & small { color: var(--muted); font-size: 12px; } }
.tag { font-size: 11.5px; color: var(--muted); background: var(--line-2); border-radius: 5px; padding: 1px 6px; white-space: nowrap;
  &.likely_private, &.private_reimbursed, &.unclear { color: var(--amber); background: var(--amber-bg); }
  &.owner { color: var(--accent); background: var(--blue-bg); } }

details.pay { margin-top: 6px; font-size: 12.5px;
  & summary { cursor: pointer; color: var(--accent); width: fit-content; }
  & dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 6px 0 0; & dt { color: var(--muted); } & dd { margin: 0; } } }

/* ---------- Ledger tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  & .k { font-size: 12px; color: var(--muted); font-weight: 500; }
  & .v { font-size: 19px; font-weight: 650; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
  & p { margin: 0; color: var(--muted); font-size: 12.5px; }
  & .meta { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--muted); }
  & .flag { color: var(--amber); font-weight: 600; } }

/* ---------- Cases ---------- */
.case-list a { display: grid; grid-template-columns: 1fr auto auto; gap: 18px; align-items: center; padding: 13px 18px;
  border-top: 1px solid var(--line-2); color: var(--ink);
  &:first-child { border-top: 0; }
  &:hover { background: var(--hover); text-decoration: none; }
  & strong { font-weight: 600; } & .muted { font-size: 12.5px; } }

.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; align-items: start;
  @media (width < 1050px) { grid-template-columns: 1fr; } }

.timeline { list-style: none; margin: 0; padding: 6px 18px 6px 18px; }
.timeline li { display: grid; grid-template-columns: 92px 18px 1fr; gap: 10px; position: relative; padding: 10px 0;
  & time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; padding-top: 1px; }
  & .dot { position: relative; display: flex; justify-content: center;
    &::before { content: ""; position: absolute; top: 0; bottom: -20px; width: 1px; background: var(--line); }
    &::after { content: ""; position: relative; margin-top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--panel); border: 2px solid var(--faint); } }
  &:last-child .dot::before { display: none; }
  & .t { font-weight: 550; } & .d { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
  &.letter   .dot::after { border-color: var(--accent); }
  &.payment  .dot::after { border-color: var(--green); background: var(--green); }
  &.deadline .dot::after { border-color: var(--red); background: var(--red); }
  &.future time { color: var(--red); font-weight: 600; } }

.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 16px 18px;
  & figure { margin: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
  & img { display: block; width: 100%; aspect-ratio: 210 / 297; object-fit: cover; }
  & figcaption { padding: 8px 10px; font-size: 12px; & strong { display: block; font-size: 12.5px; } } }

.obl { padding: 14px 18px; border-top: 1px solid var(--line-2);
  &:first-child { border-top: 0; }
  & .row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
  & .t { font-weight: 600; } & .a { font-weight: 650; font-variant-numeric: tabular-nums; }
  & p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; } }

/* ---------- Statements (balance, income) ---------- */
.statement { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.statement > div + div { border-left: 1px solid var(--line); }
@media (width < 800px) { .statement { grid-template-columns: 1fr; } .statement > div + div { border-left: 0; border-top: 1px solid var(--line); } }
.statement table td, .statement table th { padding-top: 8px; padding-bottom: 8px; }
.statement .group td { color: var(--muted); font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; border-top: 0; padding-top: 14px; }

.notes { margin: 0; padding: 0 0 0 18px; color: var(--ink-2); & li { margin: 4px 0; } }

/* ---------- Definition lists ---------- */
dl.facts { display: grid; grid-template-columns: 180px 1fr; margin: 0;
  & dt, & dd { padding: 10px 18px; border-top: 1px solid var(--line-2); margin: 0; }
  & dt:first-of-type, & dd:first-of-type { border-top: 0; }
  & dt { color: var(--muted); } }

.empty { padding: 18px; color: var(--muted); }

.subhead { margin: 0 0 12px; & h2 { font-size: 15px; font-weight: 650; margin: 0; } & p { margin: 2px 0 0; color: var(--muted); } }
.docnote { margin: 4px 0; }

/* ---------- Buttons, forms, messages ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 550; font-size: 13px;
  padding: 6px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer;
  text-decoration: none; white-space: nowrap;
  &:hover { background: var(--hover); text-decoration: none; }
  &.primary { background: var(--accent); border-color: var(--accent); color: #fff; &:hover { filter: brightness(1.1); } }
  &.ghost { background: transparent; border-color: transparent; color: var(--muted); &:hover { color: var(--ink); background: var(--hover); } }
  &.small { font-size: 12px; padding: 3px 9px; }
  &.block { display: flex; width: 100%; } }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0e1116; } }
form.actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
td form { margin: 0; }
.head-actions { display: flex; align-items: center; gap: 10px; }

.inline-form { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--bg);
  border-radius: 0 0 var(--radius) var(--radius);
  & input[name="title"] { flex: 1; } }
input, select, textarea { font: inherit; font-size: 13.5px; color: var(--ink); background: var(--panel); border: 1px solid var(--line);
  border-radius: 7px; padding: 7px 10px; min-width: 0;
  &:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 0; border-color: var(--accent); } }
textarea { resize: vertical; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px;
  & label { display: grid; gap: 5px; font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
  & label.wide { grid-column: 1 / -1; }
  & label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; & input { width: auto; } }
  & small { font-weight: 400; color: var(--muted); font-size: 12px; } }
@media (width < 700px) { .grid-form { grid-template-columns: 1fr; } }
.form .panel + .panel { margin-top: 20px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.demo-banner { margin: 0 0 18px; padding: 10px 14px; border-radius: var(--radius); background: var(--amber-bg); color: var(--amber); }
.flash { margin: 0 0 18px; padding: 10px 14px; border-radius: var(--radius); background: var(--green-bg); color: var(--green); font-weight: 550;
  view-transition-name: flash;
  &.error { background: var(--red-bg); color: var(--red); } }
tr.is-done td { color: var(--muted); }
tr.is-done td:nth-child(2) { text-decoration: line-through; }
.file-ph { display: grid; place-items: center; aspect-ratio: 210 / 297; color: var(--muted); font-weight: 650; letter-spacing: .05em; }

/* ---------- Upload, inbox, review ---------- */
.upload { margin-bottom: 20px; }
.drop { display: grid; gap: 10px; text-align: center; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  & .drop-title { font-size: 15px; font-weight: 650; }
  /* The file input itself is the drop zone: native drag-and-drop and click both work without JavaScript. */
  & input[type=file] { width: 100%; padding: 44px 16px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--bg);
    font-size: 13.5px; color: var(--muted); cursor: pointer; text-align: center; transition: border-color .15s, background .15s;
    &:hover, &:focus { border-color: var(--accent); background: var(--blue-bg); outline: none; }
    &::file-selector-button { font: inherit; font-weight: 600; margin-right: 12px; padding: 7px 14px; border-radius: 7px;
      border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; } } }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--ink-2); }
.inbox-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; padding: 16px 18px; }
.inbox-item { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; padding: 10px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
  &:hover { border-color: var(--accent); text-decoration: none; }
  & img, & .file-ph { width: 64px; height: 84px; object-fit: cover; border-radius: 4px; background: var(--panel); font-size: 11px; }
  & .meta { display: grid; gap: 3px; justify-items: start; min-width: 0; & strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; } } }
.preview { padding: 16px 18px; & img { display: block; width: 100%; border-radius: 6px; border: 1px solid var(--line); }
  & .file-ph { border: 1px solid var(--line); border-radius: 6px; } }
