/* Sablora web UI — "a tidy file manager, fused with a finance dashboard".
   Neutral chrome + a single per-account accent token. Hand-written, vendored,
   no build, no CDN. Inter is preferred when present and falls back to the system
   stack; money uses a tabular monospace. Tokens mirror the design spec 1:1. */

:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* surfaces & neutrals */
  --canvas: #f6f7f9;
  --surface: #ffffff;
  --subtle: #f1f3f5;      /* hover fill */
  --border: #e4e7eb;

  /* text ramp */
  --ink: #111827;         /* strong */
  --text: #374151;        /* body */
  --muted: #6b7280;
  --faint: #9ca3af;

  /* accent — ONE token, swappable per account. Override --accent + tints on
     .app to re-brand; chrome, text and status colours never shift. */
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-50: #fff4ec;
  --accent-100: #fde4d3;
  --accent-ring: rgba(234, 88, 12, .30);

  /* radius scale: chip · control · button · card */
  --r-chip: 4px;
  --r-control: 6px;
  --r-btn: 8px;
  --r-card: 12px;

  --shadow-card: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 3px rgba(17, 24, 39, .06);
  --shadow-pop: 0 8px 24px rgba(17, 24, 39, .12);
  --focus: 0 0 0 3px var(--accent-ring);
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

h1 { font-size: 24px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; color: var(--ink); margin: 0; }
h2 { font-size: 20px; font-weight: 600; line-height: 1.25; color: var(--ink); margin: 0 0 4px; }
h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; }

p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---- app shell: top nav bar + content -------------------------------- */
.app { display: flex; flex-direction: column; min-height: 100vh; background: var(--surface); }

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  height: 60px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; margin-right: 30px; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--ink); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px;
}
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }

.topnav { display: flex; align-items: center; }
.topnav a {
  position: relative; padding: 19px 13px;
  color: var(--muted); font-weight: 600; font-size: 15px; text-decoration: none;
}
.topnav a:hover { color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--ink); }
.topnav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 13px; right: 13px; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0;
}

.usermenu { position: relative; margin-left: auto; }
.usermenu > summary { list-style: none; cursor: pointer; }
.usermenu > summary::-webkit-details-marker { display: none; }
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.usermenu-pop {
  position: absolute; right: 0; top: 46px; z-index: 60; width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-pop); padding: 8px;
}
.usermenu-email { font-size: 12px; color: var(--muted); padding: 6px 10px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; flex: 1; }
.content { max-width: 1040px; margin: 0 auto; padding: 24px 24px 64px; }
.content-wide { max-width: none; padding: 0; }

