/* ExioCraftz Client Manager — styles
   Palette and type follow exiocraftz.com: warm cream canvas, ink text,
   a teal → mint → olive gradient, Sora for UI and IBM Plex Mono for labels. */

@font-face { font-family: 'Sora'; font-weight: 300; font-display: swap; src: url('/fonts/sora/sora-latin-300-normal.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-weight: 400; font-display: swap; src: url('/fonts/sora/sora-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-weight: 500; font-display: swap; src: url('/fonts/sora/sora-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-weight: 600; font-display: swap; src: url('/fonts/sora/sora-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-weight: 700; font-display: swap; src: url('/fonts/sora/sora-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-weight: 400 700; font-display: swap; src: url('/fonts/sora/sora-latin-ext-400-normal.woff2') format('woff2'); unicode-range: U+0100-024F, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF; }
/* ₹ and other currency signs that Sora lacks */
@font-face { font-family: 'Exio Currency'; font-weight: 400 700; font-display: swap; src: url('/fonts/plex-sans/ibm-plex-sans-latin-ext-500-normal.woff2') format('woff2'); unicode-range: U+20A0-20CF; }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap; src: url('/fonts/plex-mono/ibm-plex-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap; src: url('/fonts/plex-mono/ibm-plex-mono-latin-500-normal.woff2') format('woff2'); }

:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --bg-2: #ebe7dd;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-strong: rgba(255, 253, 249, 0.92);
  --panel-solid: #fffdf9;
  --line: rgba(13, 15, 16, 0.10);
  --line-2: rgba(13, 15, 16, 0.18);
  --text: #0d0f10;
  --dim: rgba(13, 15, 16, 0.68);
  --mute: rgba(13, 15, 16, 0.60);
  --teal: #1b7a77;
  --teal-d: #0e5a5a;
  --teal-dd: #0b4a48;
  --teal-soft: #e3efec;
  --mint: #2f9a72;
  --mint-l: #6fdcae;
  --olive: #6f8a2e;
  --amber: #a35f00;
  --amber-soft: #fbefd9;
  --red: #b3261e;
  --red-soft: #fbe5e2;
  --blue: #1d5f8f;
  --blue-soft: #e2eef7;
  --grad: linear-gradient(135deg, #187f86, #2b9a73 55%, #7b9a33);
  --shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 20px 50px -24px rgba(40, 34, 20, .28), 0 2px 6px rgba(40, 34, 20, .06);
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 6px 18px -10px rgba(40, 34, 20, .25);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --sans: 'Sora', 'Exio Currency', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', 'Exio Currency', ui-monospace, monospace;
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar: 252px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
img, svg { max-width: 100%; }
a { color: var(--teal-d); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--teal-dd); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); font-weight: 600; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 .75em; }
:focus-visible { outline: 2.5px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; }
.skip:focus { top: 12px; color: #fff; }
.icon { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dim { color: var(--dim); }
.mute { color: var(--mute); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 1.5rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.eyebrow { font-family: var(--mono); font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--mute); }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.center { text-align: center; }
[data-prewrap] { white-space: pre-wrap; overflow-wrap: anywhere; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 1rem; } .mt-2 { margin-top: 1.5rem; } .mt-half { margin-top: .5rem; }
.mb-0 { margin-bottom: 0 !important; } .mb-1 { margin-bottom: 1rem; } .mb-half { margin-bottom: .5rem; }
.maxw-sm { max-width: 520px; } .maxw-md { max-width: 760px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }

/* ---------------- Animated background (after exiocraftz.com) ---------------- */
.bg-fx { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: radial-gradient(120% 90% at 0% 0%, #f7f4ee 0%, var(--bg) 55%, #efeadf 100%); }
.bg-fx canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.bg-fx .blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; will-change: transform; }
.bg-fx .b1 { width: 52vw; height: 52vw; left: -14vw; top: -18vw; background: radial-gradient(circle at 40% 40%, rgba(111, 220, 174, .55), rgba(111, 220, 174, 0) 65%); animation: drift1 26s var(--ease) infinite; }
.bg-fx .b2 { width: 46vw; height: 46vw; right: -12vw; top: 8vh; background: radial-gradient(circle at 50% 50%, rgba(27, 122, 119, .32), rgba(27, 122, 119, 0) 65%); animation: drift2 32s var(--ease) infinite; }
.bg-fx .b3 { width: 40vw; height: 40vw; left: 22vw; bottom: -20vw; background: radial-gradient(circle at 50% 50%, rgba(170, 196, 92, .40), rgba(170, 196, 92, 0) 65%); animation: drift1 38s var(--ease) infinite reverse; }
.bg-fx .grain { position: absolute; inset: -50%; opacity: .07; mix-blend-mode: multiply; animation: grain 9s steps(6) infinite;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
@keyframes drift1 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-6vw, 5vw) scale(1.12); } }
@keyframes drift2 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(7vw, -4vw) scale(1.1); } }
@keyframes grain { 0% { transform: translate(0, 0); } 20% { transform: translate(-5%, 3%); } 40% { transform: translate(3%, -4%); } 60% { transform: translate(-2%, 5%); } 80% { transform: translate(4%, 1%); } 100% { transform: translate(0, 0); } }
html.reduce-motion .bg-fx .blob, html.reduce-motion .bg-fx .grain { animation: none; }
@media (prefers-reduced-motion: reduce) { .bg-fx .blob, .bg-fx .grain { animation: none; } }

/* ---------------- App shell ---------------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 20px 14px 16px; border-right: 1px solid var(--line);
  background: rgba(250, 248, 243, .62); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
  overflow-y: auto; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 14px; text-decoration: none; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-mark { width: 34px; height: 34px; flex: none; border-radius: 10px; }
.brand-logo { max-height: 34px; max-width: 150px; object-fit: contain; }
.brand-word { font-size: 1.05rem; letter-spacing: -0.02em; }
.brand-word b { font-weight: 700; }
.brand-word span { font-weight: 400; }
.brand-sub { display: block; font-family: var(--mono); font-size: .64rem; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.nav-label { font-family: var(--mono); font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: var(--mute); padding: 14px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 12px; text-decoration: none;
  color: var(--dim); font-size: .92rem; font-weight: 500; transition: background .2s var(--ease), color .2s var(--ease);
}
.nav a:hover { background: rgba(255, 255, 255, .7); color: var(--text); }
.nav a[aria-current="page"] { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.nav a[aria-current="page"] .icon { color: var(--teal); }
.nav .count { margin-left: auto; font-family: var(--mono); font-size: .7rem; background: var(--red-soft); color: var(--red); padding: 1px 7px; border-radius: 99px; }
.sidebar-cta { margin: 6px 4px 8px; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; text-decoration: none; color: var(--text); }
.me:hover { background: rgba(255, 255, 255, .7); color: var(--text); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: .78rem; font-weight: 600; color: #fff; background: var(--grad); }
.me small { display: block; color: var(--mute); font-size: .74rem; }
.signout { width: 100%; justify-content: flex-start; }

.topbar { display: none; }
.main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 64px; }
.page { max-width: 1240px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .lede { color: var(--dim); margin: 6px 0 0; }
.crumbs { font-size: .85rem; margin-bottom: 8px; }
.crumbs a { color: var(--dim); text-decoration: none; display: inline-flex; gap: 4px; align-items: center; }
.crumbs a:hover { color: var(--text); }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); transform: translateX(-102%); transition: transform .3s var(--ease); background: rgba(250, 248, 243, .97); box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .scrim { position: fixed; inset: 0; background: rgba(13, 15, 16, .32); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 25; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; padding: 10px 16px; background: rgba(244, 241, 234, .85); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
  .topbar .brand { padding: 0; }
  .topbar .spacer { flex: 1; }
  .main { padding: 20px 16px 72px; }
}
@media (min-width: 961px) { .scrim { display: none; } }

/* ---------------- Cards ---------------- */
.card { background: var(--panel); border: 1px solid rgba(255, 255, 255, .7); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(14px) saturate(1.15); -webkit-backdrop-filter: blur(14px) saturate(1.15); padding: 22px; }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head h2 .icon { color: var(--teal); }
.card.flat { box-shadow: none; background: rgba(255, 255, 255, .55); }
.card.tight { padding: 0; overflow: hidden; }
.card.tight > .card-head { padding: 18px 20px 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* ---------------- KPI tiles ---------------- */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.kpi { position: relative; padding: 18px 18px 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid rgba(255, 255, 255, .75); box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); overflow: hidden; text-decoration: none; color: var(--text); display: block; }
a.kpi:hover { color: var(--text); transform: translateY(-1px); }
.kpi { transition: transform .25s var(--ease); }
.kpi .label { font-family: var(--mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); display: flex; gap: 6px; align-items: center; }
.kpi .value { font-size: clamp(1.25rem, 1rem + .8vw, 1.6rem); font-weight: 600; letter-spacing: -0.02em; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--dim); margin-top: 2px; }
.kpi .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.kpi.k-received .dot { background: var(--mint); }
.kpi.k-due .dot { background: var(--blue); }
.kpi.k-overdue .dot { background: var(--red); }
.kpi.k-month .dot { background: var(--olive); }
.kpi.k-overdue.has-value { background: linear-gradient(180deg, rgba(251, 229, 226, .85), rgba(255, 255, 255, .72)); }
.kpi.k-overdue.has-value .value { color: var(--red); }
.kpi::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--grad); opacity: 0; transition: opacity .25s; }
a.kpi:hover::after { opacity: .9; }
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px 14px 12px; }
  .kpi .value { font-size: 1.05rem; }
  .kpi .label { font-size: .6rem; letter-spacing: .08em; }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* ---------------- Charts ---------------- */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: rgba(13, 15, 16, .08); }
