:root {
  --bg: #f4f6f3;
  --surface: #ffffff;
  --ink: #17302c;
  --muted: #62746f;
  --line: #e0e7e3;
  --side: #103f3c;
  --side-2: #0b2f2d;
  --side-ink: #e2efec;
  --side-muted: #93b3ad;
  --brand: #0f766e;
  --brand-2: #0b5d57;
  --mint: #f0b429;
  --green: #2f9e78;   --green-bg: #e6f6ef;
  --indigo: #2f6f8f;  --indigo-bg: #e4f0f5;
  --red: #d9583b;     --red-bg: #fcebe6;
  --amber: #d79b1d;   --amber-bg: #fcf3df;
  --blue: #4a90d9;    --blue-bg: #e7f0fb;
  --violet: #8a5a9e;  --violet-bg: #f3eaf6;
  --due: #c43d26;
  --radius: 12px;
  --side-w: 260px;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Manrope", "Segoe UI", Roboto, Arial, sans-serif; line-height: 1.45; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid #f0b429; outline-offset: 2px; }
.i { width: 20px; height: 20px; flex: none; }

/* ---------- sidebar ---------- */
.side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; z-index: 30; transition: transform .2s ease; }
.brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px 16px; }
.brand .logo { width: 42px; height: 42px; border-radius: 50%; background: var(--mint); color: var(--side-2); font-weight: 800; font-size: 1.35rem;
  display: grid; place-items: center; flex: none; }
