:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e3e6ea;
  --text: #1c2430;
  --muted: #667085;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --accent-soft: #fff1e8;
  --side: #19202b;
  --side-text: #c4cad4;
  --side-active: #2a3442;
  --good: #067647;   --good-bg: #e7f6ee;
  --warn: #93500a;   --warn-bg: #fdf3dc;
  --bad: #b42318;    --bad-bg: #fdecea;
  --info: #1e5aa8;   --info-bg: #e8f0fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 650; margin-bottom: 12px; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.block { display: block; }
.good-text { color: var(--good); }
.bad-text { color: var(--bad); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; margin: 8px 0; }
.loading, .empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty.small { padding: 16px; }
.empty.error { color: var(--bad); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); overflow-y: auto; padding-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: #8b95a5; letter-spacing: .08em; }
.logo { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.logo.big { width: 52px; height: 52px; font-size: 20px; margin: 0 auto 12px; }
.nav-group { padding: 6px 10px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7d8796; padding: 8px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; color: var(--side-text); }
.nav a:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav .ico { width: 18px; text-align: center; opacity: .8; }
.content { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.spacer { flex: 1; }
.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); }
.user-chip small { display: block; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; }
#main { flex: 1; overflow-y: auto; padding: 22px 24px 48px; }

/* ---------- Page ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.narrow { max-width: 560px; }
.card h2 + .form-grid { margin-bottom: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 16px; }
.banner { background: var(--warn-bg); color: var(--warn); border: 1px solid #f3d9a4; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger.ghost { color: var(--bad); border-color: #f2c4bf; background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; padding: 10px; }
.icon-btn { border: 0; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.tone-good { background: var(--good-bg); color: var(--good); }
.tone-warn { background: var(--warn-bg); color: var(--warn); }
.tone-bad { background: var(--bad-bg); color: var(--bad); }
.tone-info { background: var(--info-bg); color: var(--info); }
.tone-muted { background: #eef0f3; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 9px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tr.clickable { cursor: pointer; }
.grid tr.clickable:hover td { background: var(--accent-soft); }
.grid tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.card > .table-wrap { margin: 0 -18px; }
.card > .table-wrap .grid th:first-child, .card > .table-wrap .grid td:first-child { padding-left: 18px; }
.card.flush > .table-wrap, .list-body .table-wrap { margin: 0; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filter { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.filter.grow { flex: 1; min-width: 200px; }
.filter-end { margin-left: auto; display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* ---------- Forms ---------- */
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid #cfd4dc; border-radius: 7px; padding: 7px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(194, 65, 12, .25); border-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 600; color: #475467; }
.field small { color: var(--muted); }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: 1 / -1; }
.party-info { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Line editor */
.lines-editor td { padding: 6px 6px; vertical-align: top; }
.lines-editor .idx { color: var(--muted); padding-top: 13px; width: 28px; }
.lines-editor .item-cell { min-width: 260px; }
.lines-editor .item-cell .desc { margin-top: 4px; }
.lines-editor .num-input { width: 96px; text-align: right; }
.lines-editor .unit-input { width: 64px; }
.lines-editor .amount { padding-top: 13px; font-weight: 600; }
.lines-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.totals { min-width: 280px; margin-left: auto; }
.trow { display: flex; justify-content: space-between; gap: 24px; padding: 5px 0; }
.trow span { color: var(--muted); }
.trow.grand { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 9px; font-size: 16px; }
.trow.grand span { color: var(--text); font-weight: 600; }
.trow.due strong { color: var(--bad); }

/* ---------- Document view ---------- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 20px; }
.info span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.status-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: -6px 0 14px; }
.terms { white-space: pre-wrap; font: inherit; margin: 0; color: #344054; }
.note { margin: 0; }

/* ---------- Dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis.compact { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); display: flex; flex-direction: column; gap: 4px; }
a.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }
.kpi.tone-bad { background: var(--surface); border-color: #f2c4bf; }
.kpi.tone-bad strong { color: var(--bad); }
.kpi.tone-warn strong { color: var(--warn); }
.flow { display: flex; align-items: stretch; gap: 6px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; }
.flow-step { flex: 1; min-width: 118px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; color: var(--text); box-shadow: var(--shadow); }
.flow-step:hover { text-decoration: none; border-color: var(--accent); }
.flow-step strong { font-size: 22px; color: var(--accent); }
.flow-step small { color: var(--muted); }
.flow-arrow { align-self: center; color: var(--muted); font-size: 18px; }
.bars { display: flex; gap: 14px; align-items: flex-end; height: 180px; padding: 8px 4px 0; border-bottom: 1px solid var(--border); }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-pair { flex: 1; width: 100%; display: flex; gap: 4px; align-items: flex-end; justify-content: center; }
.bar { width: 40%; max-width: 26px; min-height: 2px; border-radius: 4px 4px 0 0; }
.bar.sales, .sw.sales { background: var(--accent); }
.bar.purchases, .sw.purchases { background: #94a3b8; }
.bar-group > span { font-size: 12px; color: var(--muted); padding: 6px 0; }
.legend { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 10px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
.stage-list { list-style: none; margin: 0; padding: 0; }
.stage-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); }
.stage-list li:last-child { border-bottom: 0; }

/* ---------- Production ---------- */
.stepper { display: flex; gap: 4px; overflow-x: auto; }
.step { flex: 1; min-width: 78px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--muted); position: relative; }
.step::before { content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.step:first-child::before { display: none; }
.step .dot { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--border); display: grid; place-items: center; font-size: 12px; font-weight: 700; z-index: 1; }
.step.done .dot { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.step.done::before, .step.current::before { background: var(--good); }
.step.current .dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.current small { color: var(--text); font-weight: 600; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.board-col { background: #eceef1; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.board-head { display: flex; justify-content: space-between; font-weight: 650; font-size: 13px; margin-bottom: 8px; }
.board-head .count { background: var(--surface); border-radius: 999px; padding: 0 8px; color: var(--muted); }
.board-card { display: flex; flex-direction: column; gap: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; color: var(--text); box-shadow: var(--shadow); }
.board-card:hover { border-color: var(--accent); text-decoration: none; }
.board-card small { color: var(--muted); }

/* ---------- Dialogs & toasts ---------- */
dialog.modal { border: 0; border-radius: 12px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); color: var(--text); }
dialog.modal.wide { width: min(820px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(16, 24, 40, .45); }
dialog.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px; }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, .15); font-weight: 550; transition: opacity .4s, transform .4s; max-width: 380px; }
.toast.hide { opacity: 0; transform: translateY(8px); }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #19202b 0%, #2a3442 55%, #7c2d12 130%); }
.login-card { background: var(--surface); padding: 32px; border-radius: 14px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); text-align: center; }
.login-card .field { text-align: left; }
.login-card .sub { margin: -8px 0 4px; color: var(--muted); }
.login-error { color: var(--bad); min-height: 18px; font-size: 13px; }

