/* ACCTSYS for Windows - one stylesheet for the staff app and the portal */
:root {
  --blue: #0066e8; --blue-ink: #0a4fb3; --pink: #e8206e; --purple: #6d3fc4;
  --yellow: #c98a00; --green: #12805c; --red: #c62839;
  --bg: #f4f5fb; --panel: #ffffff; --ink: #1b1d2a; --muted: #5d6478;
  --line: #e2e5ef; --soft: #eef1fb; --side: #17122b; --side-ink: #d9d4f0;
  --shadow: 0 1px 2px rgba(20, 20, 50, .06), 0 4px 16px rgba(20, 20, 50, .06);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12121a; --panel: #1c1c27; --ink: #ecebf5; --muted: #a3a3b8;
    --line: #2d2d3c; --soft: #242433; --side: #0d0b17; --side-ink: #c9c3e6;
    --blue-ink: #7fb0ff; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink); background: var(--bg);
}
a { color: var(--blue-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.brand { padding: 4px 10px 16px; }
.brand b { display: block; font-size: 17px; color: #fff; letter-spacing: .02em; }
.brand span { font-size: 11px; font-weight: 600; letter-spacing: .08em; }
.brand .t1 { color: var(--pink); } .brand .t2 { color: #5ea0ff; } .brand .t3 { color: #f5c542; }
.side a { color: var(--side-ink); padding: 8px 10px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
.side a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.side a.on { background: linear-gradient(90deg, var(--purple), var(--blue)); color: #fff; }
.side .sep { margin: 12px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; }
.side .grow { flex: 1; }
.side .me { font-size: 12px; padding: 8px 10px; opacity: .8; }
.badge { background: var(--pink); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; gap: 12px; align-items: center; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.content { padding: 20px 24px 48px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }

/* ---------- search */
.search { position: relative; flex: 1; max-width: 560px; }
.search input { width: 100%; padding-left: 34px; }
.search .icon { position: absolute; left: 11px; top: 8px; color: var(--muted); }
.search .kbd { position: absolute; right: 8px; top: 7px; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.results { position: absolute; top: 40px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 70vh; overflow: auto; z-index: 20; }
.results .grp { padding: 6px 12px; font-size: 11px; text-transform: uppercase; color: var(--muted); background: var(--soft); }
.results a { display: flex; justify-content: space-between; padding: 8px 12px; color: var(--ink); }
.results a.sel, .results a:hover { background: var(--soft); text-decoration: none; }

/* ---------- panels, cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.accent { border-top: 3px solid var(--blue); }
.kpi.warn { border-top: 3px solid var(--pink); }
.kpi.ok { border-top: 3px solid var(--green); }
.kpi.purple { border-top: 3px solid var(--purple); }

/* aging bar */
.aging { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--soft); margin: 8px 0; }
.aging span { display: block; }
.a0 { background: var(--blue); } .a1 { background: #f2b51b; } .a2 { background: var(--pink); } .a3 { background: var(--purple); } .a4 { background: #2b2b2b; }
.aging-legend { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; font-size: 12px; }
.aging-legend div { border-left: 3px solid; padding-left: 6px; }
.aging-legend .l0 { border-color: var(--blue); } .aging-legend .l1 { border-color: #f2b51b; } .aging-legend .l2 { border-color: var(--pink); } .aging-legend .l3 { border-color: var(--purple); } .aging-legend .l4 { border-color: #2b2b2b; }

/* ---------- tables */
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--soft); position: sticky; top: 0; }
.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: var(--soft); }
.t .actions { text-align: right; white-space: nowrap; }
.scroll { max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* pills */
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { background: #dff5ea; color: #0c6b4b; }
.pill.warn { background: #ffe6ef; color: #b0134f; }
.pill.info { background: #e3edff; color: #0a4fb3; }
.pill.muted { background: var(--soft); color: var(--muted); }
.pill.purple { background: #ece4ff; color: #5326a8; }
@media (prefers-color-scheme: dark) {
  .pill.ok { background: #143d30; color: #7ee2b8; } .pill.warn { background: #4a1530; color: #ff9cc3; }
  .pill.info { background: #172c52; color: #9cc3ff; } .pill.purple { background: #2e2152; color: #c8b3ff; }
}

/* ---------- buttons and forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 7px 12px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--blue); text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.pink { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn.purple { background: var(--purple); border-color: var(--purple); color: #fff; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn .k { font-size: 10px; opacity: .75; border: 1px solid currentColor; border-radius: 3px; padding: 0 3px; }
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--blue) 40%, transparent); border-color: var(--blue); }
textarea { width: 100%; min-height: 80px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
label.f input, label.f select, label.f textarea { font-weight: 400; font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.span2 { grid-column: span 2; } .span3 { grid-column: span 3; } .span4 { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.form-error { background: #ffe6ef; color: #9d1145; border: 1px solid #f7b6cd; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }
.form-warn { background: #fff4d6; color: #7a5300; border: 1px solid #f1d38a; border-radius: 8px; padding: 8px 12px; margin: 8px 0; }

/* flash */
.flash { margin: 0 0 16px; padding: 10px 14px; border-radius: 8px; border: 1px solid; }
.flash.ok { background: #e6f7ef; border-color: #a9e3c8; color: #0c5c40; }
.flash.warn { background: #fff4d6; border-color: #f1d38a; color: #6b4900; }
.flash.err { background: #ffe6ef; border-color: #f7b6cd; color: #9d1145; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); z-index: 100; max-width: 420px; }

/* ---------- dialogs */
dialog { border: none; border-radius: 14px; padding: 0; width: min(960px, 96vw); background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog.narrow { width: min(560px, 96vw); }
dialog::backdrop { background: rgba(15, 10, 35, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, color-mix(in srgb, var(--purple) 10%, transparent), transparent); }
.dlg-head h2 { margin: 0; }
.dlg-body { padding: 16px 18px; max-height: 72vh; overflow: auto; }
.dlg-foot { display: flex; justify-content: space-between; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--soft); border-radius: 0 0 14px 14px; }
.x { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); }

/* ---------- workspace (the one screen) */
.ws { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
@media (max-width: 1150px) { .ws { grid-template-columns: 1fr; } .ws-list { display: none; } }
.ws-list { position: sticky; top: 76px; max-height: calc(100vh - 100px); display: flex; flex-direction: column; padding: 10px; }
.ws-list input { margin-bottom: 8px; }
.ws-list .items { overflow: auto; }
.ws-list a { display: block; padding: 7px 8px; border-radius: 8px; color: var(--ink); }
.ws-list a:hover { background: var(--soft); text-decoration: none; }
.ws-list a.on { background: color-mix(in srgb, var(--blue) 12%, transparent); }
.ws-list a small { display: flex; justify-content: space-between; color: var(--muted); }
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .hero { grid-template-columns: 1fr; } }
.who h1 { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.who .meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); margin-top: 6px; font-size: 13px; }
.money-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.money-row div { background: var(--soft); border-radius: 8px; padding: 8px 10px; }
.money-row b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.money-row .due b { color: var(--pink); }
.actions-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a.on { color: var(--blue-ink); border-color: var(--blue); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tab { display: none; } .tab.on { display: block; }

/* timeline */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: grid; grid-template-columns: 96px 16px 1fr auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: start; }
.tl .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.dot.invoice { background: var(--blue); } .dot.payment { background: var(--green); } .dot.note { background: var(--purple); }
.dot.reminder { background: var(--pink); } .dot.online { background: #f2b51b; }

/* notes */
.note { border: 1px solid var(--line); border-left: 4px solid var(--purple); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: var(--panel); }
.note.pinned { border-left-color: var(--pink); background: color-mix(in srgb, var(--pink) 5%, var(--panel)); }
.note .head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.note .body { white-space: pre-wrap; }

/* invoice composer */
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: 11px; text-transform: uppercase; color: var(--muted); text-align: left; padding: 4px; }
.lines td { padding: 3px 4px; vertical-align: top; }
.lines input { width: 100%; }
.lines input[type=checkbox] { width: auto; }
.lines .c-item { width: 130px; } .lines .c-qty { width: 80px; } .lines .c-price { width: 110px; } .lines .c-tax { width: 50px; text-align: center; } .lines .c-ext { width: 110px; } .lines .c-x { width: 34px; }
.lines .newitem { font-size: 11px; color: var(--purple); display: block; margin-top: 2px; }
.totals { margin-left: auto; width: 300px; margin-top: 12px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand { font-size: 18px; font-weight: 700; border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 6px; }

/* ---------- sign-on */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 10%, #3a1d7a, transparent 45%), radial-gradient(circle at 90% 90%, #b3104f, transparent 40%), var(--side); }
.login .card { width: min(400px, 92vw); padding: 28px; }
.login h1 { margin-bottom: 2px; }
.login form { display: grid; gap: 12px; margin-top: 16px; }
.login .tag { font-weight: 700; letter-spacing: .06em; font-size: 12px; }

/* ---------- portal */
.portal-top { background: var(--side); color: #fff; }
.portal-top .in { max-width: 1100px; margin: 0 auto; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.portal-nav { background: var(--panel); border-bottom: 1px solid var(--line); }
.portal-nav .in { max-width: 1100px; margin: 0 auto; padding: 0 20px; display: flex; gap: 2px; overflow-x: auto; }
.portal-nav a { padding: 12px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; white-space: nowrap; }
.portal-nav a.on { color: var(--blue-ink); border-color: var(--blue); }
.portal-main { max-width: 1100px; margin: 0 auto; padding: 20px; }
.soon { border: 2px dashed var(--purple); border-radius: var(--radius); padding: 20px; text-align: center; }
@media print { .side, .top, .actions-bar, .tabs, .btn { display: none !important; } .app { display: block; } }

/* ---------- shop back office */
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; display: block; background: var(--soft); }
.thumb.ph { display: grid; place-items: center; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--purple), var(--pink)); }
.thumb.big { width: 100%; height: 160px; font-size: 48px; margin-bottom: 10px; }
.ai-box { margin-top: 16px; border: 1px solid color-mix(in srgb, var(--purple) 35%, var(--line)); background: color-mix(in srgb, var(--purple) 6%, var(--panel)); border-radius: var(--radius); padding: 12px 14px; }
.ai-result { margin-top: 12px; }
.ai-result ul { margin: 4px 0 8px; padding-left: 18px; }
.ai-wait { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); }
.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert-box { position: fixed; right: 20px; top: 70px; width: min(360px, 92vw); background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--pink); border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,.25); z-index: 90; }
.alert-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.alert-item { display: flex; flex-direction: column; padding: 10px 12px; color: var(--ink); border-bottom: 1px solid var(--line); }
.alert-item:hover { background: var(--soft); text-decoration: none; }
.grid > * { min-width: 0; }
.grid > form.grid > * { min-width: 0; }
