:root {
  --ink: #0B0E11; --bg: #0B0E11; --surface: #12171B; --surface-2: #182026; --line: #233038;
  --text: #E9F1EF; --muted: #8FA3A0; --mint: #03FBC8; --mint-2: #00D4AA; --mint-ink: #03FBC8;
  --danger: #FF6B6B; --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #F5F8F7; --surface: #FFFFFF; --surface-2: #EEF3F2; --line: #DCE5E3; --text: #0B0E11; --muted: #5D6B66; --mint-ink: #00A383; color-scheme: light; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 Heebo, system-ui, -apple-system, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
h2 { font-size: 15px; font-weight: 600; margin: 0; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
h3 { margin: 0 0 12px; }
.muted { color: var(--muted); }
.err { color: var(--danger); margin: 8px 0 0; min-height: 0; font-size: 14px; }
.err:empty { display: none; }

/* wordmark */
.wordmark { font-weight: 800; letter-spacing: -.03em; font-size: 24px; line-height: 1; display: inline-flex; flex-direction: column; }
.wordmark span { color: var(--mint-ink); }
.wordmark { flex-direction: row; flex-wrap: wrap; align-items: baseline; }
.wordmark small { flex-basis: 100%; text-align: right; font-size: 8.5px; font-weight: 600; letter-spacing: .22em; color: var(--muted); margin-top: 3px; }
.wordmark.big { font-size: 44px; margin: 0 auto 8px; }
.wordmark.big small { font-size: 11px; }

/* layout */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 12px max(16px, env(safe-area-inset-left)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; margin-right: auto; background: var(--surface); border: 1px solid var(--line); padding: 3px; border-radius: 999px; }
.tabs button, .seg button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 500; padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.tabs button.active, .seg button.active { background: var(--mint); color: var(--ink); }
.tab { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row.end { align-items: center; }
.grow { flex: 1 1 220px; } .grow-0 { flex: 0 0 auto; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; min-width: 0; }
input[type=color] { padding: 2px; width: 46px; height: 41px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--mint-2); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--mint-2); outline-offset: -1px; border-color: transparent; }
.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: 9px 16px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; }
.btn.primary { background: linear-gradient(180deg, var(--mint), var(--mint-2)); color: var(--ink); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:not(:disabled):hover { filter: brightness(1.08); }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; text-align: center; }

/* customer chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { --c: var(--mint); display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.chip::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip[aria-checked=true] { border-color: var(--c); background: color-mix(in srgb, var(--c) 18%, var(--surface-2)); }

/* lists */
.week-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; }
.list { display: flex; flex-direction: column; gap: 6px; }
.day { font-size: 13px; color: var(--muted); margin: 12px 0 2px; display: flex; justify-content: space-between; }
.item { display: grid; grid-template-columns: 10px 110px 64px 1fr auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.item:hover { border-color: color-mix(in srgb, var(--mint) 40%, var(--line)); }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.item .h { font-weight: 600; font-variant-numeric: tabular-nums; }
.item .d { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.claude { color: #E8A87C; border-color: color-mix(in srgb, #E8A87C 40%, var(--line)); }
.badge.harvest { color: #FA8C4F; border-color: color-mix(in srgb, #FA8C4F 40%, var(--line)); }
.badge.billed { color: var(--mint-ink); border-color: color-mix(in srgb, var(--mint) 40%, var(--line)); }
.empty { color: var(--muted); text-align: center; padding: 30px; border: 1px dashed var(--line); border-radius: 12px; }

/* report */
.filters { display: flex; flex-direction: column; gap: 14px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 999px; align-self: flex-start; }
.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; border-top: 3px solid var(--c, var(--mint)); }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 28px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 13px; }
.stat.total { --c: var(--text); }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 110px; padding: 10px 12px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); position: relative; overflow: hidden; }
.chart .bar { flex: 1 1 0; min-width: 3px; background: linear-gradient(180deg, var(--mint), var(--mint-2)); border-radius: 4px 4px 0 0; position: relative; }
.chart .bar:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 12px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; margin-bottom: 4px; }
.chart .axis { position: absolute; bottom: 4px; font-size: 11px; color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.entries { width: 100%; border-collapse: collapse; font-size: 14px; }
.entries th, .entries td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.entries th { color: var(--muted); font-weight: 500; font-size: 13px; }
.entries td.num, .entries th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entries tr:last-child td { border-bottom: 0; }
.entries tbody tr { cursor: pointer; }
.entries tbody tr:hover { background: var(--surface-2); }
.entries tfoot td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; }
.print-head { display: none; }

/* customers */
.alerts { max-width: 1100px; margin: 0 auto; padding: 12px 16px 0; display: flex; flex-direction: column; gap: 8px; }
.alerts:empty { display: none; }
.alert { padding: 10px 14px; border-radius: 12px; border: 1px solid #F5A524; background: color-mix(in srgb, #F5A524 14%, var(--surface)); font-weight: 500; }
.alert.reached { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.credit-row td { color: var(--muted); font-style: italic; }
.stat .bill { color: var(--text); font-weight: 600; }
.cust.head { background: none; border: 0; padding: 0 14px; font-size: 12px; color: var(--muted); }
.cust { display: grid; grid-template-columns: 46px 1fr 90px 80px 90px 140px auto auto; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.cust.archived { opacity: .55; }
.cust .tot { color: var(--muted); font-size: 13px; white-space: nowrap; }

dialog { border: 0; padding: 0; background: transparent; color: var(--text); width: min(520px, calc(100% - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog .card { display: flex; flex-direction: column; gap: 12px; }
dialog .row label { flex: 1; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--mint); color: var(--ink); font-weight: 600; padding: 10px 18px; border-radius: 999px; opacity: 0; transition: .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 1000px) {
  .cust { grid-template-columns: 46px 1fr 1fr 1fr; }
  .cust.head { display: none; }
}
@media (max-width: 720px) {
  .top { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; justify-content: space-between; }
  .tabs button { flex: 1; }
  .entry-form .row > label.grow-0 { flex: 1 1 40%; }
  .entry-form .btn { width: 100%; }
  .item { grid-template-columns: 10px 1fr auto; }
  .item .d { grid-column: 2 / -1; white-space: normal; }
  .item .src { display: none; }
  .cust { grid-template-columns: 46px 1fr 1fr; }
  .cust.head { display: none; }
  .cust .tot, .cust .btn { grid-column: span 1; }
}

@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --text: #000; --muted: #444; --line: #ccc; color-scheme: light; }
  .top, .filters, .no-print, .bulk, .chart, dialog, .toast { display: none !important; }
  .print-head { display: block; }
  .print-head h1 { margin: 0; font-size: 22px; }
  .tab { padding: 0; max-width: none; }
  .stat { break-inside: avoid; }
}
