@import url('https://api.fontshare.com/v2/css?f[]=general-sans@400,500,600&display=swap');
:root {
  --bg: #f4f5f2; --surface: #ffffff; --surface-2: #f0f1ed; --line: #dfe1db; --text: #1c2321; --muted: #66706c;
  --accent: #1d5c63; --accent-soft: #e2eeee; --in: #2f7d5b; --out: #a23b3b; --warn: #a06a12; --warn-soft: #fbf1df;
  --r: 8px; --font: 'General Sans', system-ui, -apple-system, Segoe UI, sans-serif; --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }

/* layout */
header.top { display: flex; align-items: center; gap: 24px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 500; }
nav.tabs { display: flex; gap: 4px; }
nav.tabs button { border: 0; background: none; padding: 7px 12px; border-radius: 6px; color: var(--muted); cursor: pointer; font-weight: 500; }
nav.tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
nav.tabs button:hover { color: var(--text); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
main { padding: 24px 28px 60px; max-width: 1400px; margin: 0 auto; }
section[hidden] { display: none !important; }

/* controls */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 20px; }
.toolbar label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
input, select { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; min-height: 36px; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 14px; min-height: 36px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #c4c8c0; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #164a50; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.danger { color: var(--out); }
.btn:disabled { opacity: .55; cursor: default; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--text); color: #fff; border-color: var(--text); }

/* cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 600; margin-top: 4px; letter-spacing: -0.01em; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.attn { border-color: #e8cf9f; background: var(--warn-soft); cursor: pointer; }
.pos { color: var(--in); } .neg { color: var(--out); }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.card h2 { font-size: 14px; margin: 0 0 12px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; }
.card h2 small { color: var(--muted); font-weight: 400; font-size: 12px; }
.chart-box { position: relative; height: 280px; }

/* category bars */
.catlist { display: grid; gap: 8px; }
.catrow { display: grid; grid-template-columns: 170px 1fr 96px; gap: 10px; align-items: center; font-size: 13px; cursor: pointer; border-radius: 4px; padding: 2px 0; }
.catrow:hover .bar-fill { filter: brightness(.92); }
.catrow .name { display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.bar { height: 10px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; }
.catrow .amt { text-align: right; }

/* tables */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 500; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
tbody tr:hover { background: #fafbf8; }
td.amt, th.amt { text-align: right; white-space: nowrap; }
td .muted, .muted { color: var(--muted); }
td.desc { max-width: 360px; }
td.desc div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td select { min-height: 30px; padding: 4px 8px; max-width: 200px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); margin-left: 6px; }
.tag.review { background: var(--warn-soft); color: var(--warn); }
.tag.manual { background: var(--accent-soft); color: var(--accent); }
.footer-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 2px; color: var(--muted); font-size: 13px; }

/* misc */
.banner { padding: 10px 14px; border-radius: var(--r); margin-bottom: 16px; font-size: 13px; }
.banner.warn { background: var(--warn-soft); color: #6d4a0c; border: 1px solid #e8cf9f; }
.banner.err { background: #f8e6e6; color: #7a2626; border: 1px solid #e6bcbc; }
.banner.info { background: var(--accent-soft); color: var(--accent); border: 1px solid #c4dcdc; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), #e7e9e4, var(--surface-2)); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: 4px; height: 14px; }
@keyframes sh { to { background-position: -200% 0; } }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(460px, 92vw); }
dialog::backdrop { background: rgba(20, 25, 24, .35); }
dialog h3 { margin: 0 0 12px; font-size: 16px; }
dialog .row { display: grid; gap: 4px; margin-bottom: 12px; font-size: 13px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.check input { min-height: 0; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 9px 16px; border-radius: 6px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; }
.login form { width: min(340px, 90vw); display: grid; gap: 12px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }

@media (max-width: 900px) {
  header.top { flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  nav.tabs { order: 3; width: 100%; overflow-x: auto; }
  main { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
  .catrow { grid-template-columns: 120px 1fr 84px; }
  .hide-sm { display: none; }
}
.toolbar label.check { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--text); min-height: 36px; margin-top: 0 !important; align-self: end !important; }
a.btn { display: inline-flex; align-items: center; }
nav.tabs button { white-space: nowrap; }
@media (max-width: 600px) { .kpis { grid-template-columns: 1fr 1fr; } .kpi .value { font-size: 19px; } .top-right #syncInfo { display: none; } }
[hidden] { display: none !important; }
tbody td:first-child { white-space: nowrap; }
.bulkbar { position: sticky; top: 64px; z-index: 4; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--text); color: #fff; padding: 10px 14px; border-radius: var(--r); margin-bottom: 10px; }
.bulkbar select, .bulkbar input { color: var(--text); }
.bulkbar .btn:not(.primary) { background: transparent; color: #fff; border-color: #4a5350; }
.bulkbar .btn.primary { background: #fff; color: var(--text); border-color: #fff; }
tbody tr.sel { background: var(--accent-soft) !important; }
td input[type=checkbox], th input[type=checkbox] { min-height: 0; width: 16px; height: 16px; cursor: pointer; }
tbody td.num { white-space: nowrap; }