.chart .axis { fill: var(--mute); font-family: var(--mono); font-size: 10px; }
.chart .bar-inv { fill: #1b7a77; }
.chart .bar-rec { fill: #6fdcae; }
.chart .bar-inv:hover, .chart .bar-rec:hover { opacity: .8; }
.legend { display: flex; gap: 16px; font-size: .8rem; color: var(--dim); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .l-inv { background: #1b7a77; }
.legend .l-rec { background: #6fdcae; }
.aging { display: grid; gap: 10px; }
.aging-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: .86rem; }
.aging-row .track { height: 10px; border-radius: 99px; background: rgba(13, 15, 16, .06); overflow: hidden; }
.aging-row svg { display: block; height: 10px; width: 100%; }
.meter { display: block; width: 100%; height: 8px; }
.progress { display: flex; flex-direction: column; gap: 6px; }
progress { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border: 0; border-radius: 99px; background: rgba(13, 15, 16, .08); overflow: hidden; }
progress::-webkit-progress-bar { background: rgba(13, 15, 16, .08); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--grad); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--grad); border-radius: 99px; }

/* ---------------- Buttons ---------------- */
.btn {
  --b: var(--teal-d);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: 999px; border: 1px solid transparent; font: inherit; font-size: .9rem; font-weight: 500; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .2s var(--ease), box-shadow .2s var(--ease), transform .15s var(--ease), color .2s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal-d); color: #fff; box-shadow: 0 8px 20px -10px rgba(11, 74, 72, .7), inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn-primary:hover { background: var(--teal-dd); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: #fff; border-color: rgba(13, 15, 16, .32); color: var(--text); }
.btn-ghost { background: transparent; color: var(--dim); }
.btn-ghost:hover { background: rgba(255, 255, 255, .7); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #8f1d17; color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--red); border-color: rgba(179, 38, 30, .3); }
.btn-danger-ghost:hover { background: var(--red-soft); color: #8f1d17; }
.btn-sm { min-height: 32px; padding: 5px 12px; font-size: .82rem; }
.btn-icon { min-height: 38px; width: 38px; padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-block { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; margin: 0; }
.actions[data-center] { justify-content: center; }

/* ---------------- Badges ---------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: .74rem; font-weight: 500; white-space: nowrap; background: rgba(13, 15, 16, .06); color: var(--dim); border: 1px solid transparent; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-draft { background: rgba(13, 15, 16, .06); color: #4b4e4f; }
.badge-sent { background: var(--blue-soft); color: var(--blue); }
.badge-partially_paid { background: var(--amber-soft); color: var(--amber); }
.badge-paid { background: #dff3ea; color: #1b6e4f; }
.badge-overdue { background: var(--red-soft); color: var(--red); }
.badge-cancelled { background: rgba(13, 15, 16, .05); color: var(--mute); text-decoration: line-through; }
.badge-demo { background: #fff3c4; color: #6b5200; font-family: var(--mono); letter-spacing: .08em; font-size: .66rem; }
.badge-demo::before, .badge-plain::before { display: none; }
.badge-ok { background: #dff3ea; color: #1b6e4f; }
.badge-warn { background: var(--amber-soft); color: var(--amber); }
.badge-bad { background: var(--red-soft); color: var(--red); }
.badge-info { background: var(--blue-soft); color: var(--blue); }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-family: var(--mono); font-weight: 500; font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr { transition: background .15s; }
table.data tbody tr:hover { background: rgba(255, 255, 255, .55); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num, table.data th.num { text-align: right; }
table.data tfoot td { font-weight: 600; border-top: 1px solid var(--line-2); border-bottom: 0; padding: 12px 14px; }
table.data a.rowlink { color: var(--text); text-decoration: none; font-weight: 500; }
table.data a.rowlink:hover { color: var(--teal-d); text-decoration: underline; }
table.data .sub { display: block; font-size: .78rem; color: var(--mute); }
tr.is-muted td { color: var(--mute); }
tr.is-reversed td { color: var(--mute); }
tr.is-reversed td .amt { text-decoration: line-through; }
a.sort { color: inherit; text-decoration: none; display: inline-flex; gap: 4px; }
a.sort.active { color: var(--text); }
@media (max-width: 760px) {
  table.data.responsive thead { display: none; }
  table.data.responsive tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.data.responsive td { padding: 0; border: 0; }
  table.data.responsive td[data-hide-mobile] { display: none; }
  table.data.responsive td.num { text-align: right; }
}

/* ---------------- Filters / toolbar ---------------- */
.toolbar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .field { margin: 0; }
.search { position: relative; flex: 1 1 240px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--mute); pointer-events: none; }
.search input[type="search"] { padding-left: 38px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; font-size: .82rem; text-decoration: none; color: var(--dim); background: rgba(255, 255, 255, .5); border: 1px solid var(--line); }
.chip:hover { color: var(--text); background: #fff; }
.chip[aria-current="true"] { background: var(--text); color: #fff; border-color: var(--text); }
.chip .n { font-family: var(--mono); font-size: .7rem; opacity: .75; }

/* ---------------- Forms ---------------- */
.field { margin-bottom: 14px; min-width: 0; }
.field label, .label { display: block; font-size: .82rem; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.field .hint { font-size: .8rem; color: var(--mute); margin: 5px 0 0; }
.error-text { font-size: .8rem; color: var(--red); margin: 5px 0 0; font-weight: 500; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"], input[type="number"], input[type="tel"], input[type="url"], input:not([type]), select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; font: inherit; font-size: .92rem; color: var(--text);
  background: rgba(255, 255, 255, .88); border: 1px solid var(--line-2); border-radius: 12px; transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%230d0f10' stroke-width='1.6'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
input:hover, select:hover, textarea:hover { border-color: rgba(13, 15, 16, .32); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(27, 122, 119, .18); background: #fff; }
input[readonly] { background: rgba(13, 15, 16, .04); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
.field-check { margin-bottom: 10px; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: .9rem; cursor: pointer; }
label.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--teal-d); flex: none; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { display: grid; gap: 0 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 760px) { .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); } }
fieldset { border: 0; padding: 0; margin: 0 0 8px; min-width: 0; }
legend { font-weight: 600; font-size: 1rem; margin-bottom: 12px; padding: 0; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.form-error { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--red-soft); color: var(--red); font-size: .9rem; margin-bottom: 14px; }
.input-prefix { display: flex; align-items: stretch; }
.input-prefix span { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--line-2); border-right: 0; border-radius: 12px 0 0 12px; background: rgba(13, 15, 16, .04); font-family: var(--mono); font-size: .82rem; color: var(--dim); }
.input-prefix input { border-radius: 0 12px 12px 0; }

/* ---------------- Line items editor ---------------- */
.items { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.items th { font-family: var(--mono); font-weight: 500; font-size: .66rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); text-align: left; padding: 0 6px; }
.items td { padding: 0 6px; vertical-align: top; }
.items .c-qty { width: 92px; }
.items .c-price { width: 150px; }
.items .c-sac { width: 110px; }
.items .c-amt { width: 140px; text-align: right; padding-top: 11px; font-variant-numeric: tabular-nums; font-weight: 500; }
.items .c-del { width: 44px; }
.items textarea { min-height: 42px; height: 42px; resize: vertical; }
.items input { text-align: right; }
.items td:first-child input, .items .c-sac input { text-align: left; }
@media (max-width: 760px) {
  .items thead { display: none; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; margin-bottom: 10px; border-radius: 14px; background: rgba(255, 255, 255, .6); border: 1px solid var(--line); }
  .items td { padding: 0; width: auto !important; }
  .items td:first-child { grid-column: 1 / -1; }
  .items .c-amt { padding-top: 0; text-align: left; }
  .items td[data-label]::before { content: attr(data-label); display: block; font-family: var(--mono); font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
}
.totals { margin-left: auto; width: min(100%, 360px); font-size: .92rem; }
.totals .t-row { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; }
.totals .t-row span:last-child { font-variant-numeric: tabular-nums; }
.totals .t-total { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 10px; font-weight: 600; font-size: 1.05rem; }
.totals .t-due { color: var(--teal-d); font-weight: 600; }

/* ---------------- Flash / notices ---------------- */
.flashes { display: grid; gap: 10px; margin-bottom: 18px; }
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px 12px 16px; border-radius: 14px; font-size: .9rem; border: 1px solid; box-shadow: var(--shadow-sm); animation: flashIn .35s var(--ease); background: #fff; }
.flash .icon { margin-top: 1px; }
.flash p { margin: 0; flex: 1; }
.flash-success { border-color: rgba(47, 154, 114, .35); background: #effaf5; color: #135c41; }
.flash-error { border-color: rgba(179, 38, 30, .3); background: #fdf0ee; color: #8f1d17; }
.flash-warning { border-color: rgba(163, 95, 0, .3); background: #fdf6e8; color: #6e4000; }
.flash button { background: none; border: 0; color: inherit; cursor: pointer; padding: 2px; border-radius: 6px; opacity: .7; }
.flash button:hover { opacity: 1; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; font-size: .88rem; background: rgba(255, 255, 255, .6); border: 1px solid var(--line); }
.notice .icon { color: var(--teal); margin-top: 2px; }
.notice.warn { background: #fdf6e8; border-color: rgba(163, 95, 0, .25); }
.notice.warn .icon { color: var(--amber); }
.notice.bad { background: #fdf0ee; border-color: rgba(179, 38, 30, .25); }
.notice.bad .icon { color: var(--red); }
.notice.ok { background: #effaf5; border-color: rgba(47, 154, 114, .3); }
.notice.ok .icon { color: var(--mint); }
.notice p:last-child { margin-bottom: 0; }

/* ---------------- Empty states ---------------- */
.empty { text-align: center; padding: 44px 20px; color: var(--dim); }
.empty .empty-icon { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--teal-soft); color: var(--teal); }
.empty .empty-icon .icon { width: 26px; height: 26px; }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 420px; margin: 0 auto 16px; font-size: .9rem; }

/* ---------------- Lists ---------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list[data-pad] { padding: 0 20px 8px; }
.toolbar[data-pad-x] { padding: 0 20px; }
.list .when { margin-left: auto; text-align: right; font-size: .8rem; color: var(--mute); white-space: nowrap; }
.list .what { min-width: 0; flex: 1; }
.list .what a { color: var(--text); text-decoration: none; font-weight: 500; }
.list .what a:hover { color: var(--teal-d); }
.list .what .sub { display: block; font-size: .8rem; color: var(--mute); overflow: hidden; text-overflow: ellipsis; }
.dot-icon { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--teal-soft); color: var(--teal); }
.dot-icon .icon { width: 15px; height: 15px; }
.dot-icon.pay { background: #dff3ea; color: #1b6e4f; }
.dot-icon.warn { background: var(--red-soft); color: var(--red); }
.dot-icon.mail { background: var(--blue-soft); color: var(--blue); }
.datebox { width: 46px; flex: none; text-align: center; border-radius: 12px; background: #fff; border: 1px solid var(--line); padding: 4px 0; line-height: 1.1; }
.datebox b { display: block; font-size: 1.05rem; }
.datebox span { font-family: var(--mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }

/* ---------------- Detail layouts ---------------- */
.dl { display: grid; grid-template-columns: minmax(110px, auto) minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: .9rem; }
.dl dt { color: var(--mute); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 18px; }
.summary-strip > div { background: var(--panel-strong); padding: 14px 16px; }
.summary-strip .label { font-family: var(--mono); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin: 0; }
.summary-strip .value { font-size: 1.15rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 4px; }
.summary-strip .value.due { color: var(--teal-d); }
.summary-strip .value.bad { color: var(--red); }
.paper { background: var(--panel-solid); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: clamp(18px, 3vw, 36px); position: relative; overflow: hidden; }
.paper::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--grad); }
.paper-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 24px; }
.paper .addr { font-size: .86rem; color: var(--dim); white-space: pre-line; }
.paper h3.inv-title { font-size: 1.6rem; letter-spacing: -0.03em; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--dim); font-size: .9rem; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 8px; align-items: center; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--text); border-color: var(--teal); }
.tabs a .icon { width: 16px; height: 16px; }
details.disclosure { border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .5); }
details.disclosure > summary { cursor: pointer; padding: 12px 16px; font-weight: 500; list-style: none; display: flex; gap: 8px; align-items: center; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: '+'; margin-left: auto; font-family: var(--mono); color: var(--dim); }
details.disclosure[open] > summary::after { content: '–'; }
details.disclosure > .inner { padding: 0 16px 16px; }
.codebox { font-family: var(--mono); font-size: .85rem; background: rgba(13, 15, 16, .05); border: 1px dashed var(--line-2); border-radius: 12px; padding: 12px 14px; overflow-wrap: anywhere; }
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row input { font-family: var(--mono); font-size: .8rem; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; font-family: var(--mono); }
.email-preview { border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; }
.email-preview .ep-head { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: .85rem; display: grid; gap: 4px; background: rgba(244, 241, 234, .5); }
.email-preview .ep-body { padding: 16px; white-space: pre-wrap; font-size: .9rem; line-height: 1.6; overflow-wrap: anywhere; }
.placeholder-list { display: flex; flex-wrap: wrap; gap: 6px; }
.placeholder-list code { font-family: var(--mono); font-size: .76rem; background: var(--teal-soft); color: var(--teal-dd); padding: 2px 8px; border-radius: 6px; }
.status-line { display: flex; gap: 8px; align-items: center; font-size: .88rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mute); flex: none; }
.status-dot.on { background: var(--mint); box-shadow: 0 0 0 4px rgba(47, 154, 114, .15); animation: pulseDot 2.2s ease-in-out infinite; }
.status-dot.off { background: #b9b6ae; }
.status-dot.bad { background: var(--red); }
@keyframes pulseDot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(.85); } }
@media (prefers-reduced-motion: reduce) { .status-dot.on, .flash { animation: none; } }
.qr svg { width: 180px; height: 180px; background: #fff; padding: 8px; border-radius: 14px; border: 1px solid var(--line); }

/* ---------------- Dialog ---------------- */
dialog.modal { border: 0; padding: 0; border-radius: 20px; width: min(520px, calc(100vw - 32px)); background: var(--panel-solid); color: var(--text); box-shadow: 0 30px 80px -20px rgba(13, 15, 16, .45); }
dialog.modal::backdrop { background: rgba(13, 15, 16, .38); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: dialogIn .25s var(--ease); }
@keyframes dialogIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-body { padding: 24px; }
.modal-body h2 { margin-bottom: 8px; }
.modal-body p { color: var(--dim); font-size: .92rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px 20px; flex-wrap: wrap; }

/* ---------------- Auth pages ---------------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: min(100%, 440px); }
.auth-card.wide { width: min(100%, 640px); }
.auth-brand { display: flex; justify-content: center; margin-bottom: 22px; }
.auth-card .card { padding: clamp(22px, 4vw, 34px); }
.auth-card h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-card .lede { color: var(--dim); margin-bottom: 20px; font-size: .92rem; }
.auth-foot { text-align: center; margin-top: 18px; font-size: .82rem; color: var(--mute); }
.steps { display: flex; gap: 8px; margin-bottom: 18px; }
.steps span { flex: 1; height: 4px; border-radius: 99px; background: var(--line-2); }
.steps span.done { background: var(--grad); }

/* ---------------- Misc ---------------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; padding: 4px 10px; border-radius: 99px; background: rgba(255, 255, 255, .7); border: 1px solid var(--line); color: var(--dim); }
.kbd { font-family: var(--mono); font-size: .75rem; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line-2); background: #fff; }
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: .86rem; }
.timeline li::before { content: ''; position: absolute; left: 5px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); }
.timeline li::after { content: ''; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--line-2); }
.timeline li:last-child::after { display: none; }
.timeline .t { color: var(--mute); font-size: .78rem; display: block; }
.fade-in { animation: fadeUp .5s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade-in { animation: none; } * { scroll-behavior: auto !important; } }
.only-mobile { display: none; }
@media (max-width: 760px) { .hide-mobile { display: none !important; } .only-mobile { display: initial; } }

@media print {
  .sidebar, .topbar, .bg-fx, .no-print, .flashes { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .card, .paper { box-shadow: none; border: 0; backdrop-filter: none; }
  body { background: #fff; }
}

/* ---------------- Email attachments ---------------- */
.attach-box { border: 1px dashed var(--line-2); border-radius: 14px; padding: 14px 16px; margin: 4px 0 14px; background: rgba(255, 255, 255, .5); min-width: 0; }
.attach-box legend { padding: 0 6px; display: inline-flex; gap: 6px; align-items: center; }
.attach-box input[type="file"] { width: 100%; font: inherit; font-size: .88rem; }
.attach-box .list { margin-bottom: 10px; }
.attach-box .hint.is-bad { color: var(--red); font-weight: 500; }
.ep-attach { border-top: 1px solid var(--line); }
