/* Agstic - small design system built on CSS variables (light / dark) */

:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --surface-hover: #f1f3f6;
  --border: #e3e5e9;
  --border-strong: #cfd3da;
  --text: #121417;
  --text-2: #4b5059;
  --muted: #858a93;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: #e6f0fc;
  --danger: #d03b3b;
  --danger-soft: #fdecec;
  --good: #0a7d0a;
  --sidebar: #0f1b2d;
  --sidebar-2: #17263d;
  --sidebar-text: #c6cfdc;
  --sidebar-muted: #7d8aa0;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);
  --grid: #e9e9e4;
  --axis: #c3c2b7;
  /* Series colors (validated categorical palette) */
  --s-blue: #2a78d6; --s-orange: #eb6834; --s-aqua: #1baf7a; --s-yellow: #eda100;
  --s-magenta: #e87ba4; --s-green: #008300; --s-violet: #6250d6; --s-red: #e34948; --s-gray: #8a8f98;
  --radius: 10px;
  --radius-sm: 7px;
  --font: "Segoe UI", Tahoma, system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #0f1012; --surface: #1a1a19; --surface-2: #202020; --surface-hover: #262625;
    --border: #2e2e2c; --border-strong: #3d3d3a; --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8d86;
    --accent: #3987e5; --accent-soft: #1b2b40; --danger: #e66767; --danger-soft: #3a1f1f; --good: #0ca30c;
    --sidebar: #0b0c0d; --sidebar-2: #17191c; --grid: #2c2c2a; --axis: #383835;
    --s-blue: #3987e5; --s-orange: #d95926; --s-aqua: #199e70; --s-yellow: #c98500;
    --s-magenta: #d55181; --s-green: #008300; --s-violet: #9085e9; --s-red: #e66767; --s-gray: #7c7a74;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1012; --surface: #1a1a19; --surface-2: #202020; --surface-hover: #262625;
  --border: #2e2e2c; --border-strong: #3d3d3a; --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8d86;
  --accent: #3987e5; --accent-soft: #1b2b40; --danger: #e66767; --danger-soft: #3a1f1f; --good: #0ca30c;
  --sidebar: #0b0c0d; --sidebar-2: #17191c; --grid: #2c2c2a; --axis: #383835;
  --s-blue: #3987e5; --s-orange: #d95926; --s-aqua: #199e70; --s-yellow: #c98500;
  --s-magenta: #d55181; --s-green: #008300; --s-violet: #9085e9; --s-red: #e66767; --s-gray: #7c7a74;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num, td.num, .tabular { font-variant-numeric: tabular-nums; }
[dir="ltr"] { unicode-bidi: isolate; }

/* ===== Layout ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; text-decoration: none !important; }
.brand strong { display: block; font-size: 17px; letter-spacing: .3px; }
.brand small { display: block; color: var(--sidebar-muted); font-size: 11.5px; margin-top: 1px; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }
.nav-group { margin-top: 14px; }
.nav-group-title { color: var(--sidebar-muted); font-size: 11.5px; font-weight: 600; padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 0;
  color: var(--sidebar-text); background: none; font: inherit; cursor: pointer; text-decoration: none !important; text-align: start;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-badge { margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 10px; background: var(--s-orange); color: #fff; font-size: 11.5px; font-weight: 700; text-align: center; }
.nav-badge[hidden] { display: none; }

/* Account statement (Cari Ekstre) */
.st-toolbar .card-body { display: grid; gap: 10px; }
.st-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.st-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.st-account { min-width: 280px; max-width: 420px; }
.st-search { width: 260px; }
.st-date { width: 170px; }
.st-date[hidden] { display: none; }
.st-code { font-variant-numeric: tabular-nums; letter-spacing: .3px; color: var(--text-2); }
.st-group { overflow: hidden; }
.st-group-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; width: 100%; padding: 12px 16px; border: 0; background: var(--surface-2);
  color: var(--text); font: inherit; cursor: pointer; text-align: start; }