/* ---------- Print sheet ---------- */
.print-toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; max-width: 210mm; margin: 0 auto 14px; }
.sheet { background: #fff; width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto; padding: 14mm 12mm; box-shadow: var(--shadow); border: 1px solid var(--border); font-size: 12px; color: #111; }
.sheet .pre { white-space: pre-line; }
.p-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #111; padding-bottom: 10px; }
.p-head h1 { font-size: 22px; color: var(--accent); }
.p-head .tagline { font-style: italic; color: #444; margin-bottom: 4px; }
.p-title { text-align: right; }
.p-title h2 { font-size: 17px; letter-spacing: .06em; margin: 0; }
.p-cancelled { margin-top: 8px; color: var(--bad); border: 2px solid var(--bad); display: inline-block; padding: 2px 10px; font-weight: 800; letter-spacing: .1em; }
.p-parties { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid #999; }
.p-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #555; margin-bottom: 2px; }
.p-meta { border-collapse: collapse; justify-self: end; }
.p-meta th { text-align: left; font-weight: 600; color: #555; padding: 1px 10px 1px 0; white-space: nowrap; }
.p-meta td { padding: 1px 0; }
.p-lines { width: 100%; border-collapse: collapse; margin-top: 10px; }
.p-lines th { background: #f1f1f1; border: 1px solid #999; padding: 5px; font-size: 11px; text-align: left; }
.p-lines td { border: 1px solid #bbb; padding: 5px; vertical-align: top; }
.p-lines small { color: #555; }
.p-foot { display: flex; justify-content: space-between; gap: 20px; margin-top: 10px; }
.p-words { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.p-totals { border-collapse: collapse; min-width: 240px; }
.p-totals th { text-align: left; font-weight: 500; padding: 3px 12px 3px 0; }
.p-totals td { padding: 3px 0; }
.p-totals tr.grand th, .p-totals tr.grand td { font-weight: 800; font-size: 14px; border-top: 2px solid #111; padding-top: 6px; }
.p-terms { margin-top: 14px; border-top: 1px solid #999; padding-top: 8px; }
.p-sign { display: flex; justify-content: space-between; margin-top: 28px; text-align: right; }
.sign-line { margin-top: 44px; border-top: 1px solid #111; padding-top: 4px; min-width: 200px; text-align: center; }
.p-footer { margin-top: 20px; text-align: center; color: #777; font-size: 10px; }

body.print-mode #main { background: #e9ebee; }

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .sidebar, .topbar, .print-toolbar, #toasts { display: none !important; }
  .shell, .content { display: block; height: auto; }
  #main { padding: 0; overflow: visible; background: #fff !important; }
  .sheet { box-shadow: none; border: 0; margin: 0; width: auto; min-height: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .menu-btn { display: inline-block; }
  #main { padding: 16px; }
  .topbar { padding: 8px 16px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: 1 / -1; }
  .user-chip span:last-child { display: none; }
  .p-parties { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .form-grid, .form-grid.two { grid-template-columns: 1fr; }
  .kpis, .kpis.compact { grid-template-columns: 1fr; }
}

/* ---------- Multi-company / super admin ---------- */
.expiry { background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid #f3d9a4; padding: 8px 24px; font-weight: 550; }
body.super { --side: #0b1a4a; --side-active: #1b2f73; --accent: #1e3a8a; --accent-hover: #172e6e; --accent-soft: #eef2fb; }
body.super .login-page { background: linear-gradient(160deg, #0b1a4a 0%, #1b2f73 60%, #b8860b 140%); }
code { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-size: 12.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 420px; }
.chip { font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; white-space: nowrap; }
.chip.all { background: var(--good-bg); color: var(--good); }
.presets { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.module-card { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 9px; padding: 12px; cursor: pointer; background: var(--surface); }
.module-card:hover { border-color: var(--accent); }
.module-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.module-card input { margin-top: 2px; flex: none; }
.module-card strong { display: block; margin-bottom: 2px; }
.module-card small { display: block; color: var(--muted); line-height: 1.4; }
.module-card .req { color: var(--warn); margin-top: 4px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.copy-row { display: flex; gap: 8px; margin-bottom: 14px; }
.copy-row input { font-size: 12.5px; }
.info-grid.compact { grid-template-columns: 1fr 1fr; gap: 10px; }
.switch { display: flex; align-items: center; gap: 8px; padding-top: 6px; font-weight: 500; }
.side .card > .table-wrap { margin: 0 -18px; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
.empty.locked { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 60px 20px; }
.empty.locked strong { color: var(--text); font-size: 16px; }

/* ---------- Roles & permissions ---------- */
.perm-wrap { max-height: 52vh; overflow: auto; border: 1px solid var(--border); border-radius: 9px; margin-top: 12px; }
.perm-matrix th { position: sticky; top: 0; z-index: 1; }
.perm-matrix .center { text-align: center; }
.perm-matrix td { padding: 7px 12px; }
.perm-matrix .group-row td { background: var(--surface-2); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 12px; }
.perm-matrix tbody tr:not(.group-row):hover td { background: var(--accent-soft); }
.col-toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; text-transform: none; letter-spacing: 0; }
.chip.lvl-edit { background: var(--info-bg); color: var(--info); }
.chip.lvl-view { background: #eef0f3; color: var(--muted); }
.role-preview { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; font-size: 13px; }

/* ---------- Sidebar groups (collapsible) ---------- */
button.nav-title { display: flex; width: 100%; justify-content: space-between; align-items: center; background: none; border: 0; font: inherit; font-size: 11px; cursor: pointer; text-align: left; }
button.nav-title::after { content: "▾"; font-size: 10px; opacity: .6; transition: transform .15s; }
button.nav-title:hover { color: #c4cad4; }
.nav-group.collapsed button.nav-title::after { transform: rotate(-90deg); }
.nav-group.collapsed .nav-links { display: none; }
.nav-label { flex: 1; min-width: 0; }
.nav-count { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; line-height: 18px; }

/* ---------- Register forms ---------- */
.form-section { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 8px 0 -4px; padding-top: 8px; border-top: 1px solid var(--border); }
.form-grid > .form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.sub-grid { padding: 0; }
.sub-grid[hidden] { display: none; }
.field.calc input, .field.calc select { background: var(--accent-soft); color: var(--text); font-weight: 600; border-color: #f3d3bf; }
.field-link { font-weight: 400; text-decoration: none; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.lines-editor select, .lines-editor input:not(.num-input):not(.unit-input) { min-width: 110px; }
.lines-editor .unit-input.wide { width: 120px; }
.files { list-style: none; margin: 0; padding: 0; }
.files li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.files li:last-child { border-bottom: 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.hidden-file { display: none; }
.pick-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.pick-list li { padding: 8px 4px; border-bottom: 1px solid var(--border); }

/* ---------- Register print ---------- */
.p-meta.iso { margin-top: 6px; margin-left: auto; font-size: 11px; }
.p-fields { width: 100%; border-collapse: collapse; margin-top: 10px; }
.p-fields th, .p-fields td { border: 1px solid #bbb; padding: 4px 6px; text-align: left; vertical-align: top; }
.p-fields th { background: #f4f4f4; font-weight: 600; width: 18%; color: #333; }
.p-section { font-size: 13px; margin: 14px 0 0; }
.p-sign.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; text-align: center; }
.p-sign.three .sign-line { min-width: 0; }

/* ---------- Dashboard alerts ---------- */
.alerts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.alert { display: inline-flex; align-items: center; gap: 4px; padding: 7px 12px; border-radius: 8px; border: 1px solid transparent; color: inherit; font-size: 13px; }
.alert:hover { text-decoration: none; filter: brightness(.97); }
.alert.tone-warn { border-color: #f3d9a4; }
.alert.tone-bad { border-color: #f2c4bf; }
.alert-go { margin-left: 6px; opacity: .6; }

/* ---------- Planning ---------- */
.filters.inline { border-bottom: 1px solid var(--border); }
.card.filters.inline { padding: 12px 16px; }
.meter { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; width: 120px; }
.meter span { display: block; height: 100%; background: var(--good); border-radius: 0 4px 4px 0; }
.meter span.high { background: #d08b16; }
.meter span.over { background: var(--bad); }
.meter-cell { display: flex; align-items: center; gap: 8px; }

/* ---------- Traceability ---------- */
.trace-search { display: flex; gap: 8px; }
.trace { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.trace-step { position: relative; margin: 0 0 16px; }
.trace-dot { position: absolute; left: -26px; top: 18px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid var(--bg); }
.trace-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; }
.trace-body h3 { font-size: 15px; margin-bottom: 4px; }
.trace-body p { margin: 0 0 10px; }
.trace-body > .table-wrap { margin: 0 -18px; }
.trace-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--muted); }

/* ---------- MIS ---------- */
.bar-value { font-size: 11px; color: var(--muted); min-height: 15px; font-variant-numeric: tabular-nums; }
.hbars { list-style: none; margin: 0; padding: 0; }
.hbars li { display: grid; grid-template-columns: minmax(120px, 38%) 1fr 48px; gap: 10px; align-items: center; padding: 5px 0; }
.hbar-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar { height: 12px; background: var(--surface-2); border-radius: 0 4px 4px 0; }
.hbar span { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.hbars strong { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Reports ---------- */
.report-groups { display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; }
.report-group { display: flex; align-items: flex-end; gap: 12px; }
.report-group-title { width: 130px; flex: none; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-bottom: 10px; }
.report-group .tabs { margin-bottom: 0; flex: 1; }

/* ---------- Chat ---------- */
.chat { display: grid; grid-template-columns: 240px 1fr; height: calc(100vh - 190px); min-height: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.chat-side { border-right: 1px solid var(--border); overflow-y: auto; background: var(--surface-2); padding: 8px; }
.chat-side-title { display: flex; justify-content: space-between; align-items: center; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 8px 4px; }
.icon-btn.small { font-size: 16px; padding: 0 6px; }
.chat-channel { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; border-radius: 6px; color: var(--text); }
.chat-channel:hover { background: var(--border); text-decoration: none; }
.chat-channel.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chat-unread { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 7px; }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-head { display: flex; flex-direction: column; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px 16px; }
.chat-msg { padding: 2px 0; }
.chat-msg:not(.grouped) { margin-top: 10px; }
.chat-meta { display: flex; gap: 8px; align-items: baseline; }
.chat-body { position: relative; white-space: pre-wrap; overflow-wrap: anywhere; padding-right: 24px; }
.chat-del { position: absolute; right: 0; top: 0; border: 0; background: none; color: var(--muted); cursor: pointer; opacity: 0; }
.chat-msg:hover .chat-del, .chat-del:focus { opacity: 1; }
.mention { color: var(--info); font-weight: 600; }
.mention.me { background: var(--warn-bg); color: var(--warn); border-radius: 4px; padding: 0 2px; }
.chat-compose { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-compose textarea { resize: none; }
.chat-empty { text-align: center; padding: 40px 0; }

@media (max-width: 820px) {
  .report-group { flex-direction: column; align-items: stretch; gap: 0; }
  .report-group-title { padding: 8px 0 0; }
  .chat { grid-template-columns: 1fr; height: auto; }
  .chat-side { border-right: 0; border-bottom: 1px solid var(--border); max-height: 180px; }
  .chat-messages { height: 55vh; }
  .hbars li { grid-template-columns: 1fr 1fr 40px; }
}

/* ---------- Company branding ---------- */
img.logo.img { object-fit: contain; background: #fff; padding: 3px; }
.logo.big.img { width: auto; height: 64px; background: none; }
.logo.big.img img { height: 100%; max-width: 220px; object-fit: contain; }
.logo-field { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-preview { width: 120px; height: 56px; border: 1px dashed var(--border); border-radius: 8px; display: grid; place-items: center; background: #fff; }
.logo-preview img { max-width: 112px; max-height: 48px; object-fit: contain; }
.logo-field input[type=color] { width: 44px; height: 36px; padding: 2px; }
.logo-field .color-text { width: 110px; }
.p-logo { max-height: 52px; max-width: 180px; object-fit: contain; display: block; margin-bottom: 6px; }

/* ---------- Platform provider (Jissan Technologies) ---------- */
.powered { display: flex; align-items: center; gap: 10px; margin: 8px 16px 0; padding: 10px; border-top: 1px solid rgba(255, 255, 255, .08); color: var(--side-text); font-size: 12.5px; }
.powered:hover { text-decoration: none; color: #fff; }
.powered img { width: 30px; height: 30px; border-radius: 50%; background: #fff; object-fit: contain; flex: none; }
.powered span { display: flex; flex-direction: column; line-height: 1.3; }
.powered small { color: #8b95a5; font-size: 11px; }
.login-page { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.login-powered { display: flex; align-items: center; gap: 8px; color: #d6dae2; font-size: 12.5px; }
.login-powered img { width: 26px; height: 26px; border-radius: 50%; background: #fff; }
.login-powered strong { color: #fff; }
.login-card .logo.big.img { height: 96px; margin: 0 auto 4px; }
body.super .login-card .logo.big.img { height: 150px; }

/* ---------- Super admin pages ---------- */
.card-title { padding: 14px 18px 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.preset-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.preset { border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.module-matrix .center { text-align: center; }
.module-matrix td { vertical-align: middle; }
.module-matrix .group-row td { background: var(--surface-2); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cell-toggle { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 700; color: #fff; }
.cell-toggle:hover { border-color: var(--accent); }
.cell-toggle.on { background: var(--accent); border-color: var(--accent); }
.config-logo { display: flex; align-items: center; gap: 18px; margin-bottom: 14px; }
.config-logo img { width: 120px; height: 120px; object-fit: contain; border: 1px solid var(--border); border-radius: 10px; }
.field[hidden] { display: none; }

/* ---------- Fabrication work flow ---------- */
.fab-select { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 12px 16px; align-items: end; }
.fab-select .span-2 { grid-column: span 2; }
.fab-actions { display: flex; gap: 8px; }
.fab-dates { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.fab-dates input[type=date] { width: auto; }
.fab-progress-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.fab-progress { position: relative; height: 34px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.fab-progress span { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.fab-progress strong { position: relative; display: grid; place-items: center; height: 100%; color: #fff; mix-blend-mode: normal; text-shadow: 0 0 3px rgba(0, 0, 0, .35); }
.fab-tabs a { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.fab-pct { font-size: 11px; color: var(--muted); }
.fab-pct.done { color: var(--good); font-weight: 700; }
.fab-grid .num-input { width: 90px; }
.muted-row td { color: var(--muted); }
@media (max-width: 1100px) { .fab-select { grid-template-columns: 1fr 1fr; } .fab-select .span-2 { grid-column: 1 / -1; } }