.brand b { display: block; font-size: 1.08rem; line-height: 1.2; color: #fff; }
.brand small { color: var(--side-muted); font-size: .8rem; }
.msearch { display: flex; align-items: center; gap: 8px; margin: 0 14px 10px; padding: 0 12px; border: 1px solid rgba(255,255,255,.18);
  border-radius: 12px; background: rgba(255,255,255,.06); color: var(--side-muted); }
.msearch input { background: none; border: 0; color: #fff; padding: 10px 0; font: inherit; width: 100%; }
.msearch input::placeholder { color: var(--side-muted); }
.msearch input:focus { outline: none; }
.side nav { overflow-y: auto; padding: 4px 12px 24px; flex: 1; }
.side .grp { font-size: .8rem; font-weight: 600; color: var(--side-muted);
  margin: 16px 8px 6px; display: flex; align-items: center; gap: 10px; }
.side .grp::after { content: none; }
.side nav a { display: flex; align-items: center; gap: 10px; color: var(--side-ink); text-decoration: none; padding: 7px 10px;
  border-radius: 8px; font-weight: 500; margin-bottom: 2px; position: relative; }
.side nav a .tile { width: 32px; height: 32px; border-radius: 50%; background: transparent; display: grid; place-items: center; }
.side nav a .tile .i { width: 18px; height: 18px; }
.side nav a:hover { background: rgba(255,255,255,.08); }
.side nav a[aria-current] { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; }
.side nav a[aria-current] .tile { background: var(--mint); color: var(--side-2); }
.side nav a[aria-current]::before { content: ""; position: absolute; right: 10px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%; background: var(--mint); }
.side nav a.hide, .side .grp.hide { display: none; }
.scrim { display: none; }

/* ---------- shell & top bar ---------- */
.shell { margin-left: var(--side-w); min-height: 100vh; transition: margin .2s ease; }
body.collapsed .side { transform: translateX(-100%); }
body.collapsed .shell { margin-left: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 28px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.iconbtn { background: none; border: 0; color: var(--ink); padding: 8px; border-radius: 10px; cursor: pointer; display: grid; }
.iconbtn:hover { background: var(--bg); }
.iconbtn .i { width: 24px; height: 24px; }
.tb-company { font-weight: 700; font-size: 1.25rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-quick { display: flex; gap: 8px; }
.userchip { position: relative; }
.userchip summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 12px 5px 5px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.userchip summary::-webkit-details-marker { display: none; }
.userchip .av { width: 36px; height: 36px; border-radius: 8px; background: var(--mint); color: #3b2a00; display: grid; place-items: center; font-weight: 700; }
.userchip .un { font-weight: 600; line-height: 1.1; }
.userchip .un small { display: block; color: var(--muted); font-weight: 400; font-size: .78rem; }
.userchip .menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(31,36,64,.12); padding: 6px; min-width: 160px; }
.userchip .menu a { display: block; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.userchip .menu a:hover { background: var(--bg); }

main { padding: 26px 32px 60px; max-width: 1500px; }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
h1 { font-size: 1.7rem; margin: 0; line-height: 1.2; font-weight: 700; }
h2 { font-size: 1.15rem; margin: 26px 0 12px; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- buttons & forms ---------- */
.btn, button { font: inherit; font-weight: 600; border: 1px solid var(--brand); background: var(--brand); color: #fff; padding: 8px 16px;
  border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; }
.btn .i { width: 18px; height: 18px; }
.btn:hover, button:hover { background: var(--brand-2); }
a.btn { color: #fff; }
.btn.ghost, button.ghost { background: #fff; color: var(--brand); border-color: #b9d9d4; }
.btn.ghost:hover, button.ghost:hover { background: #e9f4f2; }
a.btn.ghost { color: var(--brand); }
a.btn.soft { color: #6b4b00; }
.btn.soft { background: #fdf3d8; border-color: #fdf3d8; color: #6b4b00; }
.btn.soft:hover { background: #fbe9b5; }
.btn.danger, button.danger { background: var(--due); border-color: var(--due); }
.btn.small, button.small { padding: 4px 10px; font-size: .88rem; border-radius: 8px; }
label { display: block; font-weight: 500; font-size: .92rem; margin-bottom: 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
input[readonly] { background: #f4f5fa; }
textarea { min-height: 70px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 16px; }
.grid .wide { grid-column: 1 / -1; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters > div { min-width: 150px; }
.filters input, .filters select { padding: 7px 10px; }
.hint { color: var(--muted); font-size: .88rem; margin: 4px 0 0; }
.formfoot { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
details.panel summary { cursor: pointer; }

/* ---------- tables ---------- */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--surface); }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .82rem; color: var(--muted); font-weight: 600; background: #f8f9fc; white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; background: #f8f9fc; }
tr.dim td { color: var(--muted); text-decoration: line-through; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: #fff; }
.table-wrap table { border: 0; }
.table-wrap tr:last-child td { border-bottom: 0; }
.empty { padding: 26px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); margin: 0; }

/* ---------- status ---------- */
.tag { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: #eceef5; color: var(--muted); }
.tag.due { background: var(--red-bg); color: var(--due); }
.tag.ok { background: var(--green-bg); color: var(--green); }
.tag.wait { background: var(--amber-bg); color: #8a6100; }
.due-text { color: var(--due); font-weight: 600; }
.alert { padding: 11px 16px; border-radius: 12px; margin: 0 0 16px; }
.alert.ok { background: var(--green-bg); color: #1d6e52; }
.alert.err { background: var(--red-bg); color: var(--due); }

/* summary strip used on ledger & salesman pages */
.daybook { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.daybook div { padding: 16px 20px; border-right: 1px solid var(--line); }
.daybook div:last-child { border-right: 0; }
.daybook b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.daybook span { color: var(--muted); font-size: .9rem; }
.daybook .market b { color: var(--due); }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }

/* ---------- dashboard ---------- */
.hero { border-radius: 16px; padding: 30px 34px; color: #fff; display: flex; flex-wrap: wrap; gap: 20px; align-items: center; justify-content: space-between;
  background: radial-gradient(circle at 100% 0%, rgba(240,180,41,.28) 0 110px, transparent 111px),
    radial-gradient(circle at 78% 120%, rgba(255,255,255,.08) 0 140px, transparent 141px), #0f5a54;
  margin-bottom: 10px; }
.hero h1 { font-size: 2rem; font-weight: 700; }
.hero p { margin: 4px 0 14px; opacity: .9; font-size: 1.08rem; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 14px; border-radius: 8px; background: var(--mint); color: #3b2a00; font-weight: 600; }
.chip .i { width: 17px; height: 17px; }
.hero form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 0; }
.hero select, .hero input { width: auto; min-width: 190px; padding: 11px 16px; border: 0; border-radius: 12px; font-weight: 500; }
.hero input[type=date] { min-width: 150px; }
.hero button { background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); border-radius: 12px; padding: 10px 18px; }
.hero button:hover { background: rgba(255,255,255,.28); }
.sec { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; font-weight: 700; margin: 30px 0 14px; color: var(--ink); }
.sec .i { display: none; }
.sec::before { content: ""; width: 5px; height: 22px; border-radius: 3px; background: var(--mint); }
.sec small { font-weight: 400; color: var(--muted); font-size: .95rem; }
.sec { font-size: 1.15rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 20px; }
.card { --c: var(--indigo); --cb: var(--indigo-bg); display: flex; flex-direction: row-reverse; justify-content: space-between; gap: 14px; align-items: flex-start; padding: 18px 20px; background: #fff;
  border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: 12px; color: var(--ink); text-decoration: none; min-width: 0; }
a.card:hover { box-shadow: 0 8px 22px rgba(31,36,64,.08); }
.card .ic { width: 44px; height: 44px; border-radius: 50%; background: var(--cb); color: var(--c); display: grid; place-items: center; flex: none; }
.card .ic .i { width: 22px; height: 22px; }
.card .body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card .lbl { font-size: .95rem; font-weight: 500; color: var(--muted); line-height: 1.25; }
.card .val { font-size: 1.7rem; font-weight: 700; margin-top: 4px; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card .sub { color: var(--muted); font-size: .95rem; }
.card .pill { align-self: flex-start; padding: 1px 10px; border-radius: 6px; font-weight: 600; font-size: .88rem; }
.pill.g { background: var(--green-bg); color: var(--green); }
.pill.r { background: var(--red-bg); color: var(--red); }
.pill.a { background: var(--amber-bg); color: #9a6b00; }
.t-green { --c: var(--green); --cb: var(--green-bg); }
.t-indigo { --c: var(--indigo); --cb: var(--indigo-bg); }
.t-red { --c: var(--red); --cb: var(--red-bg); }
.t-amber { --c: var(--amber); --cb: var(--amber-bg); }
.t-blue { --c: var(--blue); --cb: var(--blue-bg); }
.t-violet { --c: var(--violet); --cb: var(--violet-bg); }
.boxhead { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.boxhead h3 { margin: 0; font-size: 1.08rem; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: 10px; }
.bars span { flex: 1; background: linear-gradient(#2fa197, #0f766e); border-radius: 5px 5px 0 0; min-height: 2px; position: relative; }
.bars span:hover { background: var(--mint); }
.bars-x { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: 6px; }

/* ---------- line editor ---------- */
.lines td { padding: 6px; }
.lines select { min-width: 220px; }
.lines input.num { width: 96px; }
.lines .stk { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px; }
.lines .x { background: transparent; color: var(--due); border: 0; font-size: 1.3rem; padding: 0 8px; }
#addline { margin-top: 10px; }
.totals { margin: 16px 0 0 auto; max-width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 6px; font-size: 1.3rem; font-weight: 700; }
#shopinfo { margin-top: 4px; }

/* ---------- login ---------- */
.nouser .shell { margin-left: 0; }
.login { max-width: 380px; margin: 12vh auto; }
.login .panel { padding: 28px; box-shadow: 0 12px 30px rgba(31,36,64,.08); }

/* ---------- tax invoice ---------- */
.invoice { background: #fff; border: 1px solid #222; max-width: 210mm; font-size: .92rem; color: #111; }
.invoice .ihead { display: grid; grid-template-columns: 1fr auto; border-bottom: 1px solid #222; }
.invoice .ihead > div { padding: 12px 14px; }
.invoice .co { font-size: 1.35rem; font-weight: 700; line-height: 1.2; }
.invoice .doc { text-align: right; border-left: 1px solid #222; }
.invoice .doc b { font-size: 1.1rem; }
.invoice .parties { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid #222; }
.invoice .parties > div { padding: 10px 14px; }
.invoice .parties > div + div { border-left: 1px solid #222; }
.invoice table th, .invoice table td { border: 1px solid #9aa0b5; padding: 4px 6px; background: none; color: #111; }
.invoice .sum { display: grid; grid-template-columns: 1fr 260px; border-top: 1px solid #222; }
.invoice .sum > div { padding: 10px 14px; }
.invoice .sum .totals { margin: 0; max-width: none; }
.invoice .foot { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #222; min-height: 90px; }
.invoice .foot > div { padding: 10px 14px; }
.invoice .sign { text-align: right; display: flex; flex-direction: column; justify-content: space-between; }
.small { font-size: .82rem; color: var(--muted); }

/* ---------- small screens ---------- */
@media (max-width: 960px) {
  .side { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.menu-open .side { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(20,22,40,.45); z-index: 25; }
  .shell { margin-left: 0; }
  .topbar { padding: 8px 14px; gap: 8px; }
  .tb-company { font-size: 1.05rem; }
  .tb-quick .soft, .userchip .un, .userchip summary > .i { display: none; }
  .userchip summary { padding: 3px; }
  main { padding: 18px 14px 50px; }
  .hero { padding: 22px; border-radius: 18px; }
  .hero h1 { font-size: 1.5rem; }
  .hero select, .hero input { min-width: 0; flex: 1; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 14px; }
  .card { padding: 18px; gap: 14px; }
  .card .ic { width: 48px; height: 48px; }
  .card .val { font-size: 1.5rem; }
  .invoice .parties, .invoice .sum, .invoice .foot { grid-template-columns: 1fr; }
}
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; }
  .noprint, .side, .topbar, .alert { display: none !important; }
  .shell { margin: 0; }
  main { padding: 0; max-width: none; }
  .pagehead h1 { font-size: 1.1rem; }
  main:has(.invoice) .pagehead { display: none; }
  .panel, .table-wrap { border: 0; padding: 0; }
  .invoice { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
#cust { display: contents; } #cust[hidden] { display: none; }
