/* Smartss CRM — application styles */
:root {
  --navy: #0e2a47;
  --navy-2: #13365b;
  --primary: #1a5fb4;
  --primary-600: #154f97;
  --primary-50: #eaf2fc;
  --accent: #0fa3b1;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --border: #e3e7ee;
  --border-strong: #cfd6e1;
  --text: #16202e;
  --text-2: #475467;
  --muted: #7a8699;
  --green: #12805c; --green-bg: #e6f5ee;
  --red: #c4302b; --red-bg: #fdecec;
  --amber: #b25e09; --amber-bg: #fff4e0;
  --blue: #1a5fb4; --blue-bg: #e8f0fc;
  --teal: #0b7f8a; --teal-bg: #e2f6f7;
  --purple: #6b3fb8; --purple-bg: #f1ebfb;
  --grey: #5b6678; --grey-bg: #eef1f5;
  --radius: 10px;
  --radius-sm: 7px;
  --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, .14);
  --sidebar-w: 240px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; color: var(--text); }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.ic { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.pad { padding: 14px 16px; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 8px } .mt-2 { margin-top: 16px } .mt-3 { margin-top: 24px }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: 8px } .mb-2 { margin-bottom: 16px } .mb-3 { margin-bottom: 24px }
.text-green { color: var(--green); } .text-red { color: var(--red); } .text-amber { color: var(--amber); }
.fw-600 { font-weight: 600; }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--navy); color: #cfd9e6; position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column; z-index: 40; transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; color: #fff; text-decoration: none !important; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--primary));
  display: grid; place-items: center; font-weight: 800; font-size: 12px; letter-spacing: .5px; color: #fff;
}
.brand-mark.has-logo { background: #fff; padding: 4px; overflow: hidden; }
.brand-mark.has-logo img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.brand-text { font-weight: 650; font-size: 15.5px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: #c5d1e0;
  font-weight: 500; margin-bottom: 2px; text-decoration: none;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .13); color: #fff; }
.nav a.active .ic { color: #5fd4de; }
.nav-count { margin-left: auto; font-style: normal; background: var(--red); color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #7f93ad; padding: 16px 12px 6px; }
.sidebar-foot { padding: 12px 20px; font-size: 11px; color: #6c819c; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, .96); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 10px 24px; min-height: 60px;
}
.global-search { flex: 1; max-width: 520px; position: relative; display: flex; align-items: center; }
.global-search > .ic { position: absolute; left: 12px; color: var(--muted); }
.global-search input[type=search] {
  width: 100%; border: 1px solid var(--border); background: var(--bg); border-radius: 9px; padding: 9px 12px 9px 36px; font: inherit;
}
.global-search input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-50); }
.search-suggest {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 420px; overflow-y: auto; z-index: 60;
}
.search-suggest a { display: flex; gap: 10px; padding: 9px 14px; color: var(--text); border-bottom: 1px solid var(--border); text-decoration: none; }
.search-suggest a:hover, .search-suggest a.focus { background: var(--primary-50); }
.search-suggest .type { font-size: 11px; color: var(--muted); text-transform: uppercase; min-width: 74px; padding-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.branch-switch select { padding: 7px 28px 7px 10px; font-weight: 600; font-size: 13px; }
.icon-btn { position: relative; border: 0; background: transparent; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--text-2); display: inline-flex; }
.icon-btn:hover { background: var(--grey-bg); }
.icon-btn .dot { position: absolute; top: 2px; right: 1px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; border-radius: 9px; padding: 0 5px; line-height: 16px; min-width: 16px; text-align: center; }
.avatar-btn { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 9px; font: inherit; color: var(--text); }
.avatar-btn:hover { background: var(--grey-bg); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: 12.5px; flex-shrink: 0; }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.user-name { font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { padding: 22px 24px 48px; max-width: 1480px; width: 100%; }
.scrim { display: none; }
.only-mobile { display: none; }

/* ---------- Dropdowns ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 210px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; display: none;
}
.dropdown-menu.right { left: auto; right: 0; }
.dropdown.open > .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 7px; color: var(--text);
  background: none; border: 0; font: inherit; text-align: left; cursor: pointer; text-decoration: none;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--grey-bg); text-decoration: none; }
.dropdown-menu .danger { color: var(--red); }
.dropdown-menu hr { margin: 6px 0; }
.dropdown-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: flex; flex-direction: column; }
.dropdown-head .muted { font-size: 12px; }
.notif-menu { width: 360px; padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-head form { margin: 0; }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-50); }
.notif-item strong { display: block; font-size: 13.5px; font-weight: 600; }
.notif-item span { font-size: 12.5px; color: var(--text-2); display: block; }
.notif-item time { font-size: 11.5px; color: var(--muted); }
.notif-all { display: block; text-align: center; padding: 10px; font-weight: 600; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; font-size: 12.5px; padding: 0; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); margin-top: 3px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: #fff; color: var(--text); font: inherit; font-weight: 600; font-size: 13.5px;
  cursor: pointer; text-decoration: none !important; white-space: nowrap; line-height: 1.3; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--grey-bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn-whatsapp:hover { background: #1ebe5b; border-color: #1ebe5b; color: #fff; }
.btn-success:hover { background: #0e6a4c; }
.btn-danger { background: #fff; border-color: #f0c6c4; color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 18px; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: block; color: var(--text); text-decoration: none !important; position: relative; }
a.kpi:hover { border-color: var(--border-strong); }
.kpi-label { font-size: 12.5px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 7px; }
.kpi-label .ic { color: var(--muted); }
.kpi-value { font-size: 23px; font-weight: 700; margin-top: 6px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kpi-value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-right: 4px; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.warn .kpi-value { color: var(--red); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-2); font-weight: 650; background: #fafbfc; white-space: nowrap; }
.table th a { color: inherit; text-decoration: none; }
.table th.sorted { color: var(--primary); }
.table tbody tr:hover { background: #fafcff; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table .primary-cell a { font-weight: 600; color: var(--text); }
.table .primary-cell a:hover { color: var(--primary); }
.table .sub { display: block; font-size: 12px; color: var(--muted); }
.table-sm th, .table-sm td { padding: 7px 10px; }
.table tfoot td { font-weight: 650; background: #fafbfc; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .ic { color: var(--border-strong); margin-bottom: 8px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.filters .search { flex: 1 1 220px; min-width: 180px; max-width: 340px; }
.filters select, .filters input { width: auto; }
.filters .grow { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border); background: #fff; font-size: 12.5px; font-weight: 600; color: var(--text-2); text-decoration: none !important; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip em { font-style: normal; opacity: .7; margin-left: 3px; }

.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); gap: 10px; flex-wrap: wrap; font-size: 13px; }
.pager-links { display: flex; gap: 4px; }
.pager-links a { padding: 5px 10px; border-radius: 6px; border: 1px solid var(--border); color: var(--text-2); text-decoration: none; }
.pager-links a.current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 650; white-space: nowrap; line-height: 18px; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-teal { background: var(--teal-bg); color: var(--teal); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-grey { background: var(--grey-bg); color: var(--grey); }

/* ---------- Forms ---------- */
label, .label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: var(--text); }
.req::after { content: " *"; color: var(--red); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=search], input[type=tel], input[type=url], input[type=file], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font: inherit; color: var(--text);
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
input[type=file] { padding: 6px; }
select { 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='%237a8699' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field { min-width: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.input-group { display: flex; }
.input-group > * { border-radius: 0; }
.input-group > :first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group > :last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-left: -1px; }
.error-text { color: var(--red); font-size: 12.5px; margin-top: 4px; }

/* Alerts */
.alert { padding: 11px 40px 11px 14px; border-radius: 9px; margin-bottom: 14px; position: relative; border: 1px solid; font-weight: 500; }
.alert-success { background: var(--green-bg); border-color: #b7e2cf; color: #0b5e43; }
.alert-error { background: var(--red-bg); border-color: #f3c3c1; color: #a02622; }
.alert-warning { background: var(--amber-bg); border-color: #f6d9a8; color: #8a4a06; }
.alert-info { background: var(--blue-bg); border-color: #c5d8f5; color: #174b8f; }
.alert-x { position: absolute; right: 8px; top: 7px; border: 0; background: none; font-size: 20px; cursor: pointer; color: inherit; opacity: .6; }

/* ---------- Detail views ---------- */
.dl { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; word-break: break-word; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; padding: 0 12px; }
.tabs a { padding: 12px 14px; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; margin-bottom: -1px; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs a em { font-style: normal; background: var(--grey-bg); border-radius: 10px; padding: 0 7px; font-size: 11.5px; margin-left: 4px; color: var(--text-2); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 26px; }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.timeline li::after { content: ""; position: absolute; left: 10px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .what { font-size: 13.5px; }
.timeline .note-body { background: var(--bg); border-radius: 8px; padding: 8px 12px; margin-top: 4px; white-space: pre-wrap; }

.progress-steps { display: flex; gap: 0; margin: 4px 0 0; overflow-x: auto; }
.progress-steps .step { flex: 1; min-width: 92px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); position: relative; padding-top: 22px; }
.progress-steps .step::before { content: ""; position: absolute; top: 6px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--border-strong); z-index: 1; }
.progress-steps .step::after { content: ""; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--border-strong); }
.progress-steps .step:first-child::after { display: none; }
.progress-steps .step.done { color: var(--green); }
.progress-steps .step.done::before, .progress-steps .step.done::after { background: var(--green); }
.progress-steps .step.current { color: var(--primary); }
.progress-steps .step.current::before { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-50); }
.progress-steps .step.bad { color: var(--red); }
.progress-steps .step.bad::before { background: var(--red); }

.bar { height: 8px; background: var(--grey-bg); border-radius: 5px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--green); border-radius: 5px; }

.totals { margin-left: auto; width: 100%; max-width: 360px; }
.totals td { padding: 6px 0; }
.totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals tr.grand td { border-top: 2px solid var(--text); font-size: 16px; font-weight: 750; padding-top: 10px; }

/* Line item editor */
.items-table { min-width: 760px; }
.items-table th { background: #fafbfc; }
.items-table td { padding: 6px; vertical-align: top; border-bottom: 1px solid var(--border); }
.items-table input, .items-table textarea { padding: 7px 8px; }
.items-table textarea { min-height: 38px; height: 38px; }
.items-table .col-qty { width: 84px; }
.items-table .col-unit { width: 78px; }
.items-table .col-price { width: 128px; }
.items-table .col-disc { width: 76px; }
.items-table .col-total { width: 130px; text-align: right; font-weight: 600; padding-top: 14px; font-variant-numeric: tabular-nums; }
.items-table .col-x { width: 40px; }
.items-table .product-pick { position: relative; }
.product-results { position: absolute; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); z-index: 1000; max-height: 320px; overflow-y: auto; text-align: left; }
.product-results div { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--border); }
.product-results div:hover, .product-results div.focus { background: var(--primary-50); }
.product-results small { color: var(--muted); display: block; }
.row-handle { cursor: grab; color: var(--muted); }

/* Auth pages */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(ellipse at top left, #1d4f80 0%, var(--navy) 55%, #0a1f36 100%); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); padding: 32px 30px; }
.auth-card .brand { padding: 0 0 18px; color: var(--navy); }
.auth-card .brand-text { color: var(--navy); font-size: 18px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card form > * + * { margin-top: 14px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--text-2); }

/* Charts */
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.chart-box.lg { height: 340px; }

.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 10px 18px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
.list-plain .grow { flex: 1; min-width: 0; }
.list-plain .title { font-weight: 600; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.attach-list .file-ic { width: 36px; height: 36px; border-radius: 8px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; font-size: 10px; font-weight: 800; text-transform: uppercase; flex-shrink: 0; }

.perm-table select { min-width: 130px; }
.inline-form { display: inline; margin: 0; }
.task-done { text-decoration: line-through; color: var(--muted); }
.overdue { color: var(--red); font-weight: 600; }
.due-soon { color: var(--amber); font-weight: 600; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(16, 24, 40, .5); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 60px 16px; overflow-y: auto; }
.modal.open { display: flex; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); }
.modal-box.lg { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .grid-main, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim.show { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 35; }
  .main { margin-left: 0; }
  .only-mobile { display: inline-flex; }
  .topbar { padding: 8px 12px; gap: 6px; }
  .content { padding: 16px 12px 40px; }
  .hide-sm { display: none !important; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .notif-menu { position: fixed; left: 8px; right: 8px; top: 58px; width: auto; }
  .branch-switch select { padding: 6px 24px 6px 8px; font-size: 12px; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi-value { font-size: 18px; }
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 19px; }
  .page-head { margin-bottom: 14px; }
  .page-actions { width: 100%; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .filters { padding: 10px 12px; }
  .filters .search { max-width: none; flex-basis: 100%; }
  .filters select { flex: 1 1 45%; }
  .card-body { padding: 14px; }
  .card-head { padding: 12px 14px; }
  /* Tables become stacked cards on phones */
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { border-bottom: 1px solid var(--border); padding: 10px 14px; }
  .table.responsive td { border: 0; padding: 3px 0; text-align: left !important; display: flex; justify-content: space-between; gap: 12px; }
  .table.responsive td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; flex-shrink: 0; }
  .table.responsive td.primary-cell { font-size: 15px; display: block; }
  .table.responsive td.actions { justify-content: flex-end; padding-top: 6px; }
  .table.responsive td:empty { display: none; }
  .global-search input { padding-left: 32px; }
  .global-search input::placeholder { font-size: 13px; }
}

@media print {
  .sidebar, .topbar, .page-actions, .no-print { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
}

/* Notification items inside the dropdown stack vertically */
.dropdown-menu a.notif-item { display: block; border-radius: 0; padding: 10px 14px; }
.dropdown-menu a.notif-item.unread { background: var(--primary-50); }
.attach-list .grow > span.small { display: block; }

[data-mailbox-fields][hidden] { display: none !important; }
.mailbox-box .check { font-weight: 500; }

/* WhatsApp dialog */
.wa-file { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 10px; background: #f7faf8; }
.wa-routes { display: grid; gap: 10px; }
.wa-route { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: #fff; cursor: pointer; font: inherit; color: inherit; }
.wa-route:hover { border-color: #25d366; background: #f3fcf6; }
.wa-route[hidden] { display: none; }
.wa-route strong { display: block; font-size: 15px; margin-bottom: 2px; }
.wa-route small { display: block; color: var(--muted, #667085); line-height: 1.45; }
.wa-ic { flex: none; width: 38px; height: 38px; border-radius: 50%; background: #25d366; color: #fff; display: grid; place-items: center; }
.wa-status { padding: 10px 12px; border-radius: 10px; background: #ecfdf3; color: #05603a; }

/* =====================================================================
   Salahuddin Softtech Solutions — brand theme
   Colours are the three S's of the logo: navy #051657 · royal #084E9C · sky #1789C4.
   Montserrat (the letterhead typeface) for headings and figures.
   ===================================================================== */
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/montserrat-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/montserrat-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/montserrat-latin-700-normal.woff2') format('woff2'); }

:root {
  --sss-navy: #051657; --sss-royal: #084E9C; --sss-sky: #1789C4;
  --navy: #051657; --navy-2: #0B2470;
  --primary: #084E9C; --primary-600: #063F80; --primary-50: #E7F0FA;
  --accent: #1789C4; --accent-50: #E5F3FA; --accent-bright: #1789C4;
  --bg: #EEF3F9; --surface: #ffffff; --surface-2: #F6F9FC; --surface-3: #F3F6FA;
  --border: #DFE6F0; --border-strong: #C8D3E2;
  --text: #0A1230; --text-2: #3E4A66; --muted: #6B7790;
  --blue: #084E9C; --blue-bg: #E7F0FA; --teal: #1478AD; --teal-bg: #E3F2FA;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(5, 22, 87, .06);
  --shadow-lg: 0 18px 44px -16px rgba(5, 22, 87, .28);
  --ribbon: linear-gradient(90deg, #051657 0 33.34%, #084E9C 33.34% 66.67%, #1789C4 66.67% 100%);
  --head-font: 'Montserrat', var(--font);
  --logo: url('../img/sss-logo.png');
  --mark: url('../img/sss-mark.svg');
}
body { background: var(--bg); }
h1, h2, h3, .brand-text, .kpi-value, .modal-head h3, .auth-title { font-family: var(--head-font); letter-spacing: -.012em; }
h1 { font-weight: 700; color: var(--sss-navy); }
h2, h3 { font-weight: 600; color: var(--sss-navy); }
a { color: var(--primary); }
::selection { background: rgba(23, 137, 196, .22); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Sidebar: white, the logo in its own colours ---------- */
.sidebar { background: #fff; color: var(--text-2); border-right: 1px solid var(--border); }
.brand { padding: 22px 22px 18px; gap: 10px; color: var(--text); }
.brand-logo { display: block; width: 172px; height: 57px; background: var(--logo) no-repeat left center / contain; }
.brand-mark.has-logo { width: 38px; height: 38px; border-radius: 10px; padding: 5px; background: #fff; border: 1px solid var(--border); }
.brand-text { font-size: 15.5px; font-weight: 700; color: var(--sss-navy); }
.nav { padding: 6px 14px 14px; }
.nav a { color: #36415E; font-weight: 500; border-radius: 9px; padding: 8px 12px; position: relative; transition: background .15s, color .15s; }
.nav a .ic { color: #8390AB; transition: color .15s; }
.nav a:hover { background: #F1F5FA; color: var(--sss-navy); }
.nav a:hover .ic { color: var(--primary); }
.nav a.active { background: #E9F1FA; color: var(--sss-navy); font-weight: 600; }
.nav a.active .ic { color: var(--primary); }
/* active marker: a short slanted bar, the angle of the S strokes */
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-label { color: #8792AA; text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; padding: 18px 12px 6px; }
.nav-count { background: #D93A3A; }
.sidebar-foot { color: #98A2B8; }

/* ---------- Top bar ---------- */
.main::before { content: ""; display: block; height: 4px; background: var(--ribbon); }
.topbar { background: rgba(255, 255, 255, .94); border-bottom: 1px solid var(--border); box-shadow: none; }
.global-search input[type=search] { background: var(--surface-3); border-color: transparent; border-radius: 10px; }
.global-search input:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 137, 196, .16); }
.avatar { background: var(--sss-navy); }
.only-mobile .brand-logo, .topbar .brand-logo { width: 110px; height: 36px; }

/* ---------- Page header + dashboard hero ---------- */
.page-head h1 { font-size: 24px; }
.breadcrumb a:hover { color: var(--primary); }
.page-head.hero {
  position: relative; overflow: hidden; align-items: center; padding: 28px 30px 30px; border-radius: 16px; margin-bottom: 20px;
  background: var(--sss-navy); color: #fff;
}
/* the SSS ribbon, very large and cropped off the right edge */
.page-head.hero::after {
  content: ""; position: absolute; right: -60px; top: -70px; width: 380px; height: 260px; pointer-events: none; opacity: .32;
  background: url('../img/sss-mark-dark.svg') no-repeat center / contain;
}
.page-head.hero::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--ribbon); }
.page-head.hero > * { position: relative; z-index: 1; }
.page-head.hero h1 { color: #fff; font-size: 27px; }
.page-head.hero .sub, .page-head.hero .sub strong { color: rgba(232, 238, 250, .82); }
.page-head.hero .btn-primary { background: #fff; color: var(--sss-navy); border-color: #fff; box-shadow: none; }
.page-head.hero .btn-primary:hover { background: #E5F3FA; border-color: #E5F3FA; }

/* ---------- Buttons ---------- */
.btn { border-radius: 9px; border-color: var(--border-strong); transition: background .15s, border-color .15s, color .15s; }
.btn:hover { background: #F2F6FB; border-color: #B5C3D8; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: none; }
.btn-primary:hover { background: var(--sss-navy); border-color: var(--sss-navy); color: #fff; }
.icon-btn:hover { background: #EEF3F9; }

/* ---------- Cards ---------- */
.card { border-color: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { padding: 15px 20px; }
.card-head h2 { font-size: 15.5px; }
.card-body { padding: 20px; }
.card-foot { background: var(--surface-2); }

/* ---------- KPI tiles ---------- */
.kpi { border-radius: var(--radius); padding: 17px 20px 16px; transition: border-color .15s, box-shadow .15s; }
a.kpi:hover { border-color: #AFC4DE; box-shadow: 0 10px 24px -16px rgba(5, 22, 87, .35); }
.kpi-label { color: var(--text-2); font-weight: 600; }
.kpi-label .ic { width: 28px; height: 28px; padding: 6px; border-radius: 8px; background: var(--accent-50); color: var(--accent); box-sizing: border-box; }
.kpi-value { color: var(--sss-navy); font-size: 25px; font-weight: 700; margin-top: 10px; }
.kpi-value small { color: var(--accent); font-family: var(--font); font-weight: 700; }
.kpi.warn { border-color: #F2C4C4; }
.kpi.warn .kpi-value { color: #C42F2F; }

/* ---------- Tables ---------- */
.table th { background: var(--surface-2); color: #4F5B78; font-size: 12.5px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.table th.sorted { color: var(--primary); }
.table tbody tr:hover { background: #F5F9FD; }
.table .primary-cell a { color: var(--sss-navy); }
.table .primary-cell a:hover { color: var(--primary); }
.items-table th { background: var(--surface-2); }
.search-suggest .type { text-transform: none; font-size: 11.5px; font-weight: 600; }

/* ---------- Chips, tabs, pager, badges ---------- */
.chip { border-color: var(--border); transition: border-color .15s, color .15s; }
.chip:hover { border-color: #B5C3D8; color: var(--sss-navy); }
.chip.active { background: var(--sss-navy); border-color: var(--sss-navy); color: #fff; }
.tabs a:hover { color: var(--sss-navy); }
.tabs a.active { color: var(--sss-navy); border-bottom-color: var(--accent); }
.pager-links a { border-radius: 8px; }
.pager-links a.current { background: var(--sss-navy); border-color: var(--sss-navy); }
.badge-blue { background: #E7F0FA; color: #084E9C; }
.badge-teal { background: #E3F2FA; color: #11719F; }

/* ---------- Forms ---------- */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local],
input[type=search], input[type=tel], input[type=url], input[type=file], select, textarea { border-radius: 9px; border-color: #CFD8E5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(23, 137, 196, .16); }
.check input { accent-color: var(--primary); }

/* ---------- Progress, timeline, bars ---------- */
.progress-steps .step.current { color: var(--primary); }
.progress-steps .step.current::before { background: var(--primary); box-shadow: 0 0 0 4px rgba(23, 137, 196, .18); }
.timeline li::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-50); }
.bar > span { background: var(--primary); }

/* ---------- Dropdowns, modals ---------- */
.dropdown-menu, .search-suggest, .product-results { border-radius: 12px; border-color: var(--border); box-shadow: var(--shadow-lg); }
.modal { background: rgba(5, 22, 87, .36); backdrop-filter: blur(2px); }
.modal-box { border-radius: 14px; }
.notif-item.unread, .dropdown-menu a.notif-item.unread { background: var(--accent-50); }
.alert { border-radius: 10px; }
.alert-info { background: #E8F3FA; border-color: #BCDDF0; color: #0F5F8A; }

/* ---------- Sign-in pages: brand panel + form ---------- */
.auth-body { display: block; place-items: normal; min-height: 100vh; padding: 0; background: #fff; }
.auth-split { width: 100%; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(400px, .85fr); min-height: 100vh; }
.auth-panel { position: relative; overflow: hidden; background: var(--bg); padding: 48px 56px; display: flex; flex-direction: column; }
.auth-panel::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--ribbon); }
/* the SSS ribbon as a large graphic, bleeding off the bottom-right corner */
.auth-panel::after {
  content: ""; position: absolute; right: -16%; bottom: -18%; width: 92%; aspect-ratio: 230 / 160; pointer-events: none;
  background: var(--mark) no-repeat center / contain;
}
.auth-panel-logo { width: 264px; height: 87px; position: relative; z-index: 1; }
.auth-panel-copy { position: relative; z-index: 1; margin-top: 9vh; max-width: 34ch; }
.auth-title { font-size: 44px; line-height: 1.05; font-weight: 700; color: var(--sss-navy); margin: 0 0 14px; }
.auth-lede { font-size: 16px; line-height: 1.55; color: var(--text-2); margin: 0; }
.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 48px 40px; background: #fff; }
.auth-card { width: 100%; max-width: 380px; background: transparent; border-radius: 0; box-shadow: none; padding: 0; }
.auth-card h1 { font-size: 24px; color: var(--sss-navy); margin-bottom: 4px; }
.auth-card .btn-primary { padding: 11px 16px; font-size: 14.5px; }
.auth-mobile-logo { display: none; }
.auth-foot { color: var(--text-2); }
.auth-legal { margin-top: 36px; font-size: 12px; color: var(--muted); }

/* Charts */
.chart-box canvas { border-radius: 8px; }

@media (max-width: 960px) {
  .auth-split { grid-template-columns: minmax(0, 1fr); }
  .auth-panel { display: none; }
  .auth-form-side { align-items: stretch; justify-content: flex-start; padding: 0 22px 40px; flex-direction: column; }
  .auth-mobile-logo { display: block; width: calc(100% + 44px); margin: 0 -22px 34px; padding: 26px 22px 22px; background: var(--bg); position: relative; }
  .auth-mobile-logo::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--ribbon); }
  .auth-mobile-logo img { width: 200px; height: auto; display: block; }
  .auth-card { max-width: none; }
}
@media (max-width: 860px) {
  .page-head.hero { padding: 22px; border-radius: 14px; }
  .page-head.hero::after { width: 220px; height: 150px; right: -110px; top: -60px; opacity: .2; }
}
@media (max-width: 640px) {
  .page-head.hero h1 { font-size: 21px; }
  .page-head.hero .page-actions .btn { width: 100%; }
  .kpi-value { font-size: 19px; margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media print { .main::before, .page-head.hero::after, .page-head.hero::before { display: none; } .page-head.hero { background: none; color: var(--text); } .page-head.hero h1 { color: var(--text); } }
/* Filter bars: keep date pickers compact on one line */
.filters input[type=date] { width: 170px; flex: 0 0 auto; }
@media (max-width: 640px) { .filters input[type=date] { flex: 1 1 45%; width: auto; min-width: 0; } }

/* ---------- Appearance switch (top bar) ---------- */
.theme-switch .ti { display: none; }
html[data-theme-pref="light"] .theme-switch .ti-light,
html[data-theme-pref="dark"] .theme-switch .ti-dark,
html[data-theme-pref="system"] .theme-switch .ti-system { display: inline-flex; }
.theme-menu { min-width: 200px; }
.theme-menu .tick { margin-left: auto; color: var(--accent); visibility: hidden; }
html[data-theme-pref="light"] [data-theme-set="light"] .tick,
html[data-theme-pref="dark"] [data-theme-set="dark"] .tick,
html[data-theme-pref="system"] [data-theme-set="system"] .tick { visibility: visible; }
html[data-theme-pref="light"] [data-theme-set="light"], html[data-theme-pref="dark"] [data-theme-set="dark"], html[data-theme-pref="system"] [data-theme-set="system"] { font-weight: 600; color: var(--primary); }
html.theme-anim, html.theme-anim * { transition: background-color .25s ease, border-color .25s ease, color .15s ease !important; }

/* =====================================================================
   Dark mode — night navy surfaces; the logo switches to its white-text version
   ===================================================================== */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070D24; --surface: #0D1636; --surface-2: #121D44; --surface-3: #0A1230;
  --border: #1E2A55; --border-strong: #2C3B70;
  --text: #E6ECF8; --text-2: #B0BCD8; --muted: #7F8DB0;
  --primary: #3E95E0; --primary-600: #2F82CB; --primary-50: rgba(62, 149, 224, .14);
  --accent: #3BAFE6; --accent-50: rgba(59, 175, 230, .14);
  --green: #3CCB8F; --green-bg: rgba(60, 203, 143, .14);
  --red: #FF7A7A; --red-bg: rgba(255, 122, 122, .14);
  --amber: #F5B545; --amber-bg: rgba(245, 181, 69, .14);
  --blue: #7DB4FF; --blue-bg: rgba(125, 180, 255, .14);
  --teal: #38BDF8; --teal-bg: rgba(56, 189, 248, .14);
  --purple: #B9A4FF; --purple-bg: rgba(185, 164, 255, .15);
  --grey: #A9B4CC; --grey-bg: rgba(169, 180, 204, .13);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 56px -16px rgba(0, 0, 0, .7);
  --logo: url('../img/sss-logo-dark.png');
  --mark: url('../img/sss-mark-dark.svg');
}
html[data-theme="dark"] body { background: var(--bg); color: var(--text); }
html[data-theme="dark"] h1, html[data-theme="dark"] h2, html[data-theme="dark"] h3, html[data-theme="dark"] .brand-text, html[data-theme="dark"] .auth-title { color: #F1F5FF; }
html[data-theme="dark"] .sidebar { background: #050A1E; border-right-color: #141E44; }
html[data-theme="dark"] .nav a { color: #B3BEDA; }
html[data-theme="dark"] .nav a .ic { color: #7584AB; }
html[data-theme="dark"] .nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
html[data-theme="dark"] .nav a:hover .ic, html[data-theme="dark"] .nav a.active .ic { color: var(--accent); }
html[data-theme="dark"] .nav a.active { background: rgba(59, 175, 230, .12); color: #fff; }
html[data-theme="dark"] .nav-label { color: #6C7A9E; }
html[data-theme="dark"] .brand-mark.has-logo { border-color: transparent; }
html[data-theme="dark"] .topbar { background: rgba(9, 16, 42, .92); border-bottom-color: var(--border); }
html[data-theme="dark"] .global-search input[type=search] { background: var(--surface-3); color: var(--text); }
html[data-theme="dark"] .global-search input:focus { background: var(--surface); }
html[data-theme="dark"] .avatar { background: #1B3A8C; }
html[data-theme="dark"] .card, html[data-theme="dark"] .kpi, html[data-theme="dark"] .modal-box,
html[data-theme="dark"] .dropdown-menu, html[data-theme="dark"] .search-suggest, html[data-theme="dark"] .product-results { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .card-foot, html[data-theme="dark"] .table th, html[data-theme="dark"] .items-table th, html[data-theme="dark"] .table tfoot td { background: var(--surface-3); color: var(--text-2); }
html[data-theme="dark"] .table tbody tr:hover { background: var(--surface-2); }
html[data-theme="dark"] .table .primary-cell a, html[data-theme="dark"] .kpi, html[data-theme="dark"] .kpi-value { color: #F1F5FF; }
html[data-theme="dark"] .kpi-value small { color: var(--accent); }
html[data-theme="dark"] .kpi.warn { border-color: rgba(255, 122, 122, .35); }
html[data-theme="dark"] .kpi.warn .kpi-value { color: var(--red); }
html[data-theme="dark"] a.kpi:hover { border-color: var(--border-strong); box-shadow: 0 14px 30px -18px rgba(0, 0, 0, .9); }
html[data-theme="dark"] .btn { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
html[data-theme="dark"] .btn:hover { background: #18255A; border-color: #3B4E8E; }
html[data-theme="dark"] .btn-primary { background: #1C66BF; border-color: #1C66BF; color: #fff; }
html[data-theme="dark"] .btn-primary:hover { background: #2577D6; border-color: #2577D6; color: #fff; }
html[data-theme="dark"] .btn-success { background: #148A62; border-color: #148A62; color: #fff; }
html[data-theme="dark"] .btn-whatsapp { background: #1FB859; border-color: #1FB859; color: #fff; }
html[data-theme="dark"] .btn-danger { background: transparent; border-color: rgba(255, 122, 122, .45); color: var(--red); }
html[data-theme="dark"] .btn-danger:hover { background: var(--red-bg); }
html[data-theme="dark"] .btn-ghost { background: transparent; border-color: transparent; }
html[data-theme="dark"] .page-head.hero { background: #0B1C5C; }
html[data-theme="dark"] .page-head.hero .btn-primary { background: #fff; color: #051657; border-color: #fff; }
html[data-theme="dark"] .chip.active, html[data-theme="dark"] .pager-links a.current { background: #1C66BF; border-color: #1C66BF; }
html[data-theme="dark"] .tabs a.active { color: #fff; }
html[data-theme="dark"] .icon-btn { color: var(--text-2); }
html[data-theme="dark"] .icon-btn:hover, html[data-theme="dark"] .avatar-btn:hover,
html[data-theme="dark"] .dropdown-menu a:hover, html[data-theme="dark"] .dropdown-menu button:hover { background: var(--surface-2); }
html[data-theme="dark"] .avatar-btn, html[data-theme="dark"] .dropdown-menu a, html[data-theme="dark"] .dropdown-menu button { color: var(--text); }
html[data-theme="dark"] input[type=text], html[data-theme="dark"] input[type=email], html[data-theme="dark"] input[type=password],
html[data-theme="dark"] input[type=number], html[data-theme="dark"] input[type=date], html[data-theme="dark"] input[type=datetime-local],
html[data-theme="dark"] input[type=search], html[data-theme="dark"] input[type=tel], html[data-theme="dark"] input[type=url],
html[data-theme="dark"] input[type=file], html[data-theme="dark"] select, html[data-theme="dark"] textarea { background-color: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
html[data-theme="dark"] input::placeholder, html[data-theme="dark"] textarea::placeholder { color: #6E7C9E; }
html[data-theme="dark"] input:disabled, html[data-theme="dark"] select:disabled { opacity: .6; }
html[data-theme="dark"] .chip { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
html[data-theme="dark"] .chip:hover { color: #fff; border-color: var(--border-strong); }
html[data-theme="dark"] .chip.active { color: #fff; }
html[data-theme="dark"] .pager-links a { border-color: var(--border); color: var(--text-2); }
html[data-theme="dark"] .badge-blue { background: var(--blue-bg); color: var(--blue); }
html[data-theme="dark"] .badge-teal { background: var(--teal-bg); color: var(--teal); }
html[data-theme="dark"] .alert-success { background: var(--green-bg); border-color: rgba(60, 203, 143, .35); color: #7FE0B5; }
html[data-theme="dark"] .alert-error { background: var(--red-bg); border-color: rgba(255, 122, 122, .35); color: #FFB0B0; }
html[data-theme="dark"] .alert-warning { background: var(--amber-bg); border-color: rgba(245, 181, 69, .35); color: #F8CE7F; }
html[data-theme="dark"] .alert-info { background: var(--accent-50); border-color: rgba(59, 175, 230, .35); color: #9BD8F5; }
html[data-theme="dark"] .notif-item { color: var(--text); }
html[data-theme="dark"] .notif-item:hover { background: var(--surface-2); }
html[data-theme="dark"] .notif-item.unread, html[data-theme="dark"] .dropdown-menu a.notif-item.unread { background: rgba(59, 175, 230, .10); }
html[data-theme="dark"] .timeline .note-body, html[data-theme="dark"] .wa-file { background: var(--surface-3); }
html[data-theme="dark"] .wa-route { background: var(--surface-2); border-color: var(--border); color: var(--text); }
html[data-theme="dark"] .wa-route:hover { background: rgba(37, 211, 102, .10); border-color: #25d366; }
html[data-theme="dark"] .wa-status { background: var(--green-bg); color: #7FE0B5; }
html[data-theme="dark"] .modal { background: rgba(2, 6, 20, .66); }
html[data-theme="dark"] .totals tr.grand td { border-top-color: var(--text); }
html[data-theme="dark"] .progress-steps .step::before, html[data-theme="dark"] .progress-steps .step::after { background: var(--border-strong); }
html[data-theme="dark"] .progress-steps .step.done::before, html[data-theme="dark"] .progress-steps .step.done::after { background: var(--green); }
html[data-theme="dark"] .progress-steps .step.current::before { background: var(--accent); }
html[data-theme="dark"] .attach-list .file-ic { background: var(--accent-50); color: var(--accent); }
html[data-theme="dark"] .tabs a em { background: var(--surface-2); color: var(--text-2); }
html[data-theme="dark"] .auth-body, html[data-theme="dark"] .auth-form-side { background: var(--surface); }
html[data-theme="dark"] .auth-panel, html[data-theme="dark"] .auth-mobile-logo { background: #050A1E; }
html[data-theme="dark"] .auth-card h1 { color: #F1F5FF; }
html[data-theme="dark"] ::selection { background: rgba(59, 175, 230, .35); }
@media print {
  html[data-theme="dark"] { color-scheme: light; --bg: #fff; --surface: #fff; --text: #0A1230; --text-2: #3E4A66; --border: #DFE6F0; }
  html[data-theme="dark"] body, html[data-theme="dark"] .card { background: #fff; color: #0A1230; }
}

/* Line editor: "Add to product list" option */
.add-prod { display: inline-flex; align-items: center; gap: 6px; margin: 5px 0 0 2px; padding: 3px 10px 3px 8px; border-radius: 20px; font-size: 12px; font-weight: 600;
  color: var(--text-2); background: var(--grey-bg); cursor: pointer; user-select: none; }
.add-prod[hidden] { display: none; }
.add-prod input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.add-prod.on { color: var(--accent); background: var(--accent-50); }

/* Register-style lists */
.table th.num-col, .table td.num-col { width: 56px; text-align: center; }
@media (max-width: 860px) {
  .table.register tr { display: flex; flex-direction: column; }
  .table.register td.primary-cell { order: -1; }
  .table.register td.num-col { display: none; }
}
.table.register .primary-cell > a { white-space: nowrap; }
.margin-dl dd .sub { display: block; }
.margin-dl .margin-total { border-top: 1px solid var(--border); padding-top: 8px; font-weight: 700; }
.adj-list li { padding: 9px 18px; font-size: 13px; }
.adj-list .sub { display: block; color: var(--muted); font-size: 12px; }
.rebate-table input { padding: 5px 7px; font-size: 13px; }
.rebate-table td.num input { width: 64px; text-align: right; }
.rebate-table th .sub { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 11px; }
.rebate-table tr.muted-row input { background: var(--bg, #f6f8fb); }
.rebate-lines { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; }
.rebate-lines summary { cursor: pointer; font-weight: 600; }
.rebate-lines .rl { padding: 7px 0; border-bottom: 1px dashed var(--border); }
.rebate-lines .rl:last-of-type { border-bottom: 0; }
.rebate-lines .rl-name { font-weight: 600; }
.rebate-lines .rl-calc .sub { display: block; font-size: 11.5px; }
.rebate-lines .rl-amt { float: right; color: var(--green); font-weight: 600; }
.rebate-lines .rl-pct { width: 64px; padding: 2px 5px; font-size: 12px; display: inline-block; }
.rebate-lines .rl-foot { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding-top: 6px; }

/* Document editor: payment terms picker, single-currency select */
.pt-row { display: flex; gap: 8px; align-items: center; }
.pt-row select { flex: 1; min-width: 0; }
select.locked { pointer-events: none; background-image: none; opacity: .85; }