/* ---- public shell (landing / login / signup) ------------------------- */
.public { min-height: 100vh; display: flex; flex-direction: column; }
.public-bar { display: flex; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.public-main { width: 100%; max-width: 860px; margin: 0 auto; padding: 48px 20px 80px; }
.public-main.narrow { max-width: 420px; }

/* ---- generic layout helpers ------------------------------------------ */
.stack > * + * { margin-top: 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.spacer { height: 4px; }

/* ---- cards ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 20px;
  box-shadow: var(--shadow-card);
}
.card + .card { margin-top: 16px; }

/* ---- buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  font: inherit; font-weight: 600; font-size: 14px;
  border-radius: var(--r-btn); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none; text-align: center; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { background: var(--subtle); color: var(--ink); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--subtle); color: var(--ink); }
.btn-danger { background: var(--surface); color: #b91c1c; border-color: #f0caca; }
.btn-danger:hover { background: #fdecec; }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 46px; padding: 0 22px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; box-shadow: var(--focus);
}
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row.center { justify-content: center; }

.linkbtn { background: none; border: none; color: var(--accent); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; padding: 6px 8px; border-radius: var(--r-control); }
.linkbtn:hover { background: var(--accent-50); }
.linkbtn.danger { color: #b91c1c; }
.linkbtn.danger:hover { background: #fdecec; }

.bullets { margin: 0; padding-left: 20px; color: var(--text); }
.bullets > li + li { margin-top: 8px; }

/* visually hidden, still read by screen readers */
.vh { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---- forms ------------------------------------------------------------ */
.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; font-size: 13px; color: var(--ink); margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-control);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input:focus-visible, select.input:focus-visible, textarea.input:focus-visible { border-color: var(--accent); box-shadow: var(--focus); }
textarea.input { min-height: 92px; resize: vertical; }
.input::placeholder { color: var(--faint); }
input[type="color"].input { padding: 4px; height: 44px; width: 64px; cursor: pointer; }
.field-error { color: #b91c1c; font-weight: 600; font-size: 13px; margin-top: 6px; }
.input-invalid { border-color: #dc2626; }
fieldset { border: none; margin: 0; padding: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .two-col { grid-template-columns: 1fr; } }

/* ---- tables ----------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.table td { padding: 12px 14px; font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f9fafb; }
.table .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table a { color: var(--ink); font-weight: 600; text-decoration: none; }
.table a:hover { color: var(--accent); }
.table strong { color: var(--ink); }

/* ---- status badges — 5 semantic states, independent of the accent ----- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--subtle); color: #4b5563; border: 1px solid var(--border);
  --dot: #9ca3af;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }
.badge-draft     { background: #f1f3f5; color: #4b5563; border-color: #e3e7eb; --dot: #9ca3af; }
.badge-scheduled { background: #eaf0fd; color: #1d4ed8; border-color: #d3e0fb; --dot: #3b82f6; }
.badge-sending   { background: #fdf3e0; color: #b45309; border-color: #f6e3bf; --dot: #f59e0b; }
.badge-sent      { background: #e7f6ed; color: #15803d; border-color: #c6ebd3; --dot: #22c55e; }
.badge-failed    { background: #fdecec; color: #b91c1c; border-color: #f7d4d4; --dot: #ef4444; }

/* ---- usage meter ------------------------------------------------------ */
.meter { background: var(--subtle); border-radius: 999px; height: 12px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .2s ease; }
.meter.is-full > span { background: #dc2626; }
.meter-label { display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; color: var(--ink); margin-bottom: 8px; }

/* ---- flash / alerts (semantic, never colour-only) --------------------- */
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-control);
  border: 1px solid transparent; font-weight: 500; font-size: 13px;
}
.flash-info    { background: var(--accent-50); border-color: var(--accent-100); color: var(--accent-hover); }
.flash-success { background: #e7f6ed; border-color: #c6ebd3; color: #15803d; }
.flash-warn    { background: #fdf3e0; border-color: #f6e3bf; color: #b45309; }
.flash-error   { background: #fdecec; border-color: #f7d4d4; color: #b91c1c; }
.flash .icon { font-size: 15px; line-height: 1.4; font-weight: 700; }

/* ---- empty states ----------------------------------------------------- */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.empty h2 { color: var(--ink); }

/* ---- invoice detail / preview ---------------------------------------- */
.pdf-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--r-control); background: #fff; }
.logo-preview { max-height: 96px; max-width: 100%; border: 1px solid var(--border); border-radius: var(--r-control); padding: 8px; background: #fff; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
@media (max-width: 560px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-grid dt { color: var(--muted); font-size: 13px; }
.detail-grid dd { margin: 0 0 6px; font-weight: 600; color: var(--ink); }

.totals { margin-left: auto; width: 280px; max-width: 100%; }
.totals .line { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.totals .grand { border-top: 1px solid var(--ink); margin-top: 6px; padding-top: 12px; font-size: 18px; font-weight: 700; color: var(--ink); }

/* ---- line-item builder rows ------------------------------------------ */
.li-row { display: grid; grid-template-columns: 1fr 110px 130px 44px; gap: 10px; align-items: start; margin-bottom: 10px; }
.li-row .li-remove { min-height: 44px; }
.li-head { display: grid; grid-template-columns: 1fr 110px 130px 44px; gap: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
@media (max-width: 560px) {
  .li-row, .li-head { grid-template-columns: 1fr 1fr; }
  .li-head { display: none; }
  .li-row .li-remove { grid-column: 1 / -1; }
}

/* ---- invoice organiser: folder rail + list panel --------------------- */
/* a flush white two-column surface (no cards/gap): folder rail + list panel,
   divided by a thin rule — the spec's "tidy file manager" look. */
.organizer { display: grid; grid-template-columns: 256px 1fr; gap: 0; align-items: stretch; }

.rail {
  background: var(--surface); border: none; border-right: 1px solid var(--border); border-radius: 0;
  box-shadow: none; padding: 16px 12px 16px 16px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 60px; align-self: start;
  height: calc(100vh - 60px); overflow: hidden;
}
.rail-section { display: flex; flex-direction: column; gap: 2px; }
.rail-folders { flex: 1; min-height: 0; }
.rail-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 12px 8px 6px;
}
.rail-add {
  width: 24px; height: 24px; border: none; background: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); border-radius: var(--r-control);
}
.rail-add:hover { background: var(--subtle); color: var(--ink); }
.rail-add .ic { width: 16px; height: 16px; }
.ftree-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.rail-empty { padding: 4px 8px 10px; }

/* system views + folder links share the row look */
.sysview, .fnode-link {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  padding: 8px; border-radius: var(--r-btn);
  color: var(--text); font-weight: 600; font-size: 14px; text-decoration: none;
}
.sysview:hover { background: var(--subtle); color: var(--ink); }
.sysview.is-active { background: var(--accent-50); color: var(--accent-hover); box-shadow: inset 3px 0 0 var(--accent); }
.fnode-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fnode-count { flex: none; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.sysview.is-active .fnode-count { color: var(--accent-hover); }
.count-badge { background: var(--accent-100); color: var(--accent-hover); padding: 1px 8px; border-radius: 999px; font-size: 11.5px; }

.ftree, .fnode-children { list-style: none; margin: 0; padding: 0; border: none; }
/* the whole row carries hover/active (incl. the chevron), with a left accent bar */
.fnode-row { display: flex; align-items: center; gap: 2px; border-radius: var(--r-btn); }
.fnode-row:hover { background: var(--subtle); }
.fnode-row.is-active { background: var(--accent-50); box-shadow: inset 3px 0 0 var(--accent); color: var(--accent-hover); }
.fnode-row .fnode-link { flex: 1; min-width: 0; }
.fnode-row .fnode-link:hover { background: none; color: inherit; }
.fnode-row.is-active .fnode-link,
.fnode-row.is-active .fnode-chevron,
.fnode-row.is-active .fnode-link .ic,
.fnode-row.is-active .fnode-count { color: var(--accent-hover); }

/* native <details> actions menu — no custom JS */
.fnode-menu { position: relative; flex: none; }
.fnode-menu > summary {
  list-style: none; cursor: pointer; width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-control); color: var(--muted); font-weight: 700; user-select: none;
}
.fnode-menu > summary::-webkit-details-marker { display: none; }
.fnode-menu > summary:hover { background: var(--subtle); color: var(--ink); }
.fnode-pop {
  position: absolute; right: 0; top: 30px; z-index: 20; width: 220px;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-pop); padding: 10px;
}
.fnode-form { display: flex; gap: 6px; }
.fnode-form .input-sm { flex: 1; min-width: 0; }
.rail-newfolder { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 12px; }
.rail-newfolder > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--r-btn);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px;
}
.rail-newfolder > summary::-webkit-details-marker { display: none; }
.rail-newfolder > summary:hover { background: var(--subtle); color: var(--ink); }
.rail-newfolder > summary .ic { width: 16px; height: 16px; }
.rail-newfolder-form { display: flex; gap: 6px; margin-top: 8px; }
.rail-newfolder-form .input-sm { flex: 1; min-width: 0; }

/* compact controls used inside the rail + menus */
.input-sm { min-height: 34px; padding: 6px 9px; font-size: 13px; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }

/* panel — flush white, the list's own surface (no card); the filter tools float
   into its top-right corner, so the head reserves space on the right. */
.panel { background: var(--surface); border: none; border-radius: 0; box-shadow: none; padding: 22px 12px 28px 28px; min-width: 0; position: relative; }
.panel-head { margin-bottom: 14px; padding-right: 300px; }
.panel-head .row-between { margin-bottom: 0; }
.panel-title { font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; color: var(--ink); margin: 0; }
.panel-count { margin-top: 4px; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; margin-bottom: 6px; }
.crumbs a { color: var(--muted); text-decoration: none; font-weight: 600; }
.crumbs a:hover { color: var(--accent); }
.crumb-sep { color: var(--faint); }

/* ---- filter bar (search + filter) ------------------------------------ */
/* floats into the panel's top-right corner so search + filter sit beside the
   breadcrumb/title, while staying outside #invoice-results (so a search keystroke
   swaps only the results and the search box keeps focus). */
.filterbar { position: absolute; top: 20px; right: 12px; z-index: 6; display: flex; align-items: center; gap: 10px; width: min(500px, 54%); margin: 0; }
.filterbar .search-input { flex: 1; min-width: 0; }
.filterbar .search-wrap { flex: 1; }
.newinvoice-btn { white-space: nowrap; }
.filters-disclosure { position: relative; flex: none; }
.filters-disclosure > summary { list-style: none; cursor: pointer; }
.filters-disclosure > summary::-webkit-details-marker { display: none; }
.filters-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; width: 300px;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-pop); padding: 14px;
}
.filter-group { border: none; margin: 0; padding: 0; }
.filter-group > legend, .filter-group > label { font-size: 12px; font-weight: 600; color: var(--ink); padding: 0; margin-bottom: 8px; }
.filter-group.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filter-group.two-col label { display: block; margin-bottom: 4px; }
.filter-check { display: inline-flex; align-items: center; gap: 6px; margin: 0 8px 8px 0; cursor: pointer; }
.filter-check input { accent-color: var(--accent); }

/* ---- multi-select + bulk bar ----------------------------------------- */
.organizer-table .col-select { width: 36px; text-align: center; padding-right: 0; }
.organizer-table .row-select, .organizer-table [data-select-all] { accent-color: var(--accent); cursor: pointer; }
.organizer-table tr[data-row] { cursor: grab; }
.organizer-table tr.is-selected { background: var(--accent-50); }
.organizer-table tr.is-selected:hover { background: var(--accent-50); }

.bulkbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 8px 12px;
  background: var(--accent-50); border: 1px solid var(--accent-100); border-radius: var(--r-btn);
}
/* a class display rule beats the UA [hidden] rule, so restore it explicitly:
   the bulk bar only appears once organizer.js shows it (≥1 row selected). */
.bulkbar[hidden] { display: none; }
.bulk-count { font-weight: 600; font-size: 13px; color: var(--accent-hover); margin-right: auto; }

/* drag-and-drop affordances */
body.is-dragging .fnode-link[data-droppable] { outline: 1px dashed var(--border); outline-offset: -1px; border-radius: var(--r-btn); }
.fnode-link.drag-over { background: var(--accent-50); box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent-hover); }

