:root {
  --bg: #f4f6f8; --panel: #fff; --ink: #14202b; --muted: #5d6b78; --line: #e2e7ec;
  --brand: #0f5c63; --brand-2: #138a8f; --brand-soft: #e3f2f2; --accent: #e8a33d;
  --good: #1d8a4e; --bad: #c0392b; --warn: #b7791f;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,32,43,.06), 0 4px 16px rgba(16,32,43,.05);
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.mono, .num { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); }

/* Shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #0c2a2e; color: #cfe3e3; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 18px; }
.logo b { background: var(--accent); color: #0c2a2e; border-radius: 8px; width: 30px; height: 30px; display: grid; place-items: center; }
.side .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7fa3a5; margin: 16px 10px 6px; }
.side a { display: block; color: #cfe3e3; padding: 8px 10px; border-radius: 8px; }
.side a:hover { background: rgba(255,255,255,.06); }
.side a.on { background: var(--brand-2); color: #fff; }
.main { padding: 22px 28px 60px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.top .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.banner { background: #fff4e0; border: 1px solid #f3d29a; color: #7a4b00; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }
.menu-btn { display: none; }

/* Cards & grids */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); } .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars div { flex: 1; background: var(--brand-2); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars div:hover::after { content: attr(data-tip); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 11px; padding: 3px 6px; border-radius: 4px; white-space: nowrap; }

/* Tables */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 9px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f6fafa; }
tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: none; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef1f4; color: var(--muted); }
.pill.paid, .pill.active { background: #e2f4ea; color: var(--good); }
.pill.unpaid, .pill.suspended { background: #fbe6e3; color: var(--bad); }
.pill.partial, .pill.trial { background: #fff1d6; color: var(--warn); }
.pill.void { background: #eee; color: #888; text-decoration: line-through; }

/* Forms */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #cfd7de; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: -1px; border-color: transparent; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); font-weight: 500; }
.check input { width: auto; }
button, .btn { font: inherit; font-weight: 600; border: 1px solid #cfd7de; background: #fff; color: var(--ink); padding: 9px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--brand-2); }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-2); }
button.danger { color: var(--bad); }
button.sm { padding: 5px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: none; background: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth .hero { background: linear-gradient(150deg, #0c2a2e, #0f5c63 60%, #138a8f); color: #e6f3f3; padding: 60px; display: flex; flex-direction: column; justify-content: center; }
.auth .hero h1 { font-size: 34px; color: #fff; line-height: 1.15; margin: 18px 0 14px; }
.auth .hero ul { padding-left: 18px; line-height: 2; }
.auth .form { display: grid; place-items: center; padding: 30px; }
.auth .form .card { width: 100%; max-width: 400px; }

/* Modal */
.backdrop { position: fixed; inset: 0; background: rgba(12,42,46,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; } #toast.err { background: var(--bad); }

/* POS */
.pos { display: grid; grid-template-columns: 1fr 380px; gap: 14px; height: calc(100vh - 110px); }
.pos .products { display: flex; flex-direction: column; min-height: 0; }
.pos .tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; overflow-y: auto; padding: 2px; margin-top: 12px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; cursor: pointer; text-align: left; display: block; font-weight: 500; }
.tile:hover { border-color: var(--brand-2); box-shadow: var(--shadow); }
.tile .p { font-family: 'JetBrains Mono', monospace; color: var(--brand); margin-top: 6px; }
.tile .s { font-size: 12px; color: var(--muted); }
.cart { display: flex; flex-direction: column; min-height: 0; }
.cart .lines { flex: 1; overflow-y: auto; margin: 10px -18px; }
.cart .line { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 18px; border-bottom: 1px solid var(--line); }
.qty { display: flex; align-items: center; gap: 4px; } .qty button { padding: 2px 8px; }
.qty input { width: 54px; text-align: center; padding: 4px; }
.total-row { display: flex; justify-content: space-between; padding: 3px 0; }
.total-row.big { font-size: 22px; font-weight: 700; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; }

/* Invoice doc */
.doc { max-width: 860px; }
.doc .head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.doc .title { font-size: 26px; font-weight: 700; color: var(--brand); }
.lines-edit td { padding: 6px; } .lines-edit input, .lines-edit select { padding: 7px 8px; }
.receipt { font-family: 'JetBrains Mono', monospace; font-size: 12px; max-width: 300px; margin: 0 auto; }
.receipt .c { text-align: center; } .receipt hr { border: none; border-top: 1px dashed #999; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: -260px; width: 240px; z-index: 40; transition: left .2s; }
  .side.open { left: 0; }
  .menu-btn { display: inline-flex; }
  .main { padding: 16px; }
  .g4 { grid-template-columns: 1fr 1fr; } .g2, .g3 { grid-template-columns: 1fr; }
  .pos { grid-template-columns: 1fr; height: auto; }
  .auth { grid-template-columns: 1fr; } .auth .hero { padding: 30px; }
  .row { flex-wrap: wrap; } .row > * { flex-basis: 140px; }
}
@media print {
  .side, .top .actions, .no-print, .menu-btn, .banner { display: none !important; }
  .shell { display: block; } .main { padding: 0; } body { background: #fff; }
  .card { box-shadow: none; border: none; padding: 0; }
  .backdrop { position: static; background: none; display: block; padding: 0; }
  .modal { box-shadow: none; max-height: none; padding: 0; }
  body.printing-modal #app { display: none; }
}
