/* Dispatch Global Portal - interface styles.
   Colours, radius and font come from CSS variables set by the admin in Branding. */

@font-face { font-family: "Fira Sans"; src: url("../fonts/FiraSans-Regular.woff") format("woff"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("../fonts/FiraSans-Italic.woff") format("woff"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("../fonts/FiraSans-Medium.woff") format("woff"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("../fonts/FiraSans-SemiBold.woff") format("woff"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url("../fonts/FiraSans-Bold.woff") format("woff"); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --primary: #1E1E66;
  --primary-soft: #e9e9f0;
  --primary-deep: #16164c;
  --accent: #5F7EEC;
  --accent-soft: #e5ebfc;
  --accent-ink: #4c65bd;
  --on-primary: #fff;
  --canvas: #f2f4f8;
  --paper: #ffffff;
  --paper-2: #f8f9fb;
  --rule: #e0e4ec;
  --rule-strong: #c9d0dc;
  --ink: #171a2c;
  --ink-2: #4b5168;
  --ink-3: #767e95;
  --good: #16794a; --good-soft: #e3f2ea;
  --warn: #9a5b00; --warn-soft: #fbefd9;
  --bad: #b3362e;  --bad-soft: #fbe6e4;
  --info: var(--accent-ink); --info-soft: var(--accent-soft);
  --radius: 6px;
  --font: "Fira Sans", "IBM Plex Sans", "Segoe UI", Roboto, "Noto Sans Arabic", "DejaVu Sans", Arial, sans-serif;
  --row-h: 44px;
  --pad: 16px;
  --shadow-pop: 0 10px 30px rgba(23, 26, 44, .14), 0 2px 6px rgba(23, 26, 44, .08);
  --sidebar-w: 244px;
}
body.density-compact { --row-h: 36px; --pad: 12px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink);
  background: var(--canvas); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 18px 0; }
code, .mono { font-family: "DejaVu Sans Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; }
.num, td.num, th.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.nowrap { white-space: nowrap; }
.right { text-align: right; } .center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
svg.i.sm { width: 15px; height: 15px; vertical-align: -3px; }
svg.i.lg { width: 22px; height: 22px; }

/* ------------------------------------------------------------ shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; background: linear-gradient(to right, var(--primary) var(--sidebar-w), var(--canvas) var(--sidebar-w)); }
body.sidebar-light .app { background: linear-gradient(to right, var(--paper) var(--sidebar-w), var(--canvas) var(--sidebar-w)); }
body.sidebar-dark .app { background: linear-gradient(to right, #15171f var(--sidebar-w), var(--canvas) var(--sidebar-w)); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--primary); color: var(--on-primary);
  display: flex; flex-direction: column; padding: 14px 10px 12px; scrollbar-width: thin;
}
.sidebar .brandblock { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: inherit; text-decoration: none; }
.sidebar .brandblock img { width: 34px; height: 34px; border-radius: 8px; background: #fff; padding: 3px; object-fit: contain; }
.sidebar .brandblock .t1 { font-weight: 600; font-size: 15px; line-height: 1.15; }
.sidebar .brandblock .t2 { font-size: 11.5px; opacity: .65; }
.sidebar .navgroup { margin-top: 10px; }
.sidebar .navgroup > .label { font-size: 11.5px; opacity: .55; padding: 6px 10px 4px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin: 1px 0; border-radius: var(--radius);
  color: inherit; opacity: .82; text-decoration: none; font-size: 13.5px; position: relative;
}
.sidebar nav a:hover { opacity: 1; background: rgba(255,255,255,.07); }
.sidebar nav a.active { opacity: 1; background: rgba(255,255,255,.12); font-weight: 500; }
.sidebar nav a.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.sidebar nav a .count { margin-left: auto; font-size: 11px; background: var(--accent); color: #fff; border-radius: 9px; padding: 0 6px; line-height: 17px; }
.sidebar .foot { margin-top: auto; padding: 14px 10px 0; font-size: 11.5px; opacity: .5; }
body.sidebar-light .sidebar { background: var(--paper); color: var(--ink); border-right: 1px solid var(--rule); }
body.sidebar-light .sidebar .brandblock img { background: transparent; }
body.sidebar-light .sidebar nav a:hover { background: var(--paper-2); }
body.sidebar-light .sidebar nav a.active { background: var(--primary-soft); color: var(--primary); }
body.sidebar-dark .sidebar { background: #15171f; color: #e8eaf0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 24px; background: rgba(255,255,255,.94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--rule);
}
.topbar .menu-toggle { display: none; }
.search { position: relative; flex: 1; max-width: 460px; }
.search input, .search input[type=search] { width: 100%; height: 36px; padding: 0 12px 0 36px; border-radius: var(--radius); border: 1px solid var(--rule); background: var(--paper-2); font: inherit; color: inherit; }
.search input:focus { background: #fff; border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.search > svg { position: absolute; left: 11px; top: 9px; color: var(--ink-3); }
.search .results { position: absolute; top: 42px; left: 0; right: 0; background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-pop); max-height: 420px; overflow: auto; }
.search .results a { display: flex; gap: 10px; padding: 9px 12px; color: var(--ink); border-bottom: 1px solid var(--rule); align-items: baseline; }
.search .results a:last-child { border-bottom: 0; }
.search .results a:hover, .search .results a.sel { background: var(--accent-soft); text-decoration: none; }
.search .results .kind { font-size: 11.5px; color: var(--ink-3); width: 82px; flex: none; }
.topbar .spacer { flex: 1; }
.iconbtn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius); border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer; }
.iconbtn:hover { background: var(--paper-2); border-color: var(--rule); }
.iconbtn .dot { position: absolute; top: 5px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10.5px; line-height: 16px; text-align: center; font-weight: 600; }
.usermenu-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border: 1px solid transparent; border-radius: 22px; background: none; cursor: pointer; font: inherit; color: var(--ink); }
.usermenu-btn:hover { background: var(--paper-2); border-color: var(--rule); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; background: var(--primary-soft); color: var(--primary); flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }

.dropdown { position: relative; }
.dropdown .menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 6px; z-index: 50; display: none; }
.dropdown.open .menu { display: block; }
.dropdown .menu a, .dropdown .menu button { display: flex; width: 100%; gap: 9px; align-items: center; padding: 8px 10px; border-radius: 4px; color: var(--ink); background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }
.dropdown .menu a:hover, .dropdown .menu button:hover { background: var(--paper-2); text-decoration: none; }
.dropdown .menu .sep { height: 1px; background: var(--rule); margin: 6px 0; }
.dropdown .menu .head { padding: 8px 10px; font-size: 12.5px; color: var(--ink-3); }
.notif-menu { width: 360px; max-height: 460px; overflow: auto; }
.notif-menu .n { display: block !important; padding: 10px !important; border-bottom: 1px solid var(--rule) !important; border-radius: 0 !important; }
.notif-menu .n.unread { background: var(--accent-soft); }
.notif-menu .n .t { font-weight: 500; }
.notif-menu .n .b { font-size: 12.5px; color: var(--ink-2); }
.notif-menu .n .w { font-size: 11.5px; color: var(--ink-3); }

.content { padding: 22px 28px 48px; max-width: 1480px; width: 100%; }
.content.wide { max-width: none; }

/* ------------------------------------------------------------ page header */
.pagehead { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.pagehead .titles { flex: 1; min-width: 240px; }
.pagehead .crumbs { font-size: 12.5px; color: var(--ink-3); margin-bottom: 4px; }
.pagehead .crumbs a { color: var(--ink-3); }
.pagehead .sub { color: var(--ink-2); margin-top: 4px; }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pagehead h1 .badge { vertical-align: 3px; margin-left: 6px; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid var(--rule-strong); background: #fff; color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; line-height: 1;
}
.btn:hover { background: var(--paper-2); text-decoration: none; }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-deep); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: var(--accent-ink); }
.btn.danger { color: var(--bad); border-color: #e7c3bf; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.good { background: var(--good); border-color: var(--good); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--paper-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12.5px; gap: 5px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btngroup { display: inline-flex; }
.btngroup .btn { border-radius: 0; margin-left: -1px; }
.btngroup .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btngroup .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btngroup .btn.on { background: var(--primary-soft); color: var(--primary); border-color: var(--rule-strong); }
form.inline { display: inline; }

/* ------------------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; line-height: 19px; white-space: nowrap; background: var(--paper-2); color: var(--ink-2); border: 1px solid var(--rule); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.tone-good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.tone-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.tone-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.tone-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.tone-muted { color: var(--ink-3); }
.badge.plain::before { display: none; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 4px; background: var(--paper-2); border: 1px solid var(--rule); font-size: 12px; color: var(--ink-2); }

/* ------------------------------------------------------------ panels */
.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); margin-bottom: 18px; }
.panel > .ph { display: flex; align-items: center; gap: 10px; padding: 12px var(--pad); border-bottom: 1px solid var(--rule); min-height: 50px; }
.panel > .ph h2 { flex: 1; font-size: 14.5px; }
.panel > .ph .tools { display: flex; gap: 6px; align-items: center; }
.panel > .pb { padding: var(--pad); }
.panel > .pf { padding: 10px var(--pad); border-top: 1px solid var(--rule); background: var(--paper-2); border-radius: 0 0 var(--radius) var(--radius); }
.panel.flush > .pb { padding: 0; }
.grid { display: grid; gap: 18px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid.side-l { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.grid > .panel { margin-bottom: 0; }
.stack > * + * { margin-top: 18px; }

/* key figures: one ruled strip, not separate cards */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); margin-bottom: 18px; }
.figures .f { padding: 14px 18px 15px; border-left: 1px solid var(--rule); min-width: 0; }
.figures .f:first-child { border-left: 0; }
.figures .f .k { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.figures .f .v { font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }
.figures .f .v small { font-size: 12.5px; font-weight: 500; color: var(--ink-3); margin-left: 3px; }
.figures .f .d { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* definition lists */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; }
.dl dt { color: var(--ink-3); font-size: 13px; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ tables */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: 12.5px; background: var(--paper-2); padding: 9px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
table.t td { padding: 0 12px; height: var(--row-h); border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.t td.wrap { padding-top: 9px; padding-bottom: 9px; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr[data-href] { cursor: pointer; }
table.t tbody tr[data-href]:hover td, table.t tbody tr.hl td { background: #f7f9fe; }
table.t td .sub { display: block; font-size: 12px; color: var(--ink-3); margin-top: 1px; }
table.t tfoot td { font-weight: 600; background: var(--paper-2); border-top: 1px solid var(--rule-strong); height: 40px; }
table.t th a { color: inherit; }
table.t .actions { text-align: right; white-space: nowrap; }
table.t .actions .btn { margin-left: 4px; }
table.t td.ref { font-weight: 500; white-space: nowrap; }
table.t.compact td { height: 36px; }

/* filters bar */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px var(--pad); border-bottom: 1px solid var(--rule); }
.filters input, .filters select { height: 32px; font-size: 13px; }
.filters .grow { flex: 1; min-width: 180px; max-width: 320px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rule); margin-bottom: 16px; overflow-x: auto; }
.panel > .tabs { margin: 0; padding: 0 var(--pad); }
.tabs a, .tabs button { padding: 10px 12px; color: var(--ink-2); border: 0; background: none; font: inherit; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--ink); text-decoration: none; }
.tabs a.on, .tabs button.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.tabs .count { font-size: 11.5px; color: var(--ink-3); margin-left: 4px; }

.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px var(--pad); border-top: 1px solid var(--rule); font-size: 13px; color: var(--ink-2); }

/* ------------------------------------------------------------ forms */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .w-12 { grid-column: span 12; } .form-grid .w-9 { grid-column: span 9; } .form-grid .w-8 { grid-column: span 8; }
.form-grid .w-6 { grid-column: span 6; } .form-grid .w-4 { grid-column: span 4; } .form-grid .w-3 { grid-column: span 3; }
.form-grid .w-2 { grid-column: span 2; }
.form-grid .section { grid-column: span 12; font-weight: 600; padding-top: 8px; border-top: 1px solid var(--rule); margin-top: 6px; }
.form-grid .section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.field label, label.lbl { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
.field .req { color: var(--bad); }
.field .help { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.field .err { font-size: 12.5px; color: var(--bad); margin-top: 4px; }
.field.has-err input, .field.has-err select, .field.has-err textarea { border-color: var(--bad); }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=url], input[type=search], input[type=month], input[type=week], select, textarea {
  width: 100%; height: 36px; padding: 0 10px; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
}
textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
select { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23767e95' stroke-width='2.4'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: #fff; cursor: pointer; }
input[type=file] { font: inherit; font-size: 13px; }
input[readonly] { background: var(--paper-2); color: var(--ink-2); }
.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--primary); }
.formfoot { display: flex; gap: 8px; justify-content: flex-end; padding-top: 16px; margin-top: 18px; border-top: 1px solid var(--rule); }
.inputgroup { display: flex; }
.inputgroup > * { border-radius: 0 !important; margin-left: -1px; }
.inputgroup > *:first-child { border-radius: var(--radius) 0 0 var(--radius) !important; margin-left: 0; }
.inputgroup > *:last-child { border-radius: 0 var(--radius) var(--radius) 0 !important; }
.inputgroup .addon { display: flex; align-items: center; padding: 0 10px; background: var(--paper-2); border: 1px solid var(--rule-strong); color: var(--ink-3); font-size: 13px; white-space: nowrap; }

/* ------------------------------------------------------------ alerts */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; font-size: 13.5px; }
.flash.success { background: var(--good-soft); border-color: #bfe0cd; color: #0f5233; }
.flash.error { background: var(--bad-soft); border-color: #efc4bf; color: #7d221c; }
.flash.info { background: var(--accent-soft); border-color: #cbd6f8; color: #2c3f86; }
.flash.warn { background: var(--warn-soft); border-color: #f0d9ac; color: #6b4000; }
.flash .x { margin-left: auto; background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; padding: 0; }
.note { padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0; font-size: 13px; color: var(--ink-2); }
.note.warn { border-color: var(--warn); background: var(--warn-soft); }

.empty { text-align: center; padding: 42px 20px; color: var(--ink-2); }
.empty .ic { width: 46px; height: 46px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.empty h3 { font-size: 15px; margin-bottom: 4px; color: var(--ink); }
.empty p { max-width: 420px; margin: 0 auto 14px; }

/* ------------------------------------------------------------ lists & misc */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: center; padding: 10px var(--pad); border-bottom: 1px solid var(--rule); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .t { font-weight: 500; }
.list .s { font-size: 12.5px; color: var(--ink-3); }
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 13.5px; }
.feed li:last-child { border-bottom: 0; }
.feed .w { font-size: 12px; color: var(--ink-3); }
.bar { height: 6px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.good > span { background: var(--good); }
.kbd { font-size: 11.5px; padding: 1px 5px; border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--ink-3); }
.files { list-style: none; padding: 0; margin: 0; }
.files li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 13.5px; }
.files li:last-child { border-bottom: 0; }
.files .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* modal (native dialog) */
dialog.modal { border: 0; border-radius: calc(var(--radius) + 2px); padding: 0; width: min(560px, 94vw); box-shadow: var(--shadow-pop); color: var(--ink); }
dialog.modal.wide { width: min(860px, 96vw); }
dialog.modal::backdrop { background: rgba(23, 26, 44, .42); }
dialog.modal .mh { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--rule); }
dialog.modal .mh h2 { flex: 1; font-size: 15px; }
dialog.modal .mb { padding: 18px; max-height: 70vh; overflow: auto; }
dialog.modal .mf { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--rule); background: var(--paper-2); }

/* charts */
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--ink-3); }
.chart .gridline { stroke: var(--rule); stroke-width: 1; }
.chart .bar-a { fill: var(--primary); }
.chart .bar-b { fill: var(--accent); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 150px 1fr 110px; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; }
.hbar .track { height: 10px; background: var(--paper-2); border-radius: 2px; overflow: hidden; border: 1px solid var(--rule); }
.hbar .track span { display: block; height: 100%; background: var(--primary); }
.hbar .track span.b { background: var(--accent); }

/* login */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); }
.auth .art { background: var(--primary); color: var(--on-primary); padding: 48px 56px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth .art .logo { background: #fff; border-radius: 10px; padding: 12px 16px; display: inline-block; align-self: flex-start; }
.auth .art .logo img { height: 64px; display: block; }
.auth .art h1 { font-size: 34px; line-height: 1.15; max-width: 520px; margin-top: auto; font-weight: 600; }
.auth .art p { max-width: 460px; opacity: .75; margin-top: 12px; font-size: 15px; }
.auth .art .rings { position: absolute; right: -160px; top: -120px; width: 560px; height: 560px; opacity: .12; }
.auth .formside { display: flex; align-items: center; justify-content: center; padding: 40px; background: #fff; }
.auth form { width: 100%; max-width: 360px; }
.auth form h2 { font-size: 22px; margin-bottom: 6px; }
.auth form .lead { color: var(--ink-2); margin-bottom: 22px; }
.auth .field { margin-bottom: 14px; }
.auth .btn { width: 100%; height: 42px; margin-top: 6px; }

/* error page */
.errorpage { max-width: 520px; margin: 12vh auto; text-align: center; }
.errorpage .code { font-size: 64px; font-weight: 700; color: var(--primary-soft); -webkit-text-stroke: 1px var(--primary); }

/* org chart */
.org { overflow-x: auto; padding: 10px 0 20px; }
.org ul { padding-top: 20px; position: relative; display: flex; justify-content: center; margin: 0; padding-left: 0; }
.org li { list-style: none; position: relative; padding: 20px 8px 0; text-align: center; }
.org li::before, .org li::after { content: ""; position: absolute; top: 0; right: 50%; border-top: 1px solid var(--rule-strong); width: 50%; height: 20px; }
.org li::after { right: auto; left: 50%; border-left: 1px solid var(--rule-strong); }
.org li:only-child::after, .org li:only-child::before { display: none; }
.org li:only-child { padding-top: 0; }
.org li:first-child::before, .org li:last-child::after { border: 0 none; }
.org li:last-child::before { border-right: 1px solid var(--rule-strong); border-radius: 0 5px 0 0; }
.org li:first-child::after { border-radius: 5px 0 0 0; }
.org ul ul::before { content: ""; position: absolute; top: 0; left: 50%; border-left: 1px solid var(--rule-strong); height: 20px; }
.org > ul { padding-top: 0; }
.org .node { display: inline-flex; gap: 9px; align-items: center; padding: 8px 12px; background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); text-align: left; min-width: 180px; color: var(--ink); }
.org .node:hover { border-color: var(--accent); text-decoration: none; }
.org .node .n { font-weight: 500; font-size: 13px; }
.org .node .r { font-size: 11.5px; color: var(--ink-3); }

/* timesheet grid */
table.ts td { padding: 4px 6px; height: auto; }
table.ts input.h { width: 62px; text-align: right; height: 32px; padding: 0 6px; font-variant-numeric: tabular-nums; }
table.ts th.day { text-align: center; min-width: 70px; }
table.ts th.day.off, table.ts td.off { background: #eef0f4; }
table.ts td.off input.h { background: #f7f8fa; }
table.ts th.day .dn { display: block; font-size: 11px; color: var(--ink-3); font-weight: 400; }
table.ts select { min-width: 170px; height: 32px; }
table.ts input.desc { height: 32px; min-width: 160px; }
table.ts td.num { padding-right: 12px; }

/* ------------------------------------------------------------ quotation sheet editor (the paper) */
.sheetwrap { display: block; }
.internalbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; background: #f6f7fb; border: 1px dashed var(--rule-strong); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
.internalbar .field label { font-size: 11.5px; margin-bottom: 3px; }
.internalbar input, .internalbar select { height: 32px; }
.internalbar .tag { font-size: 11.5px; color: var(--ink-3); align-self: center; margin-right: 4px; }
.savebar { position: sticky; bottom: 0; z-index: 15; margin: 18px -26px -30px; padding: 10px 26px; background: rgba(255,255,255,.97); border-top: 1px solid var(--rule); display: flex; gap: 22px; align-items: center; flex-wrap: wrap; box-shadow: 0 -6px 18px -12px rgba(23,26,44,.25); border-radius: 0 0 3px 3px; }
.savebar .m { display: flex; flex-direction: column; min-width: 70px; }
@media (max-width: 1500px) { .savebar { gap: 16px; } .savebar .m.opt { display: none; } }
.savebar .m span:first-child { font-size: 11.5px; color: var(--ink-3); }
.savebar .m span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.savebar .m.big span:last-child { font-size: 18px; }
.savebar .sp { flex: 1; }
.docopts { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px 16px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--rule); }
.sheet { background: #fff; border: 1px solid var(--rule); border-radius: 3px; box-shadow: 0 1px 0 var(--rule), 0 12px 30px -18px rgba(23,26,44,.25); padding: 26px 26px 30px; }
.sheet .sh-top { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: start; padding-bottom: 14px; border-bottom: 2px solid var(--doc, #1F3864); margin-bottom: 16px; }
.sheet .sh-top .docname { font-size: 20px; font-weight: 700; color: var(--doc, #1F3864); text-align: right; }
.sheet .sh-top .docno { text-align: right; font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.sheet .sh-top .docno b { color: var(--ink); }
.sheet .sh-top img { height: 54px; }
.sheet .sh-meta { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px 14px; margin-bottom: 16px; }
.sheet .sh-meta .field label { font-size: 12px; }
table.lines { width: 100%; border-collapse: collapse; font-size: 13px; }
table.lines th { background: var(--doc, #1F3864); color: #fff; font-weight: 500; padding: 8px 6px; font-size: 12px; text-align: center; white-space: nowrap; }
table.lines th.in { background: #3a3f5c; }
table.lines td { border-bottom: 1px solid var(--rule); padding: 3px 4px; vertical-align: top; }
table.lines td input, table.lines td textarea { border-color: transparent; background: transparent; height: 30px; padding: 0 6px; font-size: 13px; border-radius: 3px; }
table.lines td textarea { min-height: 30px; height: 30px; padding: 6px; overflow: hidden; resize: none; line-height: 1.35; }
table.lines td input:hover, table.lines td textarea:hover { border-color: var(--rule); }
table.lines td input:focus, table.lines td textarea:focus { border-color: var(--accent); background: #fff; box-shadow: none; }
table.lines td.n { text-align: center; color: var(--ink-3); width: 34px; padding-top: 9px; font-size: 12px; }
table.lines td.num input { text-align: right; font-variant-numeric: tabular-nums; }
table.lines td.calc { text-align: right; padding: 9px 8px 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.lines td.in { background: #f6f7fb; }
table.lines td.in input { color: var(--ink-2); }
table.lines tr.sec td { background: var(--doc-band, #EEF2F8); }
table.lines tr.sec td input { font-weight: 600; color: var(--doc, #1F3864); }
table.lines tr.dragging { opacity: .4; }
table.lines tr.dragover td { box-shadow: inset 0 2px 0 var(--accent); }
table.lines td.ops { white-space: nowrap; width: 58px; padding-top: 5px; }
table.lines td.ops button { border: 0; background: none; padding: 3px; color: var(--ink-3); cursor: pointer; border-radius: 3px; }
table.lines td.ops button:hover { background: var(--paper-2); color: var(--ink); }
table.lines td.ops .grab { cursor: grab; }
table.lines .lowm input.m { color: var(--bad); font-weight: 600; }
.addrow { display: flex; gap: 8px; padding: 10px 0 0; flex-wrap: wrap; }
.totals { margin-left: auto; width: 360px; max-width: 100%; margin-top: 12px; }
.totals .r { display: flex; justify-content: space-between; padding: 6px 4px; font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--rule); }
.totals .r.grand { font-weight: 700; background: var(--doc-band, #EEF2F8); border-bottom: 0; padding: 9px 6px; }
.totals .r input { width: 110px; height: 28px; text-align: right; }
.rail { position: sticky; top: 72px; }
.rail .panel { margin-bottom: 14px; }
.rail .money-big { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rail .row2 { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; border-bottom: 1px dashed var(--rule); }
.rail .row2:last-child { border-bottom: 0; }
.rail .row2 span:last-child { font-variant-numeric: tabular-nums; font-weight: 500; }
.marginmeter { height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--bad) 0 20%, var(--warn) 20% 40%, var(--good) 40% 100%); position: relative; margin: 12px 0 4px; opacity: .85; }
.marginmeter i { position: absolute; top: -4px; width: 3px; height: 16px; background: var(--ink); border-radius: 2px; transform: translateX(-1px); }
.suggest { position: absolute; z-index: 30; background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-pop); max-height: 260px; overflow: auto; min-width: 380px; }
.suggest div { padding: 7px 10px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--rule); }
.suggest div:hover, .suggest div.sel { background: var(--accent-soft); }
.suggest div small { color: var(--ink-3); display: block; }

/* assistant */
.chat { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 0; height: calc(100vh - 56px - 22px - 48px); min-height: 540px; background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.chat .threads { border-right: 1px solid var(--rule); display: flex; flex-direction: column; background: var(--paper-2); }
.chat .threads .new { padding: 12px; border-bottom: 1px solid var(--rule); }
.chat .threads ul { list-style: none; padding: 6px; margin: 0; overflow: auto; flex: 1; }
.chat .threads li a { display: block; padding: 8px 10px; border-radius: var(--radius); color: var(--ink); font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat .threads li a.on { background: #fff; box-shadow: inset 0 0 0 1px var(--rule); font-weight: 500; }
.chat .threads li a small { display: block; color: var(--ink-3); font-size: 11.5px; }
.chat .convo { display: flex; flex-direction: column; min-width: 0; }
.chat .msgs { flex: 1; overflow: auto; padding: 22px 26px; }
.msg { display: flex; gap: 12px; margin-bottom: 18px; max-width: 920px; }
.msg .who { width: 30px; height: 30px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.msg.bot .who { background: var(--primary); color: #fff; }
.msg.user .who { background: var(--accent-soft); color: var(--accent-ink); }
.msg .body { min-width: 0; flex: 1; }
.msg .body .name { font-size: 12.5px; color: var(--ink-3); margin-bottom: 3px; }
.msg .body .txt { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .body .txt p { margin: 0 0 8px; }
.msg .body table.t { margin-top: 10px; border: 1px solid var(--rule); font-size: 12.5px; }
.msg .body table.t td { height: 32px; }
.msg .attach { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--rule); border-radius: 14px; font-size: 12.5px; margin-top: 6px; background: var(--paper-2); }
.msg .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chat .composer { border-top: 1px solid var(--rule); padding: 12px 16px; background: #fff; }
.chat .composer form { display: flex; gap: 8px; align-items: flex-end; }
.chat .composer textarea { min-height: 42px; max-height: 160px; height: 42px; }
.chat .composer .file-pill { font-size: 12.5px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; }
.chat .quick { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 16px 10px; }
.chat .quick button { border: 1px solid var(--rule); background: #fff; border-radius: 14px; padding: 4px 11px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }
.chat .quick button:hover { border-color: var(--accent); color: var(--accent-ink); }
.typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); margin-right: 3px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }

/* admin */
.adminnav { list-style: none; padding: 6px; margin: 0; }
.adminnav a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--radius); color: var(--ink); font-size: 13.5px; }
.adminnav a:hover { background: var(--paper-2); text-decoration: none; }
.adminnav a.on { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.adminnav .grp { font-size: 11.5px; color: var(--ink-3); padding: 12px 10px 4px; }
.permgrid th:not(:first-child), .permgrid td:not(:first-child) { text-align: center; }
.permgrid td { height: 38px; }
.permgrid tr.grp td { background: var(--paper-2); font-weight: 600; font-size: 12.5px; height: 32px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--rule-strong); cursor: pointer; }
.preview-frame { border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; background: var(--canvas); }
.mini-app { display: grid; grid-template-columns: 130px 1fr; height: 220px; font-size: 11px; }
.mini-app .ms { background: var(--pv-primary, var(--primary)); color: #fff; padding: 10px 8px; }
.mini-app .ms div { padding: 5px 6px; border-radius: 4px; opacity: .8; }
.mini-app .ms div.on { background: rgba(255,255,255,.14); opacity: 1; }
.mini-app .mm { padding: 12px; }
.mini-app .mm .bt { display: inline-block; background: var(--pv-accent, var(--accent)); color: #fff; padding: 4px 10px; border-radius: 4px; }
.menurow td input[type=text] { height: 32px; }

/* print */
@media print {
  .sidebar, .topbar, .noprint { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  body { background: #fff; }
}

/* responsive */
@media (max-width: 1180px) {
  .sheetwrap { grid-template-columns: 1fr; }
  .rail { position: static; }
  .grid.side { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; background: var(--canvas) !important; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); z-index: 60; transform: translateX(-100%); transition: transform .18s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
  .topbar .menu-toggle { display: inline-flex; }
  .grid.c2, .grid.c3, .grid.side-l { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth .art { display: none; }
  .chat { grid-template-columns: 1fr; }
  .chat .threads { display: none; }
  .form-grid .w-3, .form-grid .w-4, .form-grid .w-2 { grid-column: span 6; }
  .form-grid .w-6, .form-grid .w-8, .form-grid .w-9 { grid-column: span 12; }
  .search { max-width: none; }
  .topbar .newbtn span { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* chart tooltip */
.chart .hit { cursor: default; outline: none; }
.chart .hit.on, .chart .hit:focus { fill: rgba(23, 26, 44, .045); }
.charttip { position: absolute; z-index: 90; display: none; background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow-pop); padding: 8px 10px; font-size: 12.5px; pointer-events: none; min-width: 150px; }
.charttip .h { color: var(--ink-3); margin-bottom: 4px; }
.charttip .r { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.charttip .k { width: 12px; height: 2px; border-radius: 1px; }
.charttip b { font-variant-numeric: tabular-nums; color: var(--ink); }
.charttip .n { color: var(--ink-3); }
.legend i { border-radius: 2px; }
.chat { grid-template-rows: minmax(0, 1fr); }
.chat .convo, .chat .threads { min-height: 0; }
.chat .msgs { min-height: 0; }
.msg .tablewrap { max-height: 360px; overflow: auto; border: 1px solid var(--rule); border-radius: var(--radius); margin-top: 10px; }
.msg .tablewrap table.t { margin-top: 0; border: 0; }
.msg .tablewrap thead th { position: sticky; top: 0; z-index: 1; }
table.t th .sub { display: block; font-weight: 400; font-size: 11.5px; color: var(--ink-3); }
input[type=file] { max-width: 100%; font-size: 12.5px; }
input[type=file]::file-selector-button { font: inherit; border: 1px solid var(--rule-strong); background: #fff; border-radius: var(--radius); padding: 5px 10px; margin-right: 8px; cursor: pointer; }
.permgrid td:first-child { min-width: 260px; }
@media (max-width: 960px) {
  .grid.side, .grid.side-l, .grid.c2, .grid.c3, .sheetwrap { grid-template-columns: 1fr !important; }
  .panel { overflow-x: auto; }
  .content { overflow-x: clip; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figures .f { border-left: 0; border-top: 1px solid var(--rule); }
  .figures .f:nth-child(-n+2) { border-top: 0; }
  .figures .f:nth-child(even) { border-left: 1px solid var(--rule); }
  .figures .f .v { font-size: 20px; }
  .pagehead .actions { width: 100%; }
  .sheet { padding: 14px; }
  .sheet .sh-meta .field { grid-column: span 12 !important; }
  .savebar { margin: 14px -14px -14px; padding: 10px 14px; gap: 12px; }
  .savebar .m:not(.big) { display: none; }
  .rail { position: static; }
  .usermenu-btn .small { display: none; }
}
.panel.flush > .pb.muted { padding: var(--pad); }

/* payroll */
.field .static { padding: 8px 0 0; font-size: 16px; font-variant-numeric: tabular-nums; }
table.t.pay td, table.t.pay th { padding-left: 8px; padding-right: 8px; }
table.t.pay td { padding-top: 6px; padding-bottom: 6px; height: auto; }
table.t.pay td.emp { min-width: 170px; }
table.t.pay td.emp b { white-space: nowrap; }
table.t.pay td input { width: 70px; height: 30px; padding: 3px 6px; text-align: right; font-variant-numeric: tabular-nums; }
table.t.pay td input.note { width: 130px; text-align: left; }
table.t.pay td.num .sub { font-size: 11.5px; }
table.t.pay th.grp { text-align: center; border-left: 1px solid var(--rule); }
table.t.pay td.bl, table.t.pay th.bl { border-left: 1px solid var(--rule); }
.steps { display: flex; gap: 0; margin: 0 0 16px; padding: 0; list-style: none; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--paper); overflow: hidden; }
.steps li { flex: 1; padding: 10px 14px; font-size: 13px; color: var(--ink-3); border-left: 1px solid var(--rule); }
.steps li:first-child { border-left: 0; }
.steps li b { display: block; color: var(--ink-2); font-weight: 600; }
.steps li.done b { color: var(--good, #1d7a4a); }
.steps li.now { background: var(--accent-soft); }
.steps li.now b { color: var(--ink); }
