/* ilmCode Invoice Management System -- admin UI. No build step; bump ?v= in the layout after changes. */
:root {
    --brand: #0f766e;
    --brand-dark: #115e59;
    --brand-soft: #e6f4f2;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f5f7fa;
    --card: #ffffff;
    --red: #dc2626;
    --red-soft: #fef2f2;
    --amber: #b45309;
    --amber-soft: #fffbeb;
    --green: #15803d;
    --green-soft: #f0fdf4;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: #0b2e2b; color: #cfe3e0; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side .brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; color: #fff; font-weight: 650; line-height: 1.2; }
.side .brand img { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; background: #fff; }
.side .brand .logo-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; font-weight: 700; }
.side .brand small { display: block; color: #8fb5b0; font-weight: 400; font-size: 11.5px; margin-top: 2px; }
.side .cta { margin: 4px 14px 10px; }
.side nav { padding: 4px 10px 20px; flex: 1; }
.side .group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6f9994; padding: 14px 10px 6px; }
.side nav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: #cfe3e0; text-decoration: none; }
.side nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side nav a.on { background: rgba(255, 255, 255, .11); color: #fff; }
.side .me { border-top: 1px solid rgba(255, 255, 255, .08); padding: 12px 18px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.side .me a, .side .me button { color: #8fb5b0; background: none; border: 0; cursor: pointer; font: inherit; padding: 0; }
.main { min-width: 0; }
.topbar { display: none; }
.page { padding: 24px 28px 48px; max-width: 1280px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards / grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-b { padding: 18px; }
.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)); }
.g-side { grid-template-columns: minmax(0, 1fr) 330px; align-items: start; }
/* Grid children may shrink below their content (wide tables scroll inside .table-wrap instead). */
.grid > *, .sale-grid > * { min-width: 0; }
.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.stat.hl { background: var(--brand); color: #fff; border-color: var(--brand); }
.stat.hl .label, .stat.hl .sub { color: #c9ebe6; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 550; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; }
.side .btn.primary { background: #14b8a6; border-color: #14b8a6; color: #04201d; }
.side .btn.primary:hover { background: #2dd4bf; }

/* ---------- forms ---------- */
label { display: block; font-weight: 550; font-size: 13px; margin-bottom: 5px; }
label .opt { color: var(--muted); font-weight: 400; }
.input, input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], select, textarea {
    width: 100%; height: 38px; padding: 0 11px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; font: inherit; color: var(--ink);
}
textarea { height: auto; padding: 9px 11px; min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15, 118, 110, .25); border-color: var(--brand); }
input[type=number] { text-align: right; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.err { color: var(--red); font-size: 12.5px; margin-top: 4px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: 16px; height: 16px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 6px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 140px; height: 36px; }
.filters input[type=search] { min-width: 240px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th, .t td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.t .num { text-align: right; }
.t th { font-size: 12px; font-weight: 600; color: var(--muted); background: #f8fafc; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.t tbody tr:hover { background: #fafcfc; }
.t tbody tr:last-child td { border-bottom: 0; }
.t tfoot td { font-weight: 650; background: #f8fafc; border-top: 1px solid var(--line); border-bottom: 0; }
.t .sub { color: var(--muted); font-size: 12.5px; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }

/* ---------- badges / alerts ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: #334155; white-space: nowrap; }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.teal { background: var(--brand-soft); color: var(--brand-dark); }
.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert.ok { background: var(--green-soft); border-color: #bbf7d0; color: #14532d; }
.alert.bad { background: var(--red-soft); border-color: #fecaca; color: #7f1d1d; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.due { color: var(--red); font-weight: 600; }
.pos { color: var(--green); font-weight: 600; }
.pagination { display: flex; gap: 4px; flex-wrap: wrap; padding: 12px 18px; border-top: 1px solid var(--line); }
.pagination a, .pagination span { min-width: 32px; height: 32px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); text-decoration: none; font-size: 13px; }
.pagination .on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .off { color: #cbd5e1; }

/* ---------- dashboard chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b span { width: 100%; max-width: 28px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b.zero span { background: var(--line); }
.bars .b small { font-size: 10.5px; white-space: nowrap; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }

/* ---------- sale screen ---------- */
.sale-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.picker { position: relative; }
.picker .results { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(15, 23, 42, .12); max-height: 360px; overflow-y: auto; display: none; }
.picker .results.open { display: block; }
.picker .opt { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid #f1f5f9; }
.picker .opt:last-child { border-bottom: 0; }
.picker .opt.act, .picker .opt:hover { background: var(--brand-soft); }
.picker .opt.out { opacity: .55; }
.picker .opt .r { text-align: right; white-space: nowrap; font-size: 12.5px; }
.picker .none { padding: 12px; color: var(--muted); }
.lines input { height: 34px; }
.lines td { padding: 8px 10px; }
.lines .qty { width: 90px; }
.lines .price { width: 100px; }
.lines .pct { width: 70px; }
.lines .x { color: var(--muted); background: none; border: 0; cursor: pointer; padding: 4px; border-radius: 6px; }
.lines .x:hover { color: var(--red); background: var(--red-soft); }
.lines .stockinfo { font-size: 12px; color: var(--muted); }
.lines .stockinfo.bad { color: var(--red); font-weight: 600; }
.price-grid td { padding: 7px 8px; }
.price-grid td:first-child { white-space: nowrap; padding-left: 18px; }
.price-grid input { min-width: 80px; }
.price-grid input:disabled { background: #f1f5f9; }
.lines .unit { width: 92px; height: 34px; padding: 0 6px; }
.sum-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; gap: 10px; }
.sum-row.big { font-size: 18px; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
.sum-row input { width: 130px; }
.cust-box { border: 1px dashed #cbd5e1; border-radius: 8px; padding: 10px 12px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.kbd { font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--muted); background: #fff; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #0b2e2b 0%, #0f766e 100%); }
.login { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 30px 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.login h1 { text-align: center; margin: 10px 0 2px; }
.login .muted { text-align: center; margin: 0 0 22px; }
.login .mark { width: 52px; height: 52px; margin: 0 auto; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.login .mark img { width: 52px; height: 52px; object-fit: contain; border-radius: 12px; background: #fff; }

/* ---------- print (reports) ---------- */
@media print {
    .side, .topbar, .filters, .head .actions, .btn, form button { display: none !important; }
    .shell { display: block; }
    body { background: #fff; }
    .page { padding: 0; max-width: none; }
    .card { box-shadow: none; }
    .stat.hl { background: #fff; color: var(--ink); }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
    .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sale-grid, .g-side { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
    body.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
    .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #0b2e2b; color: #fff; position: sticky; top: 0; z-index: 40; }
    .topbar button { background: none; border: 0; color: #fff; padding: 4px; cursor: pointer; }
    .topbar a.btn { margin-left: auto; }
    .page { padding: 16px 16px 40px; }
    .g2, .g3 { grid-template-columns: 1fr; }
    .filters input, .filters select, .filters input[type=search] { min-width: 0; flex: 1 1 140px; }
}
@media (max-width: 520px) {
    .g4 { grid-template-columns: 1fr 1fr; }
    .stat .value { font-size: 18px; }
}