/* ---- toast (undo) ----------------------------------------------------- */
.toast-zone { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 95; }
.toast {
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: #fff; border-radius: var(--r-btn);
  padding: 10px 12px 10px 16px; box-shadow: var(--shadow-pop); font-size: 14px;
}
.toast-msg { font-weight: 500; }
.toast-undo { margin: 0; }
.toast-action { background: none; border: none; color: var(--accent-100); font: inherit; font-weight: 700; cursor: pointer; padding: 4px 8px; border-radius: var(--r-control); }
.toast-action:hover { background: rgba(255, 255, 255, .12); }
.toast-close { background: none; border: none; color: rgba(255, 255, 255, .7); font-size: 13px; cursor: pointer; padding: 4px 6px; }
.toast-close:hover { color: #fff; }

/* ---- modal (move to folder) ------------------------------------------ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, .35); z-index: 90; }
.modal {
  position: fixed; z-index: 91; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow-pop); padding: 20px;
}
.modal-head { margin-bottom: 12px; }
.movelist { list-style: none; margin: 0 0 16px; padding: 0; max-height: 320px; overflow: auto; }
.movetarget { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-control); cursor: pointer; font-size: 14px; }
.movetarget:hover { background: var(--subtle); }
.movetarget input { accent-color: var(--accent); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; }

/* desktop: the "Folders" drawer toggle + backdrop are hidden */
.rail-toggle { display: none; }
.rail-backdrop { display: none; }

@media (max-width: 720px) {
  .organizer { grid-template-columns: 1fr; }
  .rail-toggle { display: inline-flex; margin-bottom: 12px; }

  /* rail becomes an off-canvas slide-over drawer */
  .rail {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 80; height: auto;
    width: 280px; max-width: 84vw; border-radius: 0; border-right: 1px solid var(--border);
    transform: translateX(-100%); transition: transform .18s ease; overflow-y: auto;
  }
  .organizer.rail-open .rail { transform: translateX(0); box-shadow: var(--shadow-pop); }
  .rail-backdrop {
    position: fixed; inset: 0; z-index: 79; background: rgba(17, 24, 39, .35);
  }
  .organizer.rail-open .rail-backdrop { display: block; }
}

.htmx-indicator { opacity: 0; transition: opacity .15s ease; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---- responsive: tighten the top bar + drop the filter tools --------- */
@media (max-width: 860px) {
  .brand { margin-right: 14px; }
  .brand-name { display: none; }
  .topbar { padding: 0 14px; }
  /* the 5 nav links can exceed a phone's width: let them scroll horizontally
     inside the bar (brand + avatar stay pinned) so the page itself never scrolls
     sideways. Full bar height keeps the active-link underline from being clipped. */
  .topnav { flex: 1 1 auto; min-width: 0; height: 60px; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .topnav::-webkit-scrollbar { display: none; }
  .topnav a { padding: 19px 9px; font-size: 14px; white-space: nowrap; }
  .content { padding: 18px 14px 56px; }
  /* the floating search/filter return to a normal row below the head */
  .filterbar { position: static; width: auto; margin-bottom: 14px; }
  .panel-head { padding-right: 0; }
  .panel { padding: 16px 14px 24px; }
}

/* ---- icons (lucide-style inline SVG, stroke = currentColor) ----------- */
.ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; vertical-align: middle; }
.btn .ic { width: 16px; height: 16px; }

/* left-aligned icon+name group inside a system view / folder link */
.fnode-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sysview .ic, .fnode-link .ic { color: var(--muted); }
.sysview.is-active .ic, .fnode-row.is-active .fnode-link .ic { color: var(--accent-hover); }

/* ---- folder tree: chevron disclosure + floated actions menu ----------- */
.fnode { position: relative; }
details.fnode-branch > summary, .fnode-row { padding-right: 34px; cursor: pointer; }
details.fnode-branch > summary { list-style: none; }
details.fnode-branch > summary::-webkit-details-marker { display: none; }
.fnode-chevron {
  flex: none; width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center; color: var(--faint);
}
.fnode-chevron .ic { width: 14px; height: 14px; transition: transform .15s ease; }
details.fnode-branch[open] > summary .fnode-chevron .ic { transform: rotate(90deg); }
.fnode-chevron-leaf { visibility: hidden; }

/* the actions menu is a sibling of the node's disclosure, floated over the row;
   quiet until the folder row is hovered / focused / the menu is open */
.fnode-menu { position: absolute; top: 4px; right: 4px; }
.fnode-menu > summary .ic { width: 16px; height: 16px; }
.fnode-menu > summary { opacity: 0; transition: opacity .12s ease; }
.fnode:hover > .fnode-menu > summary,
.fnode-menu[open] > summary,
.fnode-menu > summary:focus-visible { opacity: 1; }

/* ---- search input with leading icon ---------------------------------- */
.search-wrap { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
.search-wrap > .ic { position: absolute; left: 11px; color: var(--faint); pointer-events: none; }
.search-wrap .input { padding-left: 34px; }
.modal-search { width: 100%; margin-bottom: 12px; }
.filters-disclosure > summary .ic { color: inherit; }

/* ---- active-filter chips --------------------------------------------- */
.chips { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chips-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 9px 5px 11px; border-radius: 999px;
  background: var(--accent); color: #fff; border: none;
  font-size: 12.5px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.chip:hover { background: var(--accent-hover); color: #fff; }
.chip-x { font-size: 11px; opacity: .85; }

/* search-result match highlight (semantic accent tint, not the accent itself) */
.hl { background: var(--accent-100); color: var(--accent-hover); border-radius: 3px; padding: 0 1px; }

/* ---- invoice row actions menu (the ⋯ per-row menu) ------------------- */
.organizer-table .col-actions { width: 44px; text-align: right; padding-left: 0; }
.row-menu { position: relative; display: inline-block; }
.row-menu > summary {
  list-style: none; cursor: pointer; width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-control); color: var(--muted);
}
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu > summary:hover { background: var(--subtle); color: var(--ink); }
.row-pop { right: 0; left: auto; top: 30px; width: 200px; }
.row-pop form { margin: 0; }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: none; background: none; border-radius: var(--r-control);
  color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600;
  text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover { background: var(--subtle); color: var(--ink); }
.menu-item .ic { color: var(--muted); }
.menu-item.danger { color: #b91c1c; }
.menu-item.danger:hover { background: #fdecec; }
.menu-item.danger .ic { color: #b91c1c; }

/* ---- move-to-folder modal: target rows + inline new folder ----------- */
.movetarget .ic { color: var(--muted); }
.movetarget-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.move-newfolder { display: flex; align-items: center; gap: 8px; padding: 10px 2px 2px; margin-top: 6px; border-top: 1px solid var(--border); }
.move-newfolder .ic { color: var(--muted); }
.move-newfolder .input { flex: 1; min-width: 0; }

/* ---- delete-folder confirm modal ------------------------------------- */
.modal-confirm { width: min(380px, calc(100vw - 32px)); }
.confirm-icon {
  width: 44px; height: 44px; margin: 0 auto 8px; border-radius: 50%;
  background: #fdecec; color: #dc2626;
  display: flex; align-items: center; justify-content: center;
}
.confirm-icon .ic { width: 22px; height: 22px; }
.modal-head.center { text-align: center; }
.confirm-note {
  display: flex; align-items: flex-start; gap: 10px; text-align: left;
  background: #fafbfc; border: 1px solid #eceef1; border-radius: 10px;
  padding: 12px 14px; margin: 14px 0;
}
.confirm-note .ic { width: 18px; height: 18px; color: #15803d; margin-top: 1px; }
.confirm-note p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--text); }
.confirm-foot { justify-content: stretch; }
.confirm-foot > .btn, .confirm-foot > form { flex: 1; }
.confirm-foot > form .btn { width: 100%; }
.btn-danger-solid {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 16px; font: inherit; font-weight: 700; font-size: 14px;
  border-radius: var(--r-btn); border: 1px solid #dc2626; background: #dc2626; color: #fff; cursor: pointer;
}
.btn-danger-solid:hover { background: #b91c1c; border-color: #b91c1c; }

/* ---- empty-state icon ------------------------------------------------- */
.empty-icon { color: var(--faint); margin-bottom: 10px; }
.empty-icon .ic { width: 40px; height: 40px; stroke-width: 1.5; }

/* ---- airy list (taller rows, quiet ⋯, tabular Inter amounts) ---------- */
/* shared by the invoices organiser, customers, and the dashboard recent list */
.table-airy th {
  padding: 12px 14px; font-size: 11.5px; letter-spacing: .05em; color: var(--faint);
}
.table-airy td { padding: 17px 14px; font-size: 14px; }
.table-airy tbody tr:hover { background: #fafbfc; }
.table-airy td a { color: var(--ink); font-weight: 700; }
.table-airy td a:hover { color: var(--accent); }
.table-airy .num { font-family: var(--font); font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.table-airy .col-actions { width: 44px; text-align: right; padding-left: 0; }
.organizer-table .col-select { width: 44px; }
/* the ⋯ menu stays quiet until the row is hovered / focused / open */
.table-airy .row-menu > summary { opacity: 0; transition: opacity .12s ease; }
.table-airy tr:hover .row-menu > summary,
.table-airy .row-menu[open] > summary,
.table-airy .row-menu > summary:focus-visible { opacity: 1; }

/* ---- page header (title + sub + primary action) ---------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; }

/* ---- KPI stat cards -------------------------------------------------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 16px 18px; }
.stat-label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.stat-label .ic { width: 15px; height: 15px; color: var(--muted); }
.stat-value { margin-top: 10px; font-size: 26px; font-weight: 700; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-sub { margin-top: 3px; font-size: 12px; color: var(--muted); }
.stat.is-alert .stat-value, .stat.is-alert .stat-label .ic { color: #b91c1c; }
@media (max-width: 860px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .stats-grid { grid-template-columns: 1fr; } }

/* ---- card section header (icon chip + title + description) ------------ */
.section-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.ic-chip { flex: none; width: 36px; height: 36px; border-radius: var(--r-btn); background: var(--accent-50); color: var(--accent-hover); display: inline-flex; align-items: center; justify-content: center; }
.ic-chip .ic { width: 18px; height: 18px; }
.section-headings { min-width: 0; }
.section-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--ink); }
.section-desc { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.section-action { margin-left: auto; }

/* ---- initials avatar inside a list row -------------------------------- */
.list-avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-50); color: var(--accent-hover); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.cust-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cust-name { font-weight: 700; color: var(--ink); }
.cust-email { font-size: 12.5px; color: var(--muted); }

/* ---- billing plan cards ---------------------------------------------- */
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 4px; }
.plan-card { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px; }
.plan-card.is-current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan-name { font-weight: 700; font-size: 15px; color: var(--ink); }
.plan-allow { font-size: 13px; color: var(--muted); }
.plan-cta { margin-top: auto; padding-top: 6px; }
.plan-current { display: inline-flex; align-items: center; gap: 5px; align-self: flex-start; background: var(--accent-50); color: var(--accent-hover); font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.plan-current .ic { width: 13px; height: 13px; }
@media (max-width: 640px) { .plan-grid { grid-template-columns: 1fr; } }

/* ---- file upload framing (logo) -------------------------------------- */
.uploader { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.uploader .stack { flex: 1; min-width: 220px; }

/* ---- optimistic move: fade the panel while the swap confirms --------- */
#invoice-results.htmx-swapping, #invoice-panel.htmx-swapping { opacity: .5; transition: opacity .12s ease; }

/* ---- mobile: modals dock to the bottom as a sheet -------------------- */
@media (max-width: 720px) {
  .modal {
    top: auto; bottom: 0; left: 0; transform: none;
    width: 100%; max-width: 100%; max-height: 85vh;
    border-radius: var(--r-card) var(--r-card) 0 0;
  }
  .modal-confirm { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---- auth: full-bleed split (login / signup / confirm) --------------- */
/* a two-pane screen: the form on a clean white column, the product motif on a
   warm "paper" panel. The panel is supplementary — it drops away under 860px and
   the form takes the full width. */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); }

.auth-form-col { display: flex; align-items: center; justify-content: center; min-width: 0; padding: 48px 24px; background: var(--surface); }
.auth-form { width: 100%; max-width: 392px; min-width: 0; margin-inline: auto; }
.auth-form > * + * { margin-top: 18px; }
.auth-form.center { text-align: center; }

.auth-brand { margin: 0 0 6px; }
.auth-brand .brand-name { display: inline; }   /* keep the wordmark on mobile too */

.auth-head h1 { font-size: 28px; line-height: 1.15; }
.auth-head p { margin: 6px 0 0; }
.auth-alt { margin-top: 22px; }

/* leading-icon form field (mirrors .search-wrap, no JS) */
.field-icon { position: relative; }
.field-icon > .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.field-icon .input { padding-left: 38px; }

/* right-hand "paper" panel */
.auth-art-col { display: flex; align-items: center; justify-content: center; padding: 48px; background: var(--accent-50); border-left: 1px solid var(--border); }
.auth-art { width: 100%; max-width: 440px; text-align: center; }
.auth-art-img { display: block; width: 100%; max-width: 400px; height: auto; margin: 0 auto 36px; }
.auth-art-head { font-size: 22px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; color: var(--ink); margin: 0 0 10px; }
.auth-art-sub { max-width: 360px; margin: 0 auto; font-size: 14px; color: var(--muted); }

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-art-col { display: none; }
}

/* ---- marketing landing (public home) --------------------------------- */
/* Full-bleed sections, each with its own centred container; flat surfaces, the one
   accent, and the product's own components (stats, table, badges) as the hero. */
.lp-container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* sticky nav */
.lp-nav { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); }
.lp-nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.lp-nav-links { display: flex; align-items: center; gap: 10px; }
.lp-nav-link { color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: none; padding: 8px 10px; }
.lp-nav-link:hover { color: var(--ink); }

/* hero (warm paper wash) */
.lp-hero { background: var(--accent-50); border-bottom: 1px solid var(--border); padding: 72px 0 0; }
.lp-hero-inner { text-align: center; }
.lp-eyebrow { display: inline-block; background: var(--accent-100); color: var(--accent-hover); font-size: 12.5px; font-weight: 600; padding: 5px 12px; border-radius: 999px; margin-bottom: 18px; }
.lp-title { font-size: clamp(30px, 5vw, 46px); font-weight: 700; line-height: 1.08; letter-spacing: -.02em; color: var(--ink); margin: 0 auto; max-width: 720px; }
.lp-sub { font-size: 17px; line-height: 1.55; color: var(--muted); margin: 18px auto 0; max-width: 560px; }
.lp-cta-row { margin-top: 26px; }
.lp-trust { margin-top: 14px; font-size: 13px; color: var(--faint); font-weight: 500; }

/* product window (dips into the next section) */
.lp-window { position: relative; z-index: 1; max-width: 960px; margin: 48px auto -64px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-pop); overflow: hidden; text-align: left; }
.lp-window-bar { display: flex; align-items: center; gap: 7px; height: 40px; padding: 0 14px; background: var(--subtle); border-bottom: 1px solid var(--border); }
.lp-dot { width: 11px; height: 11px; border-radius: 50%; background: #d3d8de; }
.lp-window-url { margin: 0 auto; font-size: 12px; color: var(--faint); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 14px; }
.lp-window-body { padding: 20px; }
.lp-window-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.lp-stat { padding: 14px 16px; }
.lp-window-table { margin: 0; }
.lp-window-table th:first-child, .lp-window-table td:first-child { padding-left: 6px; }
.lp-window-table tbody tr:last-child td { border-bottom: none; }

/* features */
.lp-features { background: var(--surface); padding: 112px 0 80px; }
.lp-section-head { text-align: center; max-width: 600px; margin: 0 auto 40px; }
.lp-section-title { font-size: 28px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); margin: 0; }
.lp-section-sub { font-size: 15px; color: var(--muted); margin: 10px 0 0; }
.lp-feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.lp-feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow-card); padding: 24px; transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease; }
.lp-feature:hover { border-color: var(--accent-100); box-shadow: var(--shadow-pop); transform: translateY(-2px); }
.lp-feature .ic-chip { width: 44px; height: 44px; margin-bottom: 14px; }
.lp-feature .ic-chip .ic { width: 22px; height: 22px; }
.lp-feature-title { font-size: 17px; font-weight: 700; color: var(--ink); margin: 0 0 6px; }
.lp-feature-desc { font-size: 14px; color: var(--muted); line-height: 1.55; margin: 0; }

/* dark CTA band */
.lp-cta { background: var(--ink); }
.lp-cta-inner { display: grid; grid-template-columns: .9fr 1.1fr; align-items: center; gap: 40px; padding: 56px 24px; }
.lp-cta-art { display: flex; justify-content: center; }
.lp-cta-art img { width: 100%; max-width: 360px; height: auto; }
.lp-cta-title { font-size: 30px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; color: #fff; margin: 0; }
.lp-cta-sub { font-size: 15px; line-height: 1.55; color: rgba(255, 255, 255, .7); margin: 12px 0 24px; max-width: 460px; }

/* footer */
.lp-footer { background: var(--surface); border-top: 1px solid var(--border); }
.lp-footer-inner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 28px 24px; }
.lp-footer-tag { font-size: 13px; color: var(--muted); margin: 0; }
.lp-footer-links { display: flex; gap: 18px; margin-left: auto; }
.lp-footer-links a { color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: none; }
.lp-footer-links a:hover { color: var(--accent); }
.lp-footer-copy { width: 100%; font-size: 12px; color: var(--faint); margin: 4px 0 0; }

@media (max-width: 860px) {
  .lp-nav-link { display: none; }
  .lp-hero { padding-top: 48px; }
  .lp-window { margin-bottom: -40px; }
  .lp-window-stats { grid-template-columns: 1fr; }
  /* compact the invoice mock so the Status column never clips inside the window;
     overflow-x is a safety net for the very smallest screens. */
  .lp-window-body { padding: 14px; overflow-x: auto; }
  .lp-window-table th, .lp-window-table td { padding: 12px 8px; font-size: 13px; }
  .lp-features { padding-top: 80px; }
  .lp-feature-grid { grid-template-columns: 1fr; }
  .lp-cta-inner { grid-template-columns: 1fr; text-align: center; padding: 44px 24px; }
  .lp-cta-art { order: -1; }
  .lp-cta-art img { max-width: 280px; }
  .lp-cta-sub { margin-inline: auto; }
}
@media (max-width: 640px) {
  .lp-col-opt { display: none; }
}
@media (max-width: 560px) {
  /* drop the widest column on phones — Invoice / Amount / Status tell the story */
  .lp-col-cust { display: none; }
}
