/* KaziCore HCM v99 — complete phone/tablet/desktop responsive production shell */
:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #087a55;
  --primary-dark: #065f46;
  --primary-bright: #10b981;
  --soft-primary: #e7f6ef;
  --gold: #d4a72c;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --soft-red: #fee2e2;
  --nav: #0f172a;
  --nav-line: #24314a;
  --success: #087a55;
  --warning: #d97706;
  --info: #2563eb;
  --shadow: 0 18px 45px rgba(16, 10, 30, .08);
  --radius: 18px;
  --radius-sm: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .62; }
a { color: inherit; }
.hidden { display: none !important; }

.app-shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar { background: var(--nav); color: #f7f2f6; display: flex; flex-direction: column; min-height: 100vh; position: sticky; top: 0; }
.logo-block { padding: 24px 18px 18px; border-bottom: 1px solid var(--nav-line); }
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-mark { width: 38px; height: 38px; border-radius: 12px; background: var(--primary); color: white; display: grid; place-items: center; font-weight: 900; letter-spacing: -.03em; }
.logo-copy strong { display: block; font-size: 15px; }
.logo-copy span { display: block; color: #b9b0c3; font-size: 12px; margin-top: 2px; }
.nav { padding: 18px 10px; display: grid; gap: 6px; }
.nav button { width: 100%; background: transparent; color: #cdc6d4; border: 0; border-radius: 14px; padding: 13px 12px; text-align: left; display: flex; align-items: center; gap: 12px; font-weight: 700; transition: .15s ease; }
.nav button:hover { color: white; background: rgba(255,255,255,.06); }
.nav button.active { background: var(--primary); color: white; box-shadow: 0 10px 22px rgba(8, 122, 85, .26); }
.nav button .chev { margin-left: auto; opacity: .72; }
.nav .icon { width: 18px; display: inline-grid; place-items: center; font-size: 16px; opacity: .92; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--nav-line); padding: 16px 14px; display: grid; gap: 12px; }
.user-chip { display: flex; gap: 10px; align-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 12px; flex: 0 0 auto; }
.user-chip strong { font-size: 13px; display: block; }
.user-chip span { font-size: 12px; color: #b9b0c3; display: block; }
.sidebar-bottom button { border: 0; background: transparent; color: #cfc7d8; padding: 8px 4px; text-align: left; font-weight: 700; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 34px; background: rgba(247,247,248,.82); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar h1 { margin: 0; font-family: var(--serif); font-size: clamp(26px, 3vw, 38px); letter-spacing: -.035em; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.content { padding: 30px 34px 60px; max-width: 1400px; }
.section-title { display:flex; justify-content:space-between; align-items:flex-end; gap:16px; margin-bottom:18px; }
.section-title h2 { margin:0; font-family: var(--serif); font-size: 28px; letter-spacing:-.03em; }
.section-title p { margin:5px 0 0; color:var(--muted); }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 12px; padding: 10px 14px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; min-height: 40px; }
.btn:hover { box-shadow: 0 8px 20px rgba(20, 13, 30, .06); transform: translateY(-1px); }
.btn-primary { border-color: var(--primary); background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-danger { border-color: #f2b5bc; color: #b30b16; background: #fff5f6; }
.btn-success { border-color: #bfe7d3; color: #04683d; background: #effaf4; }
.btn-small { padding: 7px 10px; min-height: 32px; border-radius: 10px; font-size: 12px; }

.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)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card.flat { box-shadow:none; }
.card h3 { margin:0 0 10px; font-family:var(--serif); font-size:20px; letter-spacing:-.02em; }
.card p { color: var(--muted); }
.kpi { display:flex; align-items:flex-start; gap:16px; }
.kpi .kpi-icon { width: 48px; height:48px; border-radius:14px; display:grid; place-items:center; background:var(--soft-primary); color:var(--primary); font-size:22px; flex:0 0 auto; }
.kpi strong { font-size:30px; letter-spacing:-.04em; display:block; }
.kpi span { color:var(--muted); font-size:13px; }
.hero { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; align-items: stretch; }
.hero-panel { background: linear-gradient(135deg,#0f172a 0%,#123a35 55%,#087a55 130%); color:white; border-radius:24px; padding:30px; min-height: 260px; box-shadow:0 24px 60px rgba(25,15,35,.16); }
.hero-panel h2 { margin:0 0 10px; font-family:var(--serif); font-size:42px; letter-spacing:-.045em; line-height:1; }
.hero-panel p { color:#e9dce5; max-width:720px; }
.pill-row { display:flex; flex-wrap:wrap; gap:8px; margin-top:22px; }
.pill { display:inline-flex; align-items:center; gap:6px; border-radius:999px; padding:8px 11px; font-size:12px; font-weight:800; background:#f2edf4; color:#342b3c; }
.hero-panel .pill { background:rgba(255,255,255,.14); color:white; border:1px solid rgba(255,255,255,.12); }
.badge { border-radius: 999px; padding: 5px 9px; font-weight: 900; font-size: 11px; letter-spacing:.02em; text-transform: uppercase; display:inline-flex; align-items:center; gap:6px; }
.badge.green { background:#e7f8ef; color:#077245; }
.badge.red { background:#ffe8eb; color:#b40d18; }
.badge.yellow { background:#fff5d6; color:#866000; }
.badge.blue { background:#e8efff; color:#2452b3; }
.badge.gray { background:#eeeaf0; color:#5c5268; }

.table-wrap { overflow:auto; border:1px solid var(--line); border-radius:16px; background:var(--panel); }
table { width:100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 12px 13px; border-bottom:1px solid var(--line); text-align:left; vertical-align:middle; }
th { font-size: 12px; color:#71667b; text-transform: uppercase; letter-spacing:.06em; background:#fbfafc; white-space:nowrap; }
td { font-size: 14px; }
tr:last-child td { border-bottom:0; }
tr:hover td { background:#fffafb; }
.money { font-family: var(--mono); font-weight: 800; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display:inline-block; margin-right: 6px; background: var(--muted); }
.status-active { background: var(--success); }
.status-inactive { background: var(--warning); }

.form-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field { display:grid; gap:7px; }
.field label { color:#4e4558; font-size:12px; font-weight:900; text-transform:uppercase; letter-spacing:.04em; }
.field input, .field select, .field textarea { width:100%; border:1px solid var(--line); border-radius:12px; padding:11px 12px; background:white; color:var(--ink); outline:none; }
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color:#5fb99a; box-shadow: 0 0 0 4px rgba(8,122,85,.10); }
.field small { color: var(--muted); }
.form-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:18px; flex-wrap: wrap; }
.divider { height:1px; background:var(--line); margin:18px 0; }

.modal-backdrop { position:fixed; inset:0; background:rgba(17,11,24,.58); display:grid; place-items:center; z-index:80; padding:20px; }
.modal { width:min(940px, 100%); max-height:92vh; overflow:auto; background:white; border-radius:24px; box-shadow:0 30px 80px rgba(0,0,0,.28); border:1px solid rgba(255,255,255,.2); }
.modal header { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:20px 24px; border-bottom:1px solid var(--line); position:sticky; top:0; background:white; z-index:2; }
.modal header h3 { margin:0; font-family:var(--serif); font-size:24px; }
.modal .modal-body { padding:24px; }
.close-x { border:0; background:#f2edf4; width:36px; height:36px; border-radius:12px; font-weight:900; }

.login-page { min-height:100vh; display:grid; grid-template-columns: 1.1fr .9fr; background:white; }
.login-brand { background: radial-gradient(circle at 18% 22%, rgba(16,185,129,.25), transparent 30%), radial-gradient(circle at 82% 76%, rgba(212,167,44,.12), transparent 28%), linear-gradient(135deg,#0f172a 0%,#102a2b 58%,#087a55 130%); color:white; padding:48px; display:flex; flex-direction:column; justify-content:space-between; }
.login-brand h1 { font-family:var(--serif); font-size: clamp(42px, 6vw, 72px); letter-spacing:-.06em; line-height:.95; margin:0; }
.login-brand p { max-width:640px; color:#eee4ed; font-size:17px; line-height:1.6; }
.login-panel { display:grid; place-items:center; padding:38px; }
.login-card { width:min(440px,100%); background:var(--panel); border:1px solid var(--line); border-radius:24px; padding:28px; box-shadow:var(--shadow); }
.login-card h2 { margin:0 0 6px; font-family:var(--serif); font-size:32px; letter-spacing:-.04em; }
.quick-users { display:grid; gap:8px; margin-top:14px; }
.quick-users button { border:1px solid var(--line); border-radius:12px; background:#fbf9fc; text-align:left; padding:10px 12px; }
.quick-users strong { display:block; }
.quick-users span { display:block; color:var(--muted); font-size:12px; margin-top:3px; }
.alert { border:1px solid #ffd0d5; background:#fff5f6; color:#8b1018; padding:12px; border-radius:12px; margin:14px 0; font-weight:700; }
.notice { border:1px solid #d9e4ff; background:#f3f7ff; color:#23468e; padding:12px; border-radius:12px; margin:14px 0; }

.print-area { font-family:var(--sans); color:#111; }
.payslip { background:white; color:#111; padding:28px; max-width:900px; margin:0 auto; }
.payslip header { display:flex; justify-content:space-between; gap:20px; border-bottom:2px solid #111; padding-bottom:14px; margin-bottom:18px; }
.payslip h1 { font-size:24px; margin:0; }
.payslip h2 { font-size:18px; margin:0 0 8px; }
.payslip .lines { display:grid; grid-template-columns: 1fr 1fr; gap:14px; }
.payslip table { min-width:0; }
.payslip th { color:#111; background:#f1f1f1; }
.payslip .net { font-size:24px; font-weight:900; }

.empty-state { text-align:center; padding:34px; border:1px dashed #d6d0dc; border-radius:18px; background:#fff; }
.empty-state strong { display:block; font-family:var(--serif); font-size:22px; margin-bottom:8px; }
.todo { display:grid; gap:10px; }
.todo-item { display:flex; gap:10px; padding:12px; border:1px solid var(--line); border-radius:14px; background:#fff; }
.todo-item input { margin-top:4px; }
.chart-bar { display:grid; gap:8px; }
.bar { height:10px; border-radius:999px; background:#eeeaf0; overflow:hidden; }
.bar i { display:block; height:100%; background:linear-gradient(90deg,var(--primary),var(--primary-bright)); border-radius:999px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .hero { grid-template-columns:1fr; }
}
@media (max-width: 850px) {
  .app-shell { grid-template-columns:1fr; }
  .sidebar { position:relative; min-height: auto; }
  .nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .sidebar-bottom { display:none; }
  .topbar { position:relative; padding:20px; flex-direction:column; align-items:flex-start; }
  .content { padding:20px; }
  .grid-4, .grid-3, .grid-2, .form-grid, .form-grid.three, .login-page { grid-template-columns:1fr; }
  .login-brand { min-height: 420px; padding:28px; }
}
@media print {
  body { background:white; }
  .no-print, .sidebar, .topbar, .content > *:not(.print-area) { display:none !important; }
  .app-shell { display:block; }
  .main, .content { padding:0; max-width:none; }
  .print-area { display:block !important; }
  .payslip { box-shadow:none; padding:0; max-width:none; }
}

/* Branded document authenticity headers */
.app-logo { width: 38px; height: 38px; border-radius: 12px; object-fit: contain; background: #fff; border: 1px solid rgba(255,255,255,.18); padding: 2px; }
.app-logo-fallback { width: 38px; height: 38px; border-radius: 12px; background: var(--primary); color: white; display: grid; place-items: center; font-weight: 900; letter-spacing: -.03em; }
.document-export-header { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; border-bottom:2px solid #111; padding-bottom:12px; margin-bottom:16px; }
.document-export-company { flex:1; }
.document-export-company h1 { margin:0 0 4px; font-size:22px; color:#111; }
.document-export-company div, .document-export-meta div { font-size:12px; color:#333; line-height:1.35; }
.document-export-meta { text-align:right; min-width:180px; }
.document-export-meta h2 { margin:0 0 6px; font-size:18px; color:#111; }
.document-logo { width:58px; height:58px; object-fit:contain; border:0; border-radius:0; background:transparent; padding:0; }
.document-logo-fallback { width:58px; height:58px; border-radius:10px; border:2px solid #111; display:grid; place-items:center; font-size:18px; font-weight:900; background:#fff; color:#111; }
.document-logo-preview { min-height:82px; display:flex; align-items:center; gap:10px; }
.logo-manager-field { grid-column: span 2; }
.logo-manager { display:flex; align-items:center; gap:14px; border:1px solid var(--line); border-radius:14px; padding:12px; background:#fff; }
.logo-manager input[type="file"] { max-width:100%; margin:8px 0 6px; }
.logo-status { font-size:13px; margin-bottom:4px; }
.logo-actions { display:flex; flex-wrap:wrap; gap:8px; margin:6px 0; }
.btn.ghost { background:#fff; color:var(--ink); border:1px solid var(--line); }
@media(max-width:760px){ .logo-manager-field { grid-column: span 1; } .logo-manager { align-items:flex-start; flex-direction:column; } }
.document-header { align-items:flex-start; }
.document-brand { display:flex; align-items:flex-start; gap:14px; }
.document-brand h1 { margin-top:0; }
@media print {
  .document-export-header, .document-brand { break-inside: avoid; }
}

/* KRA-style P9A annual tax card */
.p9-card { max-width: none; }
.p9-official-header { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; border:2px solid #111; padding:14px; margin:14px 0 10px; background:#fff; }
.p9-official-header h1 { margin:0; font-size:22px; letter-spacing:.02em; }
.p9-official-header h2 { margin:3px 0 6px; font-size:15px; letter-spacing:.04em; }
.p9-badge { border:2px solid #111; padding:10px 18px; font-size:32px; font-weight:900; letter-spacing:.03em; }
.p9-identity-table { width:100%; border-collapse:collapse; margin:10px 0 14px; min-width:0; }
.p9-identity-table td { border:1px solid #111; padding:8px 10px; font-size:13px; width:50%; }
.p9-section { margin-top:18px; }
.p9-section h3 { margin:0 0 6px; font-size:18px; }
.p9-table-wrap { border-radius:0; border-color:#111; }
.p9-table { min-width:1800px; font-size:11px; }
.p9-table th { background:#f2f2f2; color:#111; border:1px solid #555; text-transform:none; letter-spacing:0; white-space:normal; text-align:center; vertical-align:bottom; padding:7px; }
.p9-table td { border:1px solid #777; padding:6px 7px; font-size:11px; }
.p9-table .money { text-align:right; }
.p9-total-row td { background:#fafafa; font-weight:900; }
@media print {
  .p9-card { padding:0; }
  .p9-official-header, .p9-identity-table, .p9-section { break-inside: avoid; }
  .p9-table { font-size:8px; min-width:0; }
  .p9-table th, .p9-table td { padding:3px; font-size:7px; }
}

/* Detailed Kenya payslip template matching the printable PDF/Excel layout */
.payslip-kenya { max-width: 860px; padding: 0 8px 18px; font-family: Arial, sans-serif; font-size: 12px; line-height: 1.25; box-shadow: none; }
.payslip-kenya .payslip-top-header { display:grid; grid-template-columns: 1fr 82px; gap:12px; align-items:flex-start; padding:8px 6px 8px; }
.payslip-kenya .payslip-logo-wrap { text-align: right; padding-top: 0; }
.payslip-kenya .payslip-logo-img { width: 74px; height: 52px; max-width: 74px; max-height: 52px; object-fit: contain; border:0; background:transparent; padding:0; }
.payslip-kenya .payslip-logo-fallback { display: inline-flex; align-items: center; justify-content: center; width: 74px; height: 52px; border:1px solid #111; background:#f7f7f7; color:#111; font-size:18px; font-weight: 800; letter-spacing: -.04em; }
.payslip-kenya .payslip-company-name { text-align: center; font-weight: 700; margin: 8px 0 3px; }
.payslip-kenya .payslip-company-lines { text-align: center; font-size: 10px; color: #333; margin-bottom: 12px; }
.payslip-kenya .payslip-green-line { height: 1px; background: var(--doc-primary,#22a06b); margin: 0 -2px; }
.payslip-kenya .payslip-title { text-align: center; font-size: 14px; padding: 5px 0 14px; color: #111; }
.payslip-kenya .payslip-info-table,
.payslip-kenya .payslip-line-table,
.payslip-kenya .payslip-personal-table { width: 100%; min-width: 0; border-collapse: collapse; table-layout: fixed; }
.payslip-kenya .payslip-info-table td { padding: 2px 8px; font-size: 12px; border: 0; }
.payslip-kenya .payslip-info-table td:first-child { width: 28%; text-align: left; }
.payslip-kenya .payslip-info-table td:last-child { text-align: right; font-weight: 600; }
.payslip-kenya .payslip-block { margin-top: 10px; }
.payslip-kenya .payslip-block-title { font-weight: 700; margin: 8px 0 2px; }
.payslip-kenya .payslip-line-table td { padding: 3px 8px; border: 0; }
.payslip-kenya .payslip-line-table td:first-child { text-align: left; }
.payslip-kenya .payslip-line-table td:last-child { text-align: right; }
.payslip-kenya .payslip-line-table tr:nth-child(odd) { background: #fafafa; }
.payslip-kenya .payslip-total-row td { font-weight: 700; background: #fff; }
.payslip-kenya .payslip-net-row { display: flex; justify-content: space-between; align-items: center; margin: 15px 6px 28px; border-top: 2px solid var(--doc-primary,#22a06b); padding: 8px 2px 0; font-size: 14px; font-weight: 700; }
.payslip-kenya .payslip-personal { border-top: 1px solid var(--doc-primary,#22a06b); border-bottom: 1px solid var(--doc-primary,#22a06b); padding: 4px 0; margin-top: 6px; }
.payslip-kenya .payslip-personal-table td { padding: 2px 8px; font-size: 11px; border: 0; }
.payslip-kenya .payslip-personal-table td:nth-child(1),
.payslip-kenya .payslip-personal-table td:nth-child(3) { width: 18%; font-weight: 500; }
.payslip-kenya .payslip-personal-table td:nth-child(2),
.payslip-kenya .payslip-personal-table td:nth-child(4) { width: 32%; }
.payslip-kenya .payslip-personal-table td:nth-child(4) { text-align: right; }
.payslip-kenya .payslip-created { font-size: 11px; margin: 4px 8px; }
.payslip-kenya .payslip-footer-note { font-size: 10px; color: #444; margin: 8px; }
@media print { .payslip-kenya { margin: 0 auto; max-width: none; padding: 0 2mm 8mm; } }

/* v16 theme controls */
html[data-theme="dark"] {
  --bg: #0b1220;
  --panel: #111c2e;
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --line: #27364d;
  --nav: #07101d;
  --nav-line: #1f3048;
  --soft-primary: rgba(16, 185, 129, .15);
  --soft-red: rgba(220, 38, 38, .16);
  --shadow: 0 18px 45px rgba(0,0,0,.34);
}
html[data-theme="dark"] .card,
html[data-theme="dark"] .table-wrap,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .modal header,
html[data-theme="dark"] .btn,
html[data-theme="dark"] .empty-state,
html[data-theme="dark"] .todo-item,
html[data-theme="dark"] .quick-users button,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea { background: var(--panel); color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] th { background:#132238; color:#cbd5e1; }
html[data-theme="dark"] tr:hover td { background:#14243a; }
html[data-theme="dark"] .topbar { background: rgba(11,18,32,.90); }
html[data-theme="dark"] .hero-panel { background: linear-gradient(135deg,#07101d 0%,#0d302c 58%,#087a55 130%); }
html[data-theme="dark"] .notice { background:#151f33; border-color:#29406f; color:#cbdcff; }
html[data-theme="dark"] .pill { background:#1f3048; color:#e2e8f0; }
html[data-theme="dark"] .field label { color:#cbd5e1; }

/* v16 document header rule: logo first, company profile after, no overlap */
.stacked-document-header,
.document-export-header.stacked-document-header { display:block; text-align:center; border-bottom:2px solid #111; padding-bottom:12px; margin-bottom:16px; }
.document-export-logo-main { display:flex; justify-content:center; align-items:center; margin-bottom:6px; }
.document-logo-main,
.document-logo.document-logo-main { width:74px; height:56px; max-width:74px; max-height:56px; object-fit:contain; border:0; border-radius:0; background:transparent; padding:0; }
.document-logo-main-fallback,
.document-logo.document-logo-main-fallback { width:74px; height:56px; max-width:74px; max-height:56px; }
.document-export-company-centered h1 { text-align:center; margin:0 0 4px; }
.document-export-company-centered div { text-align:center; }
.document-export-meta-centered { text-align:center; margin-top:6px; }

.payslip-kenya .payslip-logo-main-wrap { text-align:center; padding:8px 6px 4px; }
.payslip-kenya .payslip-logo-wrap { text-align:center; }
.payslip-kenya .payslip-logo-img { width:82px; height:58px; max-width:82px; max-height:58px; object-fit:contain; }
.payslip-kenya .payslip-logo-fallback { width:82px; height:58px; }
.payslip-kenya .payslip-company-block { text-align:center; }
.payslip-kenya .payslip-company-name { text-align:center; }
.payslip-kenya .payslip-company-lines { text-align:center; display:block; }

/* v16 KRA P9A standard fields only */
.p9-table { min-width: 1650px; }
.p9-declaration { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap:8px 16px; border:1px solid #111; border-top:0; padding:10px; font-size:12px; background:#fff; }
.p9-declaration div { min-height:22px; }
html[data-theme="dark"] .p9-declaration,
html[data-theme="dark"] .payslip-kenya,
html[data-theme="dark"] .p9-card { background:#fff; color:#111; }
@media print { .p9-declaration { font-size:9px; gap:4px; padding:6px; } }

.nav-section-label{
  margin:14px 12px 7px;
  padding-top:12px;
  border-top:1px solid var(--border);
  color:var(--muted);
  font-size:11px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.08em;
}

/* v20 workflow highlights */
tr.row-warning td { background: rgba(245, 158, 11, 0.12) !important; }
tr.row-danger td { background: rgba(220, 38, 38, 0.08) !important; }
.badge.gray { background: #e5e7eb; color: #374151; }
.badge.yellow { background: #fef3c7; color: #92400e; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.blue { background: #dbeafe; color: #1e40af; }
.hr-document-preview { white-space: pre-wrap; border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--card); line-height: 1.55; }

/* v23 responsive and support refinements */
.help-support { display:grid; gap:14px; }
.help-support .card.flat { border-radius:14px; }
@media (max-width: 680px) {
  .nav { grid-template-columns: 1fr; }
  .top-actions { width:100%; }
  .top-actions .btn, .top-actions label.btn { flex:1 1 160px; }
  .section-title { flex-direction:column; align-items:stretch; }
  .card { padding:16px; border-radius:14px; }
  .hero-panel { padding:22px; min-height:auto; }
  .hero-panel h2 { font-size:34px; }
  th, td { padding:10px 9px; font-size:13px; }
  .modal-backdrop { padding:8px; align-items:start; }
  .modal { max-height:96vh; border-radius:18px; }
  .modal header { padding:14px 16px; }
  .modal .modal-body { padding:16px; }
  .payslip-kenya { width:100%; padding:0 2px 16px; font-size:11px; }
  .payslip-kenya .payslip-personal-table td { display:block; width:100% !important; text-align:left !important; }
}
@media (max-width: 420px) {
  .topbar h1 { font-size:24px; }
  .btn { width:100%; }
  .pill-row { gap:6px; }
  .pill { width:100%; justify-content:center; }
  .kpi strong { font-size:24px; }
  .login-panel, .login-brand { padding:20px; }
}

/* v24 per-user theme selector */
.theme-toggle{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--line);background:var(--card);border-radius:12px;padding:6px 8px;font-size:12px;color:var(--muted);min-height:38px}
.theme-toggle select{border:0;background:transparent;color:var(--ink);font-weight:700;outline:none;min-width:84px}
html[data-theme="dark"] .theme-toggle select option{background:#18141d;color:#f2eef5}
@media (max-width:720px){.theme-toggle{width:100%;justify-content:space-between}.theme-toggle select{flex:1;text-align:right}}

/* v25 sales tracking grids */
.sales-grid table { min-width: 960px; }
.sales-grid input[type="number"] { width: 110px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); text-align: right; }
.sales-grid .btn-small { min-width: 96px; justify-content: flex-end; }
.row-warning { background: rgba(245, 158, 11, 0.13) !important; }
[data-theme="dark"] .row-warning { background: rgba(245, 158, 11, 0.20) !important; }
.notice.success { border-color: rgba(34, 197, 94, .35); background: rgba(34, 197, 94, .10); }
.notice.alert { border-color: rgba(239, 68, 68, .35); background: rgba(239, 68, 68, .10); }
@media (max-width: 900px) {
  .sales-grid table { min-width: 760px; }
  .sales-grid input[type="number"] { width: 88px; }
}

/* v26 collapsible navigation: desktop icon rail + mobile off-canvas drawer */
.app-shell,
.sidebar,
.main,
.nav button,
.logo-copy,
.nav-label,
.sidebar-bottom,
.topbar { transition: grid-template-columns .18s ease, width .18s ease, transform .18s ease, padding .18s ease, opacity .12s ease; }
.app-shell.sidebar-collapsed { grid-template-columns: 76px 1fr; }
.sidebar-backdrop { display:none; }
.sidebar-toggle { width:40px; height:40px; border:1px solid var(--line); border-radius:12px; background:var(--panel); color:var(--ink); display:inline-grid; place-items:center; font-size:19px; font-weight:900; flex:0 0 auto; }
.sidebar-toggle:hover { box-shadow:0 8px 20px rgba(20, 13, 30, .08); transform:translateY(-1px); }
.sidebar-toggle-inside { margin-left:auto; width:34px; height:34px; background:rgba(255,255,255,.08); color:#fff; border-color:rgba(255,255,255,.16); }
.topbar-title { display:flex; align-items:center; gap:12px; min-width:0; }
.topbar-title > div { min-width:0; }
.app-shell.sidebar-collapsed .logo-block { padding-left:12px; padding-right:12px; }
.app-shell.sidebar-collapsed .logo-row { justify-content:center; gap:0; }
.app-shell.sidebar-collapsed .logo-copy,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .nav-section-label,
.app-shell.sidebar-collapsed .user-chip-copy { display:none; }
.app-shell.sidebar-collapsed .sidebar-toggle-inside { display:none; }
.app-shell.sidebar-collapsed .nav { padding-left:8px; padding-right:8px; }
.app-shell.sidebar-collapsed .nav button { justify-content:center; padding:13px 0; gap:0; }
.app-shell.sidebar-collapsed .nav .icon { width:100%; font-size:18px; }
.app-shell.sidebar-collapsed .sidebar-bottom { padding:12px 8px; align-items:center; }
.app-shell.sidebar-collapsed .user-chip { justify-content:center; }
.app-shell.sidebar-collapsed .sidebar-bottom button { display:flex; justify-content:center; align-items:center; padding:10px 0; text-align:center; border-radius:10px; }
.app-shell.sidebar-collapsed .sidebar-bottom button .icon { width:auto; font-size:17px; }

@media (max-width: 850px) {
  .app-shell,
  .app-shell.sidebar-collapsed,
  .app-shell.sidebar-expanded { grid-template-columns: 1fr; }
  .sidebar { position:fixed; z-index:75; top:0; left:0; bottom:0; width:min(310px, 86vw); min-height:100vh; transform:translateX(0); box-shadow:0 24px 70px rgba(0,0,0,.32); }
  .app-shell.sidebar-collapsed .sidebar { transform:translateX(-110%); }
  .app-shell.sidebar-expanded .sidebar-backdrop { display:block; position:fixed; inset:0; z-index:70; border:0; background:rgba(15,10,22,.55); padding:0; }
  .app-shell.sidebar-expanded .logo-copy,
  .app-shell.sidebar-expanded .nav-label,
  .app-shell.sidebar-expanded .nav-section-label,
  .app-shell.sidebar-expanded .user-chip-copy { display:block; }
  .app-shell.sidebar-expanded .sidebar-toggle-inside { display:inline-grid; }
  .app-shell.sidebar-expanded .nav button { justify-content:flex-start; padding:13px 12px; gap:12px; }
  .app-shell.sidebar-expanded .nav .icon { width:18px; }
  .app-shell.sidebar-expanded .sidebar-bottom { display:grid; }
  .app-shell.sidebar-expanded .sidebar-bottom button { display:flex; gap:10px; align-items:center; justify-content:flex-start; }
  .logo-block { padding:18px 16px; }
  .nav { display:grid; grid-template-columns:1fr; max-height:calc(100vh - 178px); overflow:auto; padding:14px 10px; }
  .sidebar-bottom { display:grid; }
  .topbar { position:sticky; top:0; padding:14px 16px; flex-direction:column; align-items:stretch; gap:12px; }
  .topbar-title { width:100%; align-items:flex-start; }
  .topbar-title h1 { line-height:1.05; }
  .content { padding:16px; }
  body:has(.app-shell.sidebar-expanded) { overflow:hidden; }
}

@media (max-width: 420px) {
  .topbar-title { gap:9px; }
  .sidebar-toggle { width:38px; height:38px; }
}

/* v28 sales dashboard cleanup and payslip acknowledgement */
.sales-dashboard-section { margin-bottom: 18px; }
.sales-dashboard-section > .card + .card { margin-top: 18px; }
.sales-rank-bar .bar i { transition: width .25s ease; }
.payslip-acknowledgement { margin-top: 12px; border: 1px solid var(--doc-primary,#22a06b); padding: 0; background: #fff; }
.payslip-acknowledgement p { margin: 10px 8px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.ack-sign-grid { display: grid; grid-template-columns: 1fr 190px; gap: 12px; padding: 8px; font-size: 11px; }
@media (max-width: 680px) { .ack-sign-grid { grid-template-columns: 1fr; } }


/* v29 unframed uploaded document logos */
.document-logo,
.document-logo.document-logo-main,
.payslip-kenya .payslip-logo-img,
.payslip-pdf-sheet .payslip-logo-img,
.p9-pdf-sheet .document-logo {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  padding: 0 !important;
  box-shadow: none !important;
}

/* v32 KRA P9A 2025 template structure */
.p9-kra-template-header{background:#fff;color:#111;margin:0 0 10px;padding:4px 0 8px;font-family:Arial,Helvetica,sans-serif}
.p9-kra-template-header .p9-iso{text-align:center;font-size:10px;font-weight:700;margin-bottom:4px}.p9-kra-template-header .p9-kra-title{text-align:center;font-size:14px;line-height:1.15;margin-bottom:5px}.p9-kra-template-header .p9-kra-title span{font-size:10px;font-weight:700}.p9-kra-template-header .p9-appendix{font-size:10px;font-weight:700;margin-bottom:5px}.p9-identity-lines{display:grid;gap:5px;font-size:11px}.p9-identity-lines>div{display:grid;grid-template-columns:auto 1fr auto 1fr;gap:8px;align-items:end}.p9-identity-lines>div:nth-child(2),.p9-identity-lines>div:nth-child(4){grid-template-columns:auto 1fr}.p9-identity-lines span{border-bottom:1px dotted #111;min-height:14px;padding:0 6px}.p9-template-table{table-layout:fixed;font-size:9px}.p9-template-table th,.p9-template-table td{border:1px solid #111!important;color:#111!important}.p9-template-table thead th{background:#d9d9d9!important;color:#111!important;text-align:center;vertical-align:middle;padding:4px 3px;white-space:normal;line-height:1.1}.p9-template-table .p9-header-main th{font-weight:700}.p9-template-table .p9-kshs-row th,.p9-template-table .p9-letter-row th,.p9-template-table .p9-sub-letter-row th{font-size:8px;padding:3px 2px}.p9-template-table tbody td{padding:3px 4px;font-size:9px;line-height:1.05}.p9-template-table .p9-month{font-weight:700;text-align:left}.p9-template-table .p9-total-row td{font-weight:900;background:#f2f2f2!important;border-top:2px solid #111!important}.p9-important-grid{display:grid;grid-template-columns:1.6fr 1fr;gap:18px;margin-top:8px;font-size:10px;color:#111}.p9-important-grid ol{margin:4px 0 0 18px;padding:0}.p9-important-grid li{margin:2px 0}.p9-declaration{border:0!important;border-top:0!important;margin-top:8px;font-size:11px;display:grid;grid-template-columns:1fr 1fr;gap:8px}.p9-declaration div:nth-child(n+3){grid-column:auto}.p9-template-section h3{font-size:13px;text-transform:uppercase;margin-bottom:5px}.p9-table-wrap{border:0!important}
@media(max-width:900px){.p9-identity-lines>div{grid-template-columns:1fr}.p9-identity-lines strong{margin-top:4px}.p9-important-grid{grid-template-columns:1fr}.p9-template-table{min-width:1500px}.p9-table-wrap{overflow:auto!important}}

/* v33 P9A company logo/header and readable column titles */
.p9-company-header{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;border-bottom:1px solid #111;padding:4px 0 8px;margin-bottom:8px;background:#fff;color:#111}
.p9-company-header .document-logo{width:96px;height:58px;object-fit:contain;border:0!important;background:transparent!important;padding:0!important;box-shadow:none!important}
.p9-company-name{font-size:15px;font-weight:800;line-height:1.2;margin-top:2px;color:#111}
.p9-company-details{font-size:10px;line-height:1.25;color:#111;max-width:1100px}
.p9-template-table thead th{word-break:normal!important;overflow-wrap:normal!important;hyphens:none!important;white-space:normal!important;line-height:1.18!important}
.p9-template-table{min-width:1900px!important}
@media print{.p9-company-header .document-logo{border:0!important;background:transparent!important;padding:0!important;box-shadow:none!important}}

/* v35 employee search and HR issue letterhead */
.search-card input { width:100%; }
.compact-title { margin-bottom:10px; }
.hr-letterhead { border-bottom:1px solid var(--line); margin:0 0 16px; padding:0 0 14px; text-align:center; display:grid; gap:8px; }
.hr-letterhead-logo { display:flex; justify-content:center; align-items:center; }
.hr-letterhead-img { max-width:160px; max-height:70px; width:auto; height:auto; border:0!important; background:transparent!important; box-shadow:none!important; padding:0!important; object-fit:contain; }
.hr-letterhead-company h2 { margin:0 0 4px; font-size:18px; }
.hr-letterhead-company div { font-size:12px; color:var(--muted); line-height:1.4; }
.hr-letterhead-title { display:grid; gap:2px; font-size:13px; }
.hr-letterhead-title span { color:var(--muted); font-size:11px; }
@media (max-width: 720px) { .search-card .form-grid { grid-template-columns:1fr; } .search-card .field[style] { grid-column:auto!important; } }

/* v37 HR issue template manager */
.template-download-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:10px; margin-top:10px; }
.template-checklist { margin:12px 0; border-left:4px solid var(--accent); }
.template-check-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:8px 14px; margin-top:10px; }
.template-check { display:flex; align-items:center; gap:8px; padding:8px 10px; border:1px solid var(--line); border-radius:10px; background:var(--panel); font-size:13px; }
.template-check input { width:16px; height:16px; accent-color:var(--accent); }
.hr-letterhead .document-logo { max-height:72px; max-width:210px; object-fit:contain; }
@media (max-width:720px){ .template-check-grid,.template-download-grid{ grid-template-columns:1fr; } }

/* v38 HR issue Word-template editor */
.word-template-shell {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,248,252,.96));
  padding: 16px;
  margin: 14px 0;
}
.word-template-shell .hr-letterhead {
  margin-bottom: 14px;
}
.word-template-shell textarea {
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}
.hr-word-body {
  white-space: pre-wrap;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  line-height: 1.5;
}
.template-checklist {
  margin-top: 12px;
}
.template-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}
.template-check {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  font-size: .9rem;
}
.template-check input {
  width: 16px;
  height: 16px;
}

/* v39 visual HR Word templates */
.word-template-shell {
  background: #f6f7f9;
  overflow-x: auto;
}
.word-template-shell .hr-word-letterhead,
.hr-word-letterhead {
  border: 0;
  display: block;
  text-align: initial;
  padding: 0;
  margin: 0 0 18px;
}
.hr-word-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  width: 100%;
}
.hr-word-letterhead .hr-letterhead-logo {
  justify-content: flex-start;
  flex: 0 0 240px;
}
.hr-word-letterhead .document-logo,
.hr-word-letterhead .hr-letterhead-img {
  max-width: 220px;
  max-height: 82px;
  object-fit: contain;
  border: 0!important;
  background: transparent!important;
  box-shadow: none!important;
  padding: 0!important;
}
.hr-word-letterhead .hr-letterhead-company {
  flex: 1;
  text-align: right;
  color: #2c2d33;
}
.hr-word-letterhead .hr-letterhead-company h2 {
  margin: 0 0 3px;
  font-size: 15px;
  line-height: 1.2;
  color: #2c2d33;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.hr-word-letterhead .hr-letterhead-company div {
  font-size: 11px;
  color: #2c2d33;
  line-height: 1.35;
}
.hr-word-letterhead .hr-letterhead-company small {
  display: block;
  margin-top: 5px;
  color: #91aa16;
  font-weight: 800;
}
.hr-word-green-rule {
  border-top: 7px solid #b4d334;
  margin-top: 18px;
}
.hr-template-editor-field label {
  margin-bottom: 8px;
}
.hr-template-editor {
  width: 100%;
  min-width: 780px;
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 30px;
  background: #fff;
  border: 1px solid #d9dee4;
  border-radius: 0;
  color: #2c2d33;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 10pt;
  line-height: 1.28;
  overflow: auto;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
}
.hr-template-editor[contenteditable="true"]:focus {
  outline: 2px solid rgba(255, 28, 47, .38);
  outline-offset: 4px;
}
.hr-template-editor[contenteditable="false"] {
  background: #fafafa;
}
.hr-document-html table {
  border-collapse: collapse;
  max-width: 100%;
}
.hr-document-html td,
.hr-document-html th {
  vertical-align: top;
}
.hr-document-html p {
  margin-top: 0;
  margin-bottom: 7px;
}
.hr-document-html center {
  display: block;
  text-align: center;
}
.hr-document-html img {
  max-width: 100%;
  height: auto;
}
.hr-check-symbol {
  display: inline-block;
  min-width: 1em;
  cursor: pointer;
  font-family: "Segoe UI Symbol", "Arial Unicode MS", Arial, sans-serif;
  font-weight: 800;
  color: #111827;
  user-select: none;
}
.hr-check-symbol:hover {
  transform: scale(1.08);
}
.legacy-template-html p {
  margin: 0 0 7px;
}
@media (max-width: 860px) {
  .hr-template-editor { min-width: 720px; padding: 22px; }
  .hr-word-head-row { min-width: 720px; }
}

/* v40 sales entry freeze panes and uploaded-template style */
.sales-freeze-grid { max-height: 72vh; position: relative; }
.sales-freeze-grid table { border-collapse: separate; border-spacing: 0; min-width: 1400px; }
.sales-freeze-grid th { position: sticky; top: 0; z-index: 4; background: var(--panel); }
.sales-freeze-grid thead tr:nth-child(2) th { top: 38px; z-index: 4; }
.sales-freeze-grid .sticky-col,
.sales-freeze-grid .sticky-col-2 { position: sticky; background: var(--panel); z-index: 5; box-shadow: 1px 0 0 var(--line); }
.sales-freeze-grid .sticky-col { left: 0; min-width: 116px; }
.sales-freeze-grid .sticky-col-2 { left: 116px; min-width: 118px; }
.sales-freeze-grid thead .sticky-col,
.sales-freeze-grid thead .sticky-col-2 { z-index: 7; }
.sales-freeze-grid .date-cell,
.sales-freeze-grid .day-cell { text-align:left; white-space:nowrap; }
.shop-wide-sales .sticky-col { min-width: 124px; }
.employee-wide-sales .sticky-col { min-width: 116px; }
.employee-wide-sales .sticky-col-2 { left: 116px; min-width: 124px; }
.shop-branch-title { text-transform: uppercase; font-weight: 900; text-align:center; background: rgba(245, 158, 11, .12) !important; }
.branch-separator { background: #fff200 !important; min-width: 10px; width: 10px; padding: 0 !important; border-color: #fff200 !important; }
.sales-total-row td { font-weight: 900; background: rgba(15, 23, 42, .06); border-top: 2px solid var(--ink); }
[data-theme="dark"] .sales-freeze-grid .sticky-col,
[data-theme="dark"] .sales-freeze-grid .sticky-col-2,
[data-theme="dark"] .sales-freeze-grid th { background: var(--panel); }

/* v41: keep session/logout controls directly after the last visible dashboard menu item */
.nav .nav-session-actions {
  margin-top: 8px !important;
  border-top: 1px solid var(--nav-line);
  padding: 12px 4px 4px;
  display: grid;
  gap: 10px;
}
.sidebar-bottom.nav-session-actions button {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  padding: 10px 8px;
}
.app-shell.sidebar-collapsed .nav .nav-session-actions {
  padding-left: 0;
  padding-right: 0;
}

.secure-login-note{margin-top:14px;text-align:center;font-size:12px}

/* v43: notification counters and tasks/reminders UI */
.nav-badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ff1724;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(255,23,36,.28);
}
.nav button.active .nav-badge { background:#fff; color:var(--danger); }
.count-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--soft-red);
  color: var(--danger);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
  vertical-align: middle;
}
.app-shell.sidebar-collapsed .nav-badge {
  position: absolute;
  right: 7px;
  top: 5px;
  margin-left: 0;
  transform: scale(.86);
}
.app-shell.sidebar-collapsed .nav button { position: relative; }

/* v45: dashboard maintenance, task sharing controls, sales daily totals */
.dashboard-maintenance-list { display: grid; gap: 10px; }
.dashboard-maintenance-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--panel); }
.dashboard-maintenance-row .top-actions { justify-content: flex-end; }
.daily-shop-total-head, .daily-shop-total { background: rgba(34, 160, 107, .12) !important; font-weight: 900; min-width: 145px; }
.sales-total-row .daily-shop-total { background: rgba(34, 160, 107, .22) !important; }
@media (max-width: 760px) { .dashboard-maintenance-row { align-items: flex-start; flex-direction: column; } }

/* v46: digital company stamp and separated sales report controls */
.company-stamp-preview { min-width: 122px; min-height: 96px; justify-content: center; border: 1px dashed var(--line); border-radius: 12px; background: #fff; }
.company-stamp-preview-img { max-width: 132px; max-height: 96px; object-fit: contain; border: 0 !important; background: transparent !important; padding: 0 !important; box-shadow: none !important; }
.company-stamp-preview-img-fallback { display: grid; place-items: center; width: 132px; height: 84px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 11px; font-weight: 800; text-align: center; padding: 8px; }
.company-stamp-approval-preview { display: flex; justify-content: center; align-items: center; margin: 12px 0; padding: 12px; border: 1px dashed var(--line); border-radius: 14px; background: #fff; }
.digital-stamp-block { pointer-events: none; }
.disabled { opacity: .6; }

/* v50: module controls and organized settings hierarchy */
.module-control-card { border: 1px solid var(--line); }
.settings-main-card > form > h3,
.settings-subhead {
  grid-column: 1 / -1;
  margin: 18px 0 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(8,122,85,.08);
  color: var(--ink);
  font-weight: 900;
  letter-spacing: .02em;
}
.settings-main-card > form > p.small { margin-top: -4px; margin-bottom: 12px; }
.module-control-card .table-wrap table td { vertical-align: top; }

/* v52: gender-specific leave indicators */
.badge.purple { background:#f3e8ff; color:#6b21a8; }
[data-gender-leave] { min-width: 0; }

/* v54 security and read-only HR document controls */
.link-button { border:0; background:transparent; color:var(--primary); font-weight:800; cursor:pointer; padding:0; text-decoration:underline; }
.employee-readonly-document .hr-doc-viewonly,
.hr-doc-viewonly { border:1px solid var(--line); border-radius:14px; background:var(--panel); padding:18px; max-height:62vh; overflow:auto; pointer-events:auto; user-select:text; }
.employee-readonly-document input,
.employee-readonly-document textarea,
.employee-readonly-document select,
.hr-doc-viewonly input,
.hr-doc-viewonly textarea,
.hr-doc-viewonly select { pointer-events:none; user-select:none; }
.secure-login-note .link-button { font-size:12px; }

/* v55 collapsible dashboard sections */
.collapse-card {
  margin: 0 0 18px;
  padding: 0;
  overflow: hidden;
}
.collapse-card > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  user-select: none;
}
.collapse-card > summary::-webkit-details-marker { display: none; }
.collapse-card > summary strong {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  color: var(--ink);
}
.collapse-card > summary span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}
.collapse-card > summary i {
  flex: 0 0 auto;
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
  color: var(--danger);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--surface);
}
.collapse-card:not([open]) > summary { border-bottom: 0; }
.collapse-card .collapse-body {
  padding: 18px;
}
.collapse-card .collapse-body > .card,
.collapse-card .collapse-body > section.card {
  box-shadow: none;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}
.report-group {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: var(--panel);
}
.report-group h4 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 18px;
}

/* v57: collapsible Settings sections */
.settings-collapse-stack { display: grid; gap: 16px; margin-top: 18px; }
.settings-main-card { padding: 0; background: transparent; border: 0; box-shadow: none; }
.settings-main-card .collapse-card { margin-bottom: 16px; }
.settings-main-card .collapse-card .collapse-body { padding-top: 14px; }
.danger-flat { border-color: rgba(231, 42, 54, .35) !important; background: rgba(231, 42, 54, .04) !important; }
.settings-collapse-stack .card.flat, .settings-main-card .card.flat { box-shadow: none; }

/* v58: in-app success/error messages instead of browser alert popups */
.toast-root {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 99999;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 28px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 34px 1fr 28px;
  gap: 10px;
  align-items: start;
  padding: 14px 14px;
  border-radius: 16px;
  background: var(--card, #fff);
  color: var(--ink, #12142d);
  border: 1px solid var(--line, #ddd);
  box-shadow: 0 18px 45px rgba(15, 18, 40, .18);
  animation: toastIn .22s ease-out;
}
.toast-icon {
  width: 30px;
  height: 30px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}
.toast-copy strong { display:block; font-weight:900; margin-bottom:3px; }
.toast-copy p { margin:0; font-size:13px; line-height:1.35; }
.toast-close { border:0; background:transparent; color:inherit; font-size:20px; line-height:1; cursor:pointer; opacity:.72; }
.toast-success { border-left: 5px solid #22a06b; }
.toast-success .toast-icon { background: rgba(34,160,107,.14); color:#087443; }
.toast-error { border-left: 5px solid #d92d20; }
.toast-error .toast-icon { background: rgba(217,45,32,.14); color:#b42318; }
.toast-warning { border-left: 5px solid #f79009; }
.toast-warning .toast-icon { background: rgba(247,144,9,.16); color:#b54708; }
.toast-info { border-left: 5px solid #2e90fa; }
.toast-info .toast-icon { background: rgba(46,144,250,.14); color:#175cd3; }
.code-box {
  white-space: pre-wrap;
  overflow:auto;
  background: rgba(15, 18, 40, .05);
  border: 1px solid var(--line, #ddd);
  border-radius: 12px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
@keyframes toastIn { from { opacity:0; transform: translateY(-8px); } to { opacity:1; transform: translateY(0); } }
@media (max-width: 700px) { .toast-root { right: 10px; top: 10px; } }

/* v59 enterprise HRM suite */
.enterprise-suite-note { border-left:4px solid var(--primary); padding:10px 12px; background:var(--soft-primary); border-radius:12px; margin:12px 0; }
.collapse-card .card.flat .section-title h3 { margin:0; }
.badge.purple { background:rgba(126,87,194,.14); color:#6f42c1; }
.security-policy-note { border:1px dashed var(--line); border-radius:14px; padding:12px; background:var(--panel); }

/* v60 enterprise templates and persistent collapsible UX */
.suite-template-panel { margin-bottom: 14px; border-style: dashed; }
.template-preview { white-space: pre-wrap; max-height: 260px; overflow: auto; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-family: var(--sans); font-size: 12px; line-height: 1.45; }
.collapse-card[open] > summary i::after { content: ""; }
.collapse-card summary { cursor: pointer; user-select: none; }

/* v64 enterprise template rendering and editor reliability */
.hr-editor-help {
  display: block;
  margin: -2px 0 10px;
  line-height: 1.45;
}
.hr-template-editor[contenteditable="true"] {
  cursor: text;
  caret-color: #111827;
}
.hr-template-editor[contenteditable="true"]:hover {
  border-color: rgba(255, 28, 47, .45);
}
.enterprise-template-form .enterprise-template-actions,
.enterprise-template-form > .form-actions:last-child {
  position: sticky;
  bottom: -24px;
  z-index: 6;
  margin: 18px -24px -24px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(8px);
}
html[data-theme="dark"] .enterprise-template-form .enterprise-template-actions,
html[data-theme="dark"] .enterprise-template-form > .form-actions:last-child {
  background: rgba(27,23,32,.97);
}
.template-check span {
  overflow-wrap: anywhere;
}
@media (max-width: 680px) {
  .enterprise-template-form .enterprise-template-actions,
  .enterprise-template-form > .form-actions:last-child {
    bottom: -16px;
    margin: 18px -16px -16px;
    padding: 12px 16px;
  }
}

/* v65 AI Assistant, report studio and notification channel UI */
.ai-provider-card{border-left:5px solid var(--primary,#2f8f4e)}
.ai-provider-card code,.notice code{font-family:Consolas,monospace;background:rgba(15,23,42,.07);padding:2px 5px;border-radius:4px}
.ai-query-card textarea{width:100%;resize:vertical}
.ai-response-panel{margin-top:14px;border:1px solid var(--border,#d8dce5);border-radius:14px;padding:16px;background:var(--card,#fff)}
.ai-response-heading{display:flex;justify-content:space-between;gap:12px;align-items:flex-start;border-bottom:1px solid var(--border,#d8dce5);padding-bottom:10px;margin-bottom:12px}
.ai-response-heading h3{margin:7px 0 0}.ai-answer p{margin:0 0 10px}.ai-answer ul{margin:4px 0 12px 22px}.ai-spacer{height:6px}
.ai-sources{margin-top:14px}.ai-sources h4{margin-bottom:8px}.ai-source-card{display:grid;grid-template-columns:minmax(150px,1fr) auto;gap:4px 12px;border:1px solid var(--border,#d8dce5);border-radius:10px;padding:9px 11px;margin-bottom:7px}
.ai-source-card small{grid-column:1/-1;color:var(--muted,#6b7280)}
.ai-report-actions{margin-top:15px;border:1px solid rgba(47,143,78,.35);background:rgba(47,143,78,.08);border-radius:12px;padding:12px;display:grid;gap:8px}
.ai-history{max-height:470px;overflow:auto;padding-right:4px}.ai-message{border:1px solid var(--border,#d8dce5);border-radius:12px;padding:10px 12px;margin-bottom:9px;background:var(--card,#fff)}
.ai-message.user{border-left:4px solid #2563eb}.ai-message.assistant{border-left:4px solid #2f8f4e}.ai-message>span{float:right;font-size:11px;color:var(--muted,#6b7280)}.ai-message p{margin:8px 0 0;line-height:1.45}
@media(max-width:720px){.ai-response-heading{display:block}.ai-response-heading small{display:block;margin-top:6px}.ai-source-card{grid-template-columns:1fr}.ai-source-card small{grid-column:auto}.ai-message>span{float:none;display:block;margin-top:3px}}

/* v67 startup shell: visible while the application state and remote connection initialize. */
.startup-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--page-bg, #f3f4f6); }
.startup-card { width: min(520px, 100%); padding: 34px; text-align: center; border: 1px solid #e5e7eb; border-radius: 20px; background: #ffffff; box-shadow: 0 20px 50px rgba(17, 24, 39, 0.10); color: #111827; }
.startup-card h1 { margin: 10px 0 8px; font-size: clamp(1.45rem, 3vw, 2rem); }
.startup-card p { margin: 0; color: #4b5563; }
.startup-spinner { width: 38px; height: 38px; margin: 0 auto 14px; border: 4px solid #e5e7eb; border-top-color: #166534; border-radius: 50%; animation: hrm-startup-spin .8s linear infinite; }
.startup-error { border-color: #fecaca; background: #fff7f7; }
@keyframes hrm-startup-spin { to { transform: rotate(360deg); } }

/* v72: calendar controls, KPI containment and dashboard-specific action cleanup */
.picker-field { display:flex; align-items:stretch; gap:8px; min-width:0; }
.picker-field > input, .picker-field > select { min-width:0; flex:1 1 auto; width:100%; }
.btn-calendar { flex:0 0 44px !important; width:44px; min-width:44px; padding:8px; font-size:17px; }
.dashboard-neutral-actions { justify-content:flex-end; }
.kpi { min-width:0; overflow:hidden; }
.kpi > div:last-child { min-width:0; flex:1 1 auto; overflow:hidden; }
.kpi strong { max-width:100%; font-size:clamp(18px, 2.1vw, 30px); line-height:1.05; overflow-wrap:anywhere; word-break:break-word; white-space:normal; font-variant-numeric:tabular-nums; }
.kpi span { display:block; margin-top:6px; overflow-wrap:anywhere; }
.public-holiday-manager .table-wrap { max-height:520px; }
.public-holiday-manager table { min-width:680px; }
@media (max-width: 850px) {
  .dashboard-neutral-actions { width:auto; }
  .dashboard-neutral-actions .theme-toggle { width:auto; }
  .picker-field { width:100%; }
  .kpi strong { font-size:clamp(17px, 6vw, 24px); }
}

/* v73 responsive containment audit: prevent wide dashboard content from expanding page grid tracks. */
.grid,
.grid > *,
.card,
.table-wrap,
.ai-query-card,
.ai-provider-card,
.ai-history,
.todo {
  min-width: 0;
  max-width: 100%;
}
.table-wrap { width: 100%; overflow-x: auto; }
@media (max-width: 900px) {
  .content .grid.grid-2,
  .content .grid.grid-3,
  .content .grid.grid-4 {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* v74 KaziCore commercial identity */
.kazicore-mark { width:40px; height:40px; flex:0 0 auto; border-radius:13px; display:inline-grid; place-items:center; background:var(--primary); color:#fff; box-shadow:0 10px 24px rgba(8,122,85,.22); overflow:hidden; }
.kazicore-mark svg { width:31px; height:31px; display:block; }
.kazicore-mark .kazicore-core-dot { fill:var(--gold); stroke:none; }
.kazicore-mark-lg { width:48px; height:48px; border-radius:15px; }
.kazicore-mark-lg svg { width:37px; height:37px; }
.kazicore-mark-sm { width:30px; height:30px; border-radius:10px; box-shadow:none; }
.kazicore-mark-sm svg { width:23px; height:23px; }
.commercial-logo-copy strong { font-size:18px; letter-spacing:-.035em; }
.commercial-logo-copy span { color:#94a3b8; font-size:10px; letter-spacing:.045em; text-transform:uppercase; }
.login-brand .commercial-logo-copy span { color:#cbd5e1; }
.brand-descriptor { display:inline-block; margin-top:14px; color:#94a3b8; font-size:11px; font-weight:800; letter-spacing:.09em; text-transform:uppercase; }
.brand-eyebrow { display:inline-block; margin-bottom:12px; color:#6ee7b7; font-size:11px; font-weight:900; letter-spacing:.14em; text-transform:uppercase; }
.login-brand-message h1 em { color:#6ee7b7; font-style:normal; }
.login-brand-foot { margin:0; font-size:12px !important; font-weight:800; letter-spacing:.04em; color:#cbd5e1 !important; }
.login-card-brand { display:flex; align-items:center; gap:9px; margin-bottom:18px; color:var(--primary); font-weight:900; font-size:13px; letter-spacing:.02em; }
.login-workspace-context { display:grid; gap:3px; margin:18px 0; padding:12px 14px; border:1px solid var(--line); border-left:4px solid var(--primary); border-radius:12px; background:var(--bg); }
.login-workspace-context span { color:var(--muted); font-size:10px; font-weight:900; letter-spacing:.08em; text-transform:uppercase; }
.login-workspace-context strong { font-size:13px; }
.login-privacy-note { margin:18px 0 0; color:var(--muted); font-size:10.5px; line-height:1.5; text-align:center; }
.workspace-identity { margin-top:16px; padding:11px 12px; border-radius:12px; background:rgba(255,255,255,.055); border:1px solid rgba(255,255,255,.08); display:grid; gap:3px; }
.workspace-identity span { color:#7f93ad; font-size:9px; font-weight:900; letter-spacing:.1em; }
.workspace-identity strong { color:#f8fafc; font-size:11px; line-height:1.35; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.nav-section-label { margin:12px 11px 3px; color:#71839c; font-size:9px; font-weight:900; letter-spacing:.13em; text-transform:uppercase; }
.nav-section-label:first-child { margin-top:0; }
.topbar-workspace-context { display:flex; align-items:center; gap:8px; margin-bottom:4px; min-width:0; }
.topbar-workspace-context span { max-width:360px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--primary); font-size:11px; font-weight:900; letter-spacing:.015em; }
.topbar-workspace-context b { color:var(--muted); font-size:9px; letter-spacing:.08em; text-transform:uppercase; }
.hero-panel .brand-eyebrow { color:#a7f3d0; }
.hero-panel h2 { font-family:var(--sans); font-weight:800; }
.topbar h1, .section-title h2, .card h3, .modal header h3, .login-card h2 { font-family:var(--sans); font-weight:800; }
.nav button.active .icon { color:#fff; }
.app-shell.sidebar-collapsed .workspace-identity { display:none; }
.app-shell.sidebar-collapsed .kazicore-mark { width:42px; height:42px; }
.app-shell.sidebar-collapsed .nav-section-label { display:none; }
.login-card .btn-primary { box-shadow:0 12px 24px rgba(8,122,85,.18); }
.login-card .btn-primary:hover { box-shadow:0 14px 28px rgba(8,122,85,.24); }
@media (max-width:850px) {
  .workspace-identity { display:grid; }
  .brand-descriptor { margin-top:10px; }
  .login-brand-message h1 { font-size:clamp(42px,12vw,64px); }
  .topbar-workspace-context { flex-wrap:wrap; }
}
@media (max-width:520px) {
  .login-brand { min-height:360px; }
  .login-brand-message p { font-size:14px; }
  .login-brand-foot { display:none; }
  .topbar-workspace-context b { display:none; }
}
.startup-brand-lockup { display:flex; align-items:center; justify-content:center; gap:13px; margin:0 auto 10px; text-align:left; }
.startup-brand-lockup h1 { margin:0; color:#0f172a; }
.startup-brand-lockup span { display:block; margin-top:3px; color:#64748b; font-size:10px; font-weight:800; letter-spacing:.06em; text-transform:uppercase; }
.startup-kazicore-mark { width:44px; height:44px; border-radius:13px; display:grid; place-items:center; background:#087a55; color:#fff; font-weight:900; font-size:24px; box-shadow:0 10px 24px rgba(8,122,85,.22); }
.startup-spinner { border-top-color:#087a55; }

/* v76 instant login / deferred first-run sales hydration */
.login-workspace-prep { margin:14px 0 0; display:grid; grid-template-columns:minmax(0,1fr) auto; gap:6px 10px; align-items:center; color:var(--muted); font-size:10.5px; }
.login-workspace-prep[hidden] { display:none !important; }
.login-workspace-prep span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.login-workspace-prep strong { color:var(--primary); font-size:10px; }
.login-workspace-prep i { grid-column:1 / -1; display:block; height:5px; border-radius:999px; overflow:hidden; background:var(--line); }
.login-workspace-prep i b { display:block; height:100%; border-radius:inherit; background:linear-gradient(90deg,var(--primary),var(--primary-bright)); transition:width .15s ease; }

/* v95 — Company-specific generated document / certificate theme controls */
.document-theme-preview{border:1px solid var(--line);border-top:7px solid var(--doc-primary);border-radius:12px;background:white;padding:14px;max-width:620px;box-shadow:0 8px 24px rgba(15,23,42,.06);color:var(--doc-text)}
.document-theme-preview-head{display:flex;justify-content:space-between;gap:16px;align-items:center;color:var(--doc-primary);font-weight:900;font-size:13px;text-transform:uppercase}
.document-theme-preview-head span{font-size:10px;border:1px solid var(--doc-primary);padding:4px 7px;border-radius:999px}
.document-theme-preview-title{margin:16px 0 12px;background:var(--doc-secondary);color:var(--doc-primary);padding:9px 10px;border-left:4px solid var(--doc-accent);font-weight:900;text-align:center}
.document-theme-preview-row{height:8px;background:#e5e7eb;border-radius:999px;margin:7px 0;width:90%}.document-theme-preview-row.short{width:62%}
.document-theme-preview-accent{height:4px;background:var(--doc-accent);width:34%;margin-top:15px}
.document-theme-chip{display:inline-flex;align-items:center;gap:6px;margin-top:4px;font-size:10px;font-weight:800}.document-theme-chip:before{content:"";width:12px;height:12px;border-radius:50%;background:var(--chip);border:1px solid rgba(0,0,0,.18)}
.document-export-header{border-color:var(--doc-primary,#111)!important}.document-export-company h1,.document-export-meta h2{color:var(--doc-primary,#111)}
.hr-letterhead{border-color:var(--doc-primary,var(--line))}.hr-letterhead-title strong{color:var(--doc-primary,inherit)}
@media print{.document-theme-preview{box-shadow:none}}

/* v96 production login readiness */
.login-ready-note { margin:14px 0 0; padding:9px 11px; border:1px solid var(--line); border-radius:11px; background:var(--panel); color:var(--muted); font-size:10.5px; line-height:1.45; }
.login-ready-note strong { color:var(--primary); }

/* v97 — production mobile/responsive hardening */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: hidden; }
body { overflow-x: hidden; min-width: 0; }
img, svg, canvas { max-width: 100%; }
button, .btn, input, select, textarea { touch-action: manipulation; }
.table-wrap, .sales-grid, .p9-table-wrap { max-width: 100%; -webkit-overflow-scrolling: touch; overscroll-behavior-inline: contain; }
.content > *, .card, .grid > *, .form-grid > * { min-width: 0; }

@media (max-width: 850px) {
  body { background: var(--bg); }
  .login-page { min-height: 100svh; display: flex !important; flex-direction: column; background: var(--bg); }
  .login-brand { min-height: 0 !important; padding: max(14px, env(safe-area-inset-top)) 18px 14px !important; display: block; flex: 0 0 auto; }
  .login-brand-header { display:flex; align-items:center; justify-content:space-between; gap:12px; }
  .login-brand-message, .login-brand-foot { display:none !important; }
  .login-brand .brand-descriptor { margin:0; max-width:46%; text-align:right; font-size:9px; line-height:1.35; }
  .login-panel { display:flex; align-items:flex-start; justify-content:center; flex:1; padding:18px 14px max(20px, env(safe-area-inset-bottom)); }
  .login-card { width:min(100%, 520px); padding:22px; border-radius:18px; box-shadow:0 10px 32px rgba(15,23,42,.08); }
  .login-card h2 { font-size:28px; line-height:1.1; }
  .login-workspace-context { margin:14px 0; }
  .login-card input, .login-card select, .login-card textarea { font-size:16px; min-height:48px; }
  .login-card .btn { min-height:48px; font-size:16px; }
  .secure-login-note, .login-ready-note, .login-privacy-note { line-height:1.45; }

  .app-shell, .app-shell.sidebar-collapsed, .app-shell.sidebar-expanded { width:100%; min-width:0; }
  .sidebar { width:min(320px, 90vw); max-width:90vw; height:100dvh; min-height:100dvh; overflow:hidden; }
  .nav { max-height:calc(100dvh - 132px); overflow-y:auto; overflow-x:hidden; padding-bottom:max(18px, env(safe-area-inset-bottom)); }
  .nav button, .sidebar-bottom button { min-height:46px; }
  .topbar { position:sticky !important; top:0; padding:12px 14px; gap:10px; z-index:30; }
  .topbar-title { align-items:flex-start; }
  .topbar-title h1 { font-size:clamp(22px, 7vw, 30px); overflow-wrap:anywhere; }
  .topbar p { font-size:12px; line-height:1.4; max-width:100%; }
  .top-actions { width:100%; display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:8px; }
  .top-actions > * { min-width:0; max-width:100%; }
  .top-actions select, .theme-toggle select { width:100%; max-width:100%; min-height:42px; }
  .content { width:100%; max-width:none; padding:14px 12px max(28px, env(safe-area-inset-bottom)); }
  .section-title { flex-direction:column; align-items:stretch; gap:10px; }
  .section-title h2 { font-size:24px; }
  .section-title > div:last-child, .section-title .form-actions, .section-title .top-actions { width:100%; }
  .grid-4, .grid-3, .grid-2, .form-grid, .form-grid.three { grid-template-columns:minmax(0,1fr) !important; }
  .grid { gap:12px; }
  .card { padding:16px; border-radius:14px; }
  .card h3 { font-size:18px; }
  .hero-panel { min-height:0; padding:20px; border-radius:18px; }
  .hero-panel h2 { font-size:32px; }
  .kpi { gap:12px; }
  .kpi strong { font-size:25px; }
  .table-wrap { border-radius:12px; }
  table { min-width:680px; }
  th, td { padding:10px; font-size:12px; }
  .sales-grid table { min-width:720px; }
  .sales-grid input[type="number"] { width:82px; }
  .form-actions { width:100%; justify-content:stretch; gap:8px; }
  .form-actions .btn { flex:1 1 150px; min-height:44px; }
  .field input, .field select, .field textarea { font-size:16px; min-height:44px; }
  .modal-backdrop { padding:0; place-items:end center; }
  .modal { width:100%; max-width:100%; max-height:94dvh; border-radius:20px 20px 0 0; border-bottom:0; }
  .modal header { padding:14px 16px; }
  .modal header h3 { font-size:20px; line-height:1.2; overflow-wrap:anywhere; }
  .modal .modal-body { padding:16px; }
  .close-x { width:42px; height:42px; flex:0 0 auto; }
  .logo-manager { flex-direction:column; align-items:stretch; }
  .document-export-header, .document-brand, .p9-official-header { flex-direction:column; align-items:flex-start; }
  .document-export-meta { min-width:0; width:100%; text-align:left; }
  .payslip { padding:16px; }
  .payslip header, .payslip .lines { grid-template-columns:1fr; flex-direction:column; }
  .payslip-kenya { width:100%; max-width:100%; overflow-x:auto; }
}

@media (max-width: 520px) {
  .login-brand { padding-left:14px !important; padding-right:14px !important; }
  .login-brand .commercial-logo-copy span { display:none; }
  .login-brand .brand-descriptor { display:none; }
  .login-panel { padding:12px 10px max(14px, env(safe-area-inset-bottom)); }
  .login-card { padding:18px 16px; border-radius:16px; }
  .login-card-brand { margin-bottom:13px; }
  .login-card h2 { font-size:25px; }
  .login-workspace-context { padding:10px 12px; }
  .topbar { padding:10px; }
  .topbar p { display:none; }
  .topbar-workspace-context { margin-bottom:2px; }
  .top-actions { grid-template-columns:1fr; }
  .content { padding:10px 9px max(24px, env(safe-area-inset-bottom)); }
  .card { padding:14px; }
  .hero-panel { padding:17px; }
  .hero-panel h2 { font-size:28px; }
  .section-title h2 { font-size:22px; }
  .btn { min-height:44px; }
  .form-actions { flex-direction:column; }
  .form-actions .btn { width:100%; flex:0 0 auto; }
  table { min-width:620px; }
  .modal .modal-body { padding:14px 12px max(18px, env(safe-area-inset-bottom)); }
  .modal header { padding:12px; }
  .document-theme-preview-head { align-items:flex-start; flex-direction:column; }
}

@media (max-width: 360px) {
  .login-card { padding:16px 13px; }
  .login-card h2 { font-size:23px; }
  .kazicore-mark-lg { width:42px; height:42px; }
  .content { padding-left:7px; padding-right:7px; }
  .card { padding:12px; }
  table { min-width:580px; }
}


/* v99 — complete screen responsiveness: operational tables become readable cards on phones. */
.mobile-code-safe { max-width:100%; overflow:auto; white-space:pre-wrap; overflow-wrap:anywhere; }
@media (max-width: 640px) {
  .content, .main, .topbar, .section-title, .card, .modal, .modal-body { min-width:0; max-width:100%; }
  .topbar-title { min-width:0; width:100%; }
  .topbar-title > div { min-width:0; }
  .topbar-workspace-context span { max-width:min(68vw, 320px); }
  .workspace-identity strong { white-space:normal; overflow-wrap:anywhere; }
  .pill-row, .toolbar, .filters, .button-row, .action-row, .dashboard-maintenance-row { max-width:100%; flex-wrap:wrap; }
  .notice, .todo-item, .user-chip, .ai-message, .ai-source-card { overflow-wrap:anywhere; word-break:break-word; }
  .field, .field input, .field select, .field textarea { width:100%; max-width:100%; min-width:0; }
  .field input[type="checkbox"], .field input[type="radio"] { width:auto; min-height:0; }
  select { text-overflow:ellipsis; }
  .modal form, .modal .form-grid, .modal .grid { min-width:0; max-width:100%; }
  .hr-template-editor, .hr-word-head-row { min-width:0 !important; width:100% !important; max-width:100% !important; }
  .hr-template-editor { padding:12px !important; overflow-wrap:anywhere; }
  .logo-manager-field, [style*="grid-column"] { max-width:100%; }

  /* Ordinary operational tables become stacked records. Specialist statutory/Sales sheets remain scrollable. */
  .table-wrap:has(> table.mobile-stack-table) { overflow:visible; border:0; background:transparent; }
  table.mobile-stack-table { min-width:0 !important; width:100% !important; border-collapse:separate; border-spacing:0 10px; background:transparent; }
  table.mobile-stack-table thead { position:absolute !important; width:1px !important; height:1px !important; padding:0 !important; margin:-1px !important; overflow:hidden !important; clip:rect(0,0,0,0) !important; white-space:nowrap !important; border:0 !important; }
  table.mobile-stack-table tbody { display:grid; gap:10px; width:100%; }
  table.mobile-stack-table tbody tr { display:block; width:100%; border:1px solid var(--line); border-radius:14px; background:var(--panel); box-shadow:0 3px 12px rgba(15,23,42,.04); overflow:hidden; }
  table.mobile-stack-table tbody td { display:grid; grid-template-columns:minmax(92px, 38%) minmax(0, 1fr); gap:10px; align-items:start; width:100%; min-width:0; padding:10px 12px; border:0; border-bottom:1px solid var(--line); white-space:normal !important; text-align:left !important; overflow-wrap:anywhere; }
  table.mobile-stack-table tbody td:last-child { border-bottom:0; }
  table.mobile-stack-table tbody td::before { content:attr(data-label); color:var(--muted); font-size:9px; font-weight:900; letter-spacing:.055em; text-transform:uppercase; overflow-wrap:anywhere; }
  table.mobile-stack-table tbody td[colspan] { display:block; }
  table.mobile-stack-table tbody td[colspan]::before { display:none; }
  table.mobile-stack-table .money { white-space:normal; overflow-wrap:anywhere; }
  table.mobile-stack-table .btn, table.mobile-stack-table button, table.mobile-stack-table select, table.mobile-stack-table input { max-width:100%; }
  table.mobile-stack-table .form-actions { display:grid; grid-template-columns:1fr; width:100%; }

  /* Specialist sheets intentionally keep their column structure, but scroll inside their own surface. */
  .p9-table-wrap, .sales-grid, .sales-freeze-grid, .payslip-kenya { width:100%; max-width:100%; overflow-x:auto !important; -webkit-overflow-scrolling:touch; }
  .p9-table-wrap table, .sales-grid table, .sales-freeze-grid table { margin-bottom:4px; }
}

@media (max-width: 380px) {
  table.mobile-stack-table tbody td { grid-template-columns:1fr; gap:4px; }
  .topbar-workspace-context span { max-width:76vw; }
  .modal { max-height:96dvh; }
}

/* v99 — scale fixed-width legacy document/template tables to the phone canvas. */
@media (max-width: 640px) {
  .content table[width]:not(.p9-table):not(.p9-template-table),
  .modal table[width]:not(.p9-table):not(.p9-template-table) {
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
    table-layout:auto !important;
  }
  .content table[width]:not(.p9-table):not(.p9-template-table) col,
  .modal table[width]:not(.p9-table):not(.p9-template-table) col {
    width:auto !important;
  }
  .content table[width] td, .content table[width] th,
  .modal table[width] td, .modal table[width] th {
    max-width:100%;
    overflow-wrap:anywhere;
    word-break:break-word;
  }
}

/* v102 sustained-session rendering guard */
.dashboard-switch-placeholder{min-height:120px;display:flex;align-items:center;justify-content:center;gap:10px;color:var(--muted);font-size:14px}
.dashboard-switch-placeholder span{width:18px;height:18px;border:2px solid var(--line);border-top-color:var(--primary);border-radius:50%;animation:kaziCoreSpin .8s linear infinite}
@keyframes kaziCoreSpin{to{transform:rotate(360deg)}}
.content > .card,.content > .grid,.content > .hero,.content > .section-title,.content > details{content-visibility:auto;contain-intrinsic-size:1px 420px}
@media print{.content > *{content-visibility:visible!important;contain-intrinsic-size:auto!important}}

/* Independent navigation scroll, dashboard onboarding and click theme controls */
@media (min-width: 851px) {
  .sidebar {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    align-self: start;
  }
  .sidebar .logo-block { flex: 0 0 auto; }
  .sidebar .nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    align-content: start;
  }
  .main { min-height: 100vh; min-height: 100dvh; }
}
.sidebar .nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.22) transparent; }
.sidebar .nav::-webkit-scrollbar { width: 8px; }
.sidebar .nav::-webkit-scrollbar-track { background: transparent; }
.sidebar .nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 999px; }
.sidebar .nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.3); }

.theme-clicker,
.settings-theme-clicker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 13px;
  min-height: 40px;
}
.theme-choice,
.settings-theme-choice {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  min-height: 32px;
  padding: 6px 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.theme-choice:hover,
.settings-theme-choice:hover { color: var(--ink); background: rgba(127,127,127,.09); }
.theme-choice.active,
.settings-theme-choice.active {
  color: white;
  background: var(--primary);
  box-shadow: 0 5px 14px rgba(8,122,85,.2);
}
.settings-theme-clicker { width: 100%; justify-content: flex-start; flex-wrap: wrap; margin-top: 3px; }
.settings-theme-choice { min-height: 38px; padding: 8px 12px; }

.tutorial-launch-button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  min-height: 40px;
  padding: 7px 11px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 800;
}
.tutorial-launch-button > span {
  width: 23px;
  height: 23px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
}
.tutorial-launch-button:hover { box-shadow: 0 8px 20px rgba(20,13,30,.08); }

.dashboard-tutorial-root { position: fixed; inset: auto 0 0 auto; z-index: 10050; pointer-events: none; }
.dashboard-tutorial-spotlight { display:none!important; }
.dashboard-tutorial-card {
  pointer-events: auto;
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: min(390px, calc(100vw - 32px));
  max-height: min(520px, calc(100dvh - 34px));
  overflow: auto;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.32);
  padding: 18px;
}
.dashboard-tutorial-card h3 { margin: 8px 0 8px; font-size: 20px; line-height: 1.18; }
.dashboard-tutorial-card p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 13px; }
.dashboard-tutorial-progress { display:flex; justify-content:space-between; gap:12px; align-items:center; color:var(--muted); font-size:11px; font-weight:900; letter-spacing:.04em; text-transform:uppercase; }
.dashboard-tutorial-progress b { color: var(--primary); }
.dashboard-tutorial-dots { display:flex; gap:6px; margin:16px 0 12px; }
.dashboard-tutorial-dots i { width:7px; height:7px; border-radius:999px; background:var(--line); }
.dashboard-tutorial-dots i.active { width:20px; background:var(--primary); }
.dashboard-tutorial-actions { display:grid; grid-template-columns:auto 1fr auto auto; gap:8px; align-items:center; }
.tutorial-target-active { scroll-margin: 90px; }

@media (max-width: 850px) {
  .sidebar { overflow: hidden; }
  .sidebar .nav {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    height: auto;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
  }
  .dashboard-neutral-actions { gap: 7px; }
  .tutorial-launch-button b { display: none; }
  .tutorial-launch-button { width: 40px; padding: 5px; justify-content:center; }
  .theme-clicker { flex: 1 1 auto; justify-content: stretch; }
  .theme-choice { flex: 1 1 0; min-width: 0; padding-left: 5px; padding-right: 5px; }
  .theme-choice b { font-size: 11px; }
  .dashboard-tutorial-card {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: auto;
    max-height: min(58dvh, 480px);
    border-radius: 16px;
    padding: 15px;
  }
  .dashboard-tutorial-card h3 { font-size: 18px; }
}

@media (max-width: 390px) {
  .theme-choice b { display: none; }
  .theme-choice { min-height: 34px; }
  .theme-choice span { font-size: 15px; }
  .settings-theme-choice b { display: inline; }
  .dashboard-tutorial-actions { grid-template-columns:auto 1fr auto; }
  .dashboard-tutorial-actions .btn:nth-last-child(2) { grid-column:auto; }
}
