/* Alitech ERP: brand purple/pink from the logo, light + dark, no external assets. */
:root {
  --brand: #6a1b9a; --brand-ink: #ffffff; --accent: #e6007e;
  --bg: #f4f2f8; --surface: #ffffff; --surface-2: #faf9fc; --line: #e5e1ee;
  --ink: #1d1630; --muted: #6b6480;
  --ok: #1b7f4b; --ok-bg: #e3f5ea; --warn: #9a6200; --warn-bg: #fff2d6; --bad: #b3261e; --bad-bg: #fde7e5; --info: #1f5fa8; --info-bg: #e3eefb;
  --radius: 10px; --shadow: 0 1px 2px rgba(29, 22, 48, .06), 0 4px 16px rgba(29, 22, 48, .06);
  --side: 232px;
}
:root[data-theme="dark"] {
  --brand: #b36adf; --brand-ink: #1a0f24; --accent: #ff5db1;
  --bg: #130f1c; --surface: #1c1728; --surface-2: #221c31; --line: #342c48;
  --ink: #efeaf8; --muted: #a79fbd;
  --ok: #5fd08e; --ok-bg: #12301f; --warn: #f0b84d; --warn-bg: #33270d; --bad: #ff8a80; --bad-bg: #3a1714; --info: #7db4f0; --info-bg: #14263d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #b36adf; --brand-ink: #1a0f24; --accent: #ff5db1;
    --bg: #130f1c; --surface: #1c1728; --surface-2: #221c31; --line: #342c48;
    --ink: #efeaf8; --muted: #a79fbd;
    --ok: #5fd08e; --ok-bg: #12301f; --warn: #f0b84d; --warn-bg: #33270d; --bad: #ff8a80; --bad-bg: #3a1714; --info: #7db4f0; --info-bg: #14263d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.boot { display: grid; place-items: center; min-height: 100vh; }
.boot-msg { color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.grow { flex: 1 1 auto; } .hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* shell */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 8px; padding: 0 6px; }
.brand img { height: 38px; width: auto; }
.company-switch { display: grid; gap: 4px; }
.company-switch label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; display: grid; gap: 8px; padding: 6px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top .menu-btn { display: none; }
.page { padding: 20px 24px 48px; max-width: 1280px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .card-h { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card > .card-b { 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)); }
.stat { padding: 14px 16px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: 12.5px; }
.stat.bad .v { color: var(--bad); }

/* buttons + inputs */
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 7px 14px; border-radius: 8px; font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 34px; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 3px 10px; min-height: 28px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.input, select, textarea { width: 100%; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; min-height: 34px; }
textarea { min-height: 70px; resize: vertical; }
.field { display: grid; gap: 4px; align-content: start; }
.field > label { font-size: 12.5px; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .input { max-width: 260px; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { background: none; border: 0; padding: 8px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.tbl .num, .tbl th.num { text-align: right; }
.tbl tfoot td { font-weight: 650; border-top: 2px solid var(--line); background: var(--surface-2); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* badges */
.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--info); border-color: transparent; }

/* dl */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* totals box */
.totals { margin-left: auto; width: min(360px, 100%); }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .strong { font-weight: 700; border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 8px; }

/* line editor */
.lines th, .lines td { padding: 6px 8px; }
.lines .input { min-width: 70px; }
.lines td.desc { min-width: 240px; }
.pct-ok { color: var(--ok); font-weight: 600; } .pct-bad { color: var(--bad); font-weight: 600; }

/* bars */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 8px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; min-width: 0; }
.bars .pair { display: flex; align-items: flex-end; gap: 3px; height: calc(100% - 20px); width: 100%; justify-content: center; }
.bars .bar { width: 38%; max-width: 28px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar.a { background: var(--brand); } .bars .bar.b { background: var(--accent); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.dot.a { background: var(--brand); } .dot.b { background: var(--accent); }

/* modal + toast */
.overlay { position: fixed; inset: 0; background: rgba(15, 10, 25, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); width: min(640px, 100%); max-height: 92vh; display: flex; flex-direction: column; }
.modal.wide { width: min(900px, 100%); }
.modal-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-b { padding: 18px; overflow-y: auto; }
.modal-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; }
.toast.err { background: var(--bad); color: #fff; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--info-bg); color: var(--info); }
.alert.bad { background: var(--bad-bg); color: var(--bad); } .alert.warn { background: var(--warn-bg); color: var(--warn); } .alert.ok { background: var(--ok-bg); color: var(--ok); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(420px, 100%); padding: 28px; }
.auth img { height: 54px; margin-bottom: 14px; }
.auth form { display: grid; gap: 14px; margin-top: 16px; }

/* timeline */
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.timeline li { padding-left: 16px; border-left: 2px solid var(--line); }
.timeline .when { color: var(--muted); font-size: 12px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .top .menu-btn { display: inline-flex; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page { padding: 16px 14px 40px; } .top { padding: 10px 14px; }
}
@media (max-width: 560px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 0; } .kv dd { margin-bottom: 8px; }
}
@media print { .side, .top, .actions, .toolbar, .toasts, .btn { display: none !important; } .shell { display: block; } .page { padding: 0; } body { background: #fff; } }