.st-group-head:hover { background: var(--surface-hover); }
.st-caret { display: inline-block; width: 14px; color: var(--muted); transition: transform .15s; }
.st-caret.open { transform: rotate(90deg); }
.st-chip { margin-left: 12px; font-size: 13px; }
.st-opening td { background: var(--surface-2); }
/* Payment matching: green = paid / linked, amber = partly, red = unpaid / not linked */
.st-detail tr.st-m-full td:first-child { box-shadow: inset 4px 0 0 var(--s-aqua); }
.st-detail tr.st-m-partial td:first-child { box-shadow: inset 4px 0 0 var(--s-yellow); }
.st-detail tr.st-m-none td:first-child { box-shadow: inset 4px 0 0 var(--s-red); }
.match-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 280px; padding: 3px 9px; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-chip .icon { width: 14px; height: 14px; }
.match-chip span { font-weight: 600; }
.match-chip.m-full { background: color-mix(in srgb, var(--s-aqua) 16%, transparent); color: var(--good); border-color: color-mix(in srgb, var(--s-aqua) 40%, transparent); }
.match-chip.m-partial { background: color-mix(in srgb, var(--s-yellow) 18%, transparent); color: var(--s-yellow); border-color: color-mix(in srgb, var(--s-yellow) 45%, transparent); }
.match-chip.m-none { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.match-chip:hover { filter: brightness(1.1); text-decoration: underline; }
.match-chip.m-draft { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.st-detail tr.st-m-draft td { color: var(--muted); font-style: italic; }
.st-detail tr.st-m-draft td:first-child { box-shadow: inset 4px 0 0 var(--border-strong); }
.modal.match-modal { width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; }
.match-head { margin-bottom: 12px; }
.match-head h3 { margin: 0 0 4px; }
.match-section { margin-top: 14px; }
.match-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 6px; }
.match-amount { width: 130px; text-align: right; }
.match-summary { margin-right: auto; font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.match-done { display: flex; gap: 8px; align-items: center; margin-top: 14px; color: var(--good); font-weight: 600; }
.modal.match-modal .actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
@media print { .match-chip { border: 0; background: none !important; padding: 0; } }
@media print {
  .st-toolbar, .st-search, .page-head .actions, .back-link { display: none !important; }
  .st-group-head { background: none; }
}

/* e-Invoice "Link to shipment" panel */
.ei-link { border-color: var(--accent); }
.ei-body { display: grid; gap: 16px; }
.ei-step { display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.ei-num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.ei-step-body { min-width: 0; display: grid; gap: 6px; }
.ei-step-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.ei-booking { max-width: 760px; }
.ei-open { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; width: max-content; }
.ei-lines td:first-child, .ei-lines th:first-child { width: 34px; }
.ei-foot { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 12px; }
.ei-total { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 13.5px; }

/* e-Invoicing */
.info-card .card-body, .alert-card .card-body { display: flex; align-items: flex-start; gap: 10px; color: var(--text-2); line-height: 1.55; }
.info-card .icon { color: var(--accent); margin-top: 1px; }
.alert-card { border-color: var(--danger); background: var(--danger-soft); }
.alert-card .icon { color: var(--danger); margin-top: 1px; }
.check-bar { display: flex; gap: 10px; align-items: center; }
.check-bar input { max-width: 320px; font-size: 16px; letter-spacing: .5px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.detail-grid .muted { font-size: 12px; }
.match-card .card-body { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; display: flex; align-items: center; gap: 14px; padding: 0 24px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.menu-toggle { display: none; }
.crumbs { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs b { color: var(--text); font-weight: 600; }
.global-search input { width: 300px; }
.view { padding: 22px 24px 40px; max-width: 1500px; width: 100%; margin: 0 auto; }

/* ===== Controls ===== */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 7px 10px; min-height: 36px; width: 100%; outline: none; transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--accent); }
input[type="number"] { text-align: right; }

.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: none; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }

/* ===== Page header ===== */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; margin: 0; font-weight: 700; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .spacer { flex: 1; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }

/* ===== Cards ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-head .hint { color: var(--muted); font-size: 12.5px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px 18px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--s-gray)); }
.badge.c-blue { --dot: var(--s-blue); } .badge.c-orange { --dot: var(--s-orange); } .badge.c-aqua { --dot: var(--s-aqua); }
.badge.c-yellow { --dot: var(--s-yellow); } .badge.c-magenta { --dot: var(--s-magenta); } .badge.c-green { --dot: var(--s-green); }
.badge.c-violet { --dot: var(--s-violet); } .badge.c-red { --dot: var(--s-red); } .badge.c-gray { --dot: var(--s-gray); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; user-select: none; }
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text); }
table.data th .arrow { font-size: 10px; margin-inline-start: 4px; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.strong { font-weight: 600; }
table.data tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
.pos { color: var(--good); } .neg { color: var(--danger); }
.empty { padding: 48px 18px; text-align: center; color: var(--muted); }

.list-toolbar { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.list-toolbar input[type="search"] { max-width: 320px; }
.list-toolbar select, .list-toolbar input[type="date"] { width: auto; min-width: 140px; }
.list-foot { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.list-foot .spacer { flex: 1; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.half { grid-column: span 2; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field label .req { color: var(--danger); margin-inline-start: 2px; }
.field .hint { font-size: 11.5px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; }

.summary-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.summary-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.summary-item .label { font-size: 12px; color: var(--muted); }
.summary-item .value { font-size: 19px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }

.grid-edit { width: 100%; border-collapse: collapse; }
.grid-edit th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: start; padding: 8px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.grid-edit td { padding: 5px 4px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.grid-edit td input, .grid-edit td select { min-height: 32px; padding: 5px 8px; min-width: 90px; }
.grid-edit td select { min-width: 130px; }
.grid-edit td.calc { color: var(--text-2); font-weight: 600; padding-inline: 10px; white-space: nowrap; }
.grid-edit tr:last-child td { border-bottom: 0; }
.grid-foot { padding: 10px 12px; display: flex; gap: 10px; align-items: center; }

/* ===== Dashboard ===== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; }
.kpi .value { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.kpi .label svg { width: 16px; height: 16px; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -.3px; }
.kpi .foot { font-size: 12px; color: var(--muted); margin-top: 3px; }
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-grid.even { grid-template-columns: 1fr 1fr; }
.dash-grid > *, .kpis > *, .stack > * { min-width: 0; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar-hit { fill: transparent; cursor: default; }
.chart .bar-hit:hover { fill: var(--surface-hover); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12.5px; min-width: 150px; z-index: 5; display: none;
}
.tooltip .t-title { font-weight: 700; margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.tooltip .t-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 150px) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.hbar .val { white-space: nowrap; min-width: 40px; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; background: var(--s-blue); }
.hbar .val { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ===== Toasts & dialogs ===== */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); font-weight: 600;
  animation: toast-in .18s ease-out; max-width: 420px;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: #0a7d0a; color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); display: grid; place-items: center; z-index: 90; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(440px, calc(100vw - 32px)); padding: 22px; }
.modal h3 { margin: 0 0 8px; font-size: 16px; }
.modal p { margin: 0 0 18px; color: var(--text-2); line-height: 1.6; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-start; }
@keyframes fade { from { opacity: 0; } }

.loading { padding: 60px; text-align: center; color: var(--muted); }
.changes { font-size: 12.5px; }
.changes td { padding: 4px 8px; border-bottom: 1px solid var(--border); }

/* ===== Top bar "viewing as" ===== */
.viewing-as { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.viewing-as select { width: 190px; min-height: 34px; padding: 5px 8px; }
.lang-pick { gap: 6px; }
.lang-pick .icon { width: 16px; height: 16px; }
.lang-pick select { width: auto; min-width: 96px; }

/* ===== Tabs / segmented control ===== */
.tabs { display: flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; font: inherit; font-weight: 600; color: var(--text-2); padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.filters-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters-row select { width: auto; min-width: 130px; }
.muted { color: var(--muted); }

/* ===== Compact (AuroSoft-style) record header ===== */
.form-compact { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.25fr); gap: 0 20px; padding: 14px 16px 12px; }
.fc-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fc-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding-bottom: 4px; border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.fc-row { display: grid; grid-template-columns: 108px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 32px; }
.fc-row label { font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-row input:not([type="checkbox"]), .fc-row select { min-height: 31px; padding: 4px 8px; }
.fc-row textarea { min-height: 54px; padding: 6px 8px; }
.fc-notes { padding: 0 16px 14px; }
.form-compact.cols-1 { grid-template-columns: minmax(0, 640px); }
.form-compact.cols-2 { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 0 32px; }
.form-compact.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fc-row.top { align-items: start; }
.fc-row.top label { padding-top: 6px; }
.fc-checkgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 14px; padding: 4px 0 8px; }
.fc-checkgrid .fc-check { font-weight: 500; }
.radio-group { display: flex; gap: 18px; align-items: center; min-height: 31px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.radio { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.radio input { width: 16px; min-height: 16px; height: 16px; accent-color: var(--accent); }

/* Form tabs (company card: Company info · Contacts · Accounting ...) */
.form-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-strong); }
.form-tabs button {
  border: 1px solid transparent; border-bottom: 0; background: none; font: inherit; font-weight: 600; color: var(--text-2);
  padding: 8px 14px; border-radius: 8px 8px 0 0; cursor: pointer; margin-bottom: -1px;
}
.form-tabs button:hover { color: var(--text); }
.form-tabs button.active { background: var(--surface); border-color: var(--border-strong); border-bottom: 1px solid var(--surface); color: var(--text); }
.form-tab-panel[hidden] { display: none; }

/* Full form in a popup (e.g. new company from a booking) */
.modal.xl { width: min(1080px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; padding: 18px 20px; background: var(--bg); }
.modal-form .page-head { margin-bottom: 12px; }
/* Generator section (document tools on the booking page) */
.generator-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.gen-tile {
  display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; text-align: left;
  padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface);
  font: inherit; color: var(--text); cursor: pointer; transition: border-color .12s, background .12s;
}
.gen-tile:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.gen-tile:disabled { opacity: .55; cursor: default; }
.gen-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.gen-icon svg { width: 20px; height: 20px; }
.gen-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gen-text small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.gen-go { font-size: 12.5px; font-weight: 700; color: var(--accent); white-space: nowrap; }

/* B/L draft & proforma print layouts */
.doc-watermark { position: relative; }
.doc-watermark::after { content: "DRAFT"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 120px; font-weight: 800; color: rgba(200, 0, 0, .07); transform: rotate(-24deg); pointer-events: none; }
.bl-grid { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid #222; margin-bottom: 14px; }
.bl-box { border: 1px solid #999; padding: 8px 10px; min-height: 62px; font-size: 13px; line-height: 1.5; }
.bl-box.span2 { grid-column: 1 / -1; }
.bl-box .lbl { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: #555; margin-bottom: 3px; }
.bl-box b { font-size: 13.5px; }
.bl-row3 { display: grid; grid-template-columns: repeat(3, 1fr); grid-column: 1 / -1; }
.bl-row3 .bl-box { border-width: 1px; }
.doc-note { margin-top: 18px; font-size: 12.5px; color: #555; }
.fc-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 22px; margin: 0 16px 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.fc-checks .fc-title { border: 0; padding: 0; margin: 0 6px 0 0; }
.fc-check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; white-space: nowrap; }
.fc-row label.quick-add, .field label.quick-add { color: var(--accent); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.fc-row label.quick-add:hover, .field label.quick-add:hover { text-decoration-style: solid; }
.with-btn { display: flex; gap: 6px; min-width: 0; }
.with-btn input { flex: 1; min-width: 0; }
.with-btn .btn { height: 31px; width: 34px; padding: 0; justify-content: center; flex: none; }
.fc-row input[type="datetime-local"] { font-size: 13px; padding: 4px 6px; }
.modal.wide { width: min(640px, calc(100vw - 32px)); }
.quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 6px; }
.fc-notes .fc-row { grid-template-columns: 108px minmax(0, 1fr); align-items: start; }

/* Charge grids */
.grid-card .card-head { padding: 10px 14px; }
.grid-totals { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.grid-edit th.num { text-align: right; }
.grid-edit td.t-number input, .grid-edit td.t-money input, .grid-edit td.t-int input { min-width: 0; width: 92px; text-align: right; }
/* number cells line up under their right-aligned headings */
.grid-edit td.t-number, .grid-edit td.t-money, .grid-edit td.t-int { text-align: right; }
.grid-edit td.t-date input { min-width: 0; width: 138px; }
.grid-edit td.t-text input { min-width: 110px; }
.grid-edit td.calc { text-align: right; font-variant-numeric: tabular-nums; }
.grid-edit tr.locked td { background: var(--surface-2); }
.grid-edit.hide-c-commodity .c-commodity, .grid-edit.hide-c-hs_code .c-hs_code { display: none; }
.grid-edit td.c-hs_code input { min-width: 110px; }
.grid-toggle-input.sm { width: 150px; margin-left: 8px; }
.grid-card .card-head { flex-wrap: wrap; row-gap: 8px; }
.grid-edit td.c-commodity input { min-width: 180px; }
.grid-toggle { margin-left: 14px; font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.grid-toggle-input { margin-left: 10px; width: 240px; max-width: 40%; height: 28px; padding: 0 8px; font: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface, #fff); color: inherit; }
.grid-toggle-input[hidden] { display: none; }
.grid-totals { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.grid-totals b { color: var(--text-1, inherit); font-weight: 600; }
.grid-edit tr.locked input, .grid-edit tr.locked select { color: var(--text-2); }

@media (max-width: 1280px) { .form-compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 22px; } }
@media (max-width: 820px) { .form-compact { grid-template-columns: 1fr; } }

.cancel-banner { border-color: var(--danger); background: var(--danger-soft); }
.cancel-banner b { color: var(--danger); }

/* ===== Stage bar (bookings pipeline) ===== */
.stagebar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.stage {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font: inherit; font-weight: 600; cursor: pointer;
}
.stage:hover { background: var(--surface-hover); color: var(--text); }
.stage.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.stage .count { font-size: 12px; font-weight: 600; padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-variant-numeric: tabular-nums; }
.stage.active .count { background: rgba(255,255,255,.22); color: #fff; }
.stage .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--s-gray)); }
.dot.c-blue { --dot: var(--s-blue); } .dot.c-orange { --dot: var(--s-orange); } .dot.c-aqua { --dot: var(--s-aqua); }
.dot.c-yellow { --dot: var(--s-yellow); } .dot.c-green { --dot: var(--s-green); } .dot.c-violet { --dot: var(--s-violet); }
.dot.c-red { --dot: var(--s-red); } .dot.c-gray { --dot: var(--s-gray); }
.stage.active .dot { box-shadow: 0 0 0 2px rgba(255,255,255,.7); }

/* ===== Screen tabs (one tab per open screen, like AuroSoft) ===== */
.tabstrip {
  display: flex; align-items: flex-end; gap: 2px; padding: 8px 16px 0; background: var(--bg);
  border-bottom: 1px solid var(--border); position: sticky; top: 58px; z-index: 19; overflow-x: auto; scrollbar-width: thin;
}
.screen-tab {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 6px 0 12px; max-width: 230px; flex: none;
  border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface-2);
  color: var(--text-2); font: inherit; font-size: 13px; cursor: pointer; margin-bottom: -1px; user-select: none;
}
.screen-tab:hover { color: var(--text); background: var(--surface-hover); }
.screen-tab.active { background: var(--surface); color: var(--text); font-weight: 600; border-color: var(--border-strong); border-bottom: 1px solid var(--surface); }
.screen-tab .t-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-tab svg { width: 15px; height: 15px; flex: none; }
.screen-tab .t-close { width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 5px; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; flex: none; }
.screen-tab .t-close:hover { background: var(--danger-soft); color: var(--danger); }
.screen-tab .t-close svg { width: 13px; height: 13px; }
.tabstrip .spacer { flex: 1; }
.tabstrip .tab-tools { display: flex; gap: 2px; padding-bottom: 4px; flex: none; }
.tab-page[hidden] { display: none; }

/* ===== Task board ===== */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); min-height: 200px; }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-weight: 700; }
.board-col-head .count { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; font-size: 12px; color: var(--text-2); }
.board-col-body { display: flex; flex-direction: column; gap: 10px; padding: 0 10px 12px; }
.task-card { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; border-left: 3px solid var(--prio, var(--s-blue)); }
.task-card.p-urgent { --prio: var(--s-red); } .task-card.p-high { --prio: var(--s-orange); }
.task-card.p-normal { --prio: var(--s-blue); } .task-card.p-low { --prio: var(--s-gray); }
.task-card .t-title { font-weight: 600; line-height: 1.35; color: var(--text); text-decoration: none; }
.task-card .t-title:hover { color: var(--accent); }
.task-card .t-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; color: var(--text-2); align-items: center; }
.task-card .t-meta span { display: inline-flex; align-items: center; gap: 4px; }
.task-card .t-meta svg { width: 14px; height: 14px; }
.task-card .t-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.due { font-weight: 600; }
.due.overdue { color: var(--danger); }
.due.soon { color: var(--s-orange); }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.chip.auto { color: var(--s-violet); }
.roles-table td { white-space: normal; vertical-align: top; }
.roles-table .chip { margin: 0 4px 4px 0; }
.chip.muted { opacity: .75; font-weight: 500; }

/* Sign-in */
.app[hidden] { display: none; }
.auth-screen { min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 14px; padding: 24px 16px; background: var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 28px; }
.auth-card h1 { font-size: 20px; margin: 18px 0 6px; }
.auth-card > p { margin: 0 0 6px; line-height: 1.5; font-size: 13.5px; }
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand strong { display: block; font-size: 18px; }
.auth-brand small { color: var(--muted); font-size: 12px; }
.auth-form { display: grid; gap: 12px; margin-top: 14px; }
.auth-field { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.auth-field input { min-height: 40px; font-size: 15px; }
.auth-form .btn.primary { justify-content: center; min-height: 40px; font-size: 14.5px; }
.auth-error { color: var(--danger); font-size: 13px; min-height: 18px; }
.auth-foot select { width: auto; }
.modal .auth-form .actions { justify-content: flex-end; }

/* Signed-in user (top bar) */
.user-menu { position: relative; }
.user-button { display: flex; align-items: center; gap: 9px; padding: 4px 10px 4px 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.user-button:hover { background: var(--surface-hover); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-text { display: grid; text-align: start; line-height: 1.15; }
.user-text b { font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-text small { font-size: 11.5px; color: var(--muted); }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; display: grid; }
.user-dropdown[hidden] { display: none; }
.user-dropdown button { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border: 0; border-radius: 7px; background: none; color: var(--text); font: inherit; cursor: pointer; text-align: start; }
.user-dropdown button:hover { background: var(--surface-hover); }
@media (max-width: 820px) { .user-text { display: none; } }

/* ===== Reports ===== */
table.report th.sticky, table.report td.sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.report th.sticky { background: var(--surface-2); z-index: 2; }
table.report tbody tr:hover td.sticky { background: var(--surface-hover); }
table.report td.zero { color: var(--muted); }
table.report th.group-start, table.report td.group-start { border-left: 1px solid var(--border-strong); }
.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.rule { border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }

/* ===== Print ===== */
.print-page { background: #fff; color: #111; max-width: 820px; margin: 0 auto; padding: 40px 44px; border-radius: var(--radius); box-shadow: var(--shadow); }
.print-page h1 { margin: 0; font-size: 24px; }
.print-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #111; padding-bottom: 16px; margin-bottom: 18px; }
.print-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; margin-bottom: 18px; font-size: 13.5px; }
.print-meta div span { color: #666; margin-inline-end: 6px; }
.print-page table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.print-page th, .print-page td { border-bottom: 1px solid #ddd; padding: 8px; text-align: start; }
.print-page th { background: #f3f3f3; }
.print-page .totals { margin-top: 14px; margin-inline-start: auto; width: 280px; }
.print-page .totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.print-page .totals .grand { font-weight: 700; font-size: 16px; border-top: 2px solid #111; margin-top: 4px; padding-top: 8px; }
.print-toolbar { max-width: 820px; margin: 0 auto 14px; display: flex; gap: 8px; }

@media print {
  .sidebar, .topbar, .tabstrip, .print-toolbar, .toasts { display: none !important; }
  .view { padding: 0; max-width: none; }
  body { background: #fff; }
  .print-page { box-shadow: none; padding: 0; max-width: none; }
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .dash-grid, .dash-grid.even, .board { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; inset-block: 0; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .viewing-as span { display: none; }
  .viewing-as select { width: 120px; }
  .lang-pick select { width: auto; min-width: 0; }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .menu-toggle { display: inline-grid; }
  .global-search input { width: 160px; }
  .topbar { padding: 0 16px; }
  .view { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.half { grid-column: auto; }
}

/* Tools → Invoice generator preview (page built by the server, same as the PDF) */
.tool-invoice-frame { display: block; width: 100%; max-width: 820px; height: 1180px; margin: 0 auto; border: 0; border-radius: 6px; background: #fff; box-shadow: 0 2px 14px rgba(0,0,0,.18); }

