/* ============ Kuttingedge Design System (accounts.kes.co.zw match) ============ */
:root {
  --background: #F7F7F7;
  --foreground: #121212;
  --primary: #2d2d2d;
  --primary-foreground: #ffffff;
  --secondary: #f97316;
  --secondary-foreground: #ffffff;
  --accent: #84cc16;
  --accent-foreground: #1a1a1a;
  --muted: #f0f0f0;
  --muted-foreground: #6b7280;
  --card: #ffffff;
  --card-foreground: #121212;
  --border: #E3E3E3;
  --input: #E3E3E3;
  --ring: #2d2d2d;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --shadow-card: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow-pop: 0 10px 30px rgba(16,24,40,.12);
  --shadow-sidebar: 1px 0 3px rgba(16,24,40,.05);
  --success: #16a34a;
  --success-bg: #e9f7ef;
  --warning: #f97316;
  --warning-bg: #fff4ec;
  --danger: #dc2626;
  --danger-bg: #feeaea;
  --info: #0369a1;
  --info-bg: #e9f4fa;
  --link: #1d4ed8;
  --sidebar-w: 238px;
}

*, *::before, *::after { box-sizing: border-box; }

html { line-height: 1.5; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
hr { border: none; border-top: 1px solid var(--border); }

.font-700 { font-weight: 600; }
.font-600 { font-weight: 600; }
.font-800 { font-weight: 600; }
.text-muted { color: var(--muted-foreground); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-link { color: var(--link); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-lg { font-size: 16px; }

/* ============ App shell ============ */
.shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--card);
  color: var(--foreground);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-sidebar);
  transition: width .18s ease, margin-left .18s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 18px; border-bottom: 1px solid var(--border); position: relative; }
.sidebar-brand img { width: 36px; height: 36px; object-fit: contain; }
.sidebar-brand .sb-brand-txt { min-width: 0; flex: 1; }
.sidebar-brand .name { font-weight: 600; font-size: 15.5px; line-height: 1.05; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand .tag { font-size: 11px; color: var(--muted-foreground); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-chev { background: none; border: none; color: var(--muted-foreground); cursor: pointer; padding: 4px; display: flex; border-radius: 6px; }
.sb-chev:hover { background: var(--muted); color: var(--foreground); }
.sb-chev svg { width: 16px; height: 16px; }
.brand-menu {
  position: absolute; top: calc(100% + 6px); left: 12px; z-index: 60;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-pop); min-width: 180px; padding: 6px; display: none;
}
.brand-menu.open { display: block; }
.brand-menu a { display: flex; padding: 9px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--foreground); }
.brand-menu a:hover { background: var(--muted); }

.sidebar-nav { flex: 1; padding: 8px 12px 12px; overflow-y: auto; }
.sidebar-nav a.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; margin-bottom: 3px; border-radius: 9px;
  color: #3f4655; font-size: 14px; font-weight: 500;
  border: 1px solid transparent; transition: all .12s;
  white-space: nowrap;
}
.sidebar-nav a.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-nav a.nav-item span { overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav a.nav-item:hover { background: var(--muted); color: var(--foreground); }
.sidebar-nav a.nav-item.active {
  background: var(--primary);
  color: var(--primary-foreground);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16,24,40,.2);
}
.sidebar-nav .nav-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em;
  color: #9aa2b1; padding: 18px 12px 8px;
}
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.install-row { display: flex; }
.install-row .btn svg { width: 15px; height: 15px; margin-right: 2px; }
body.sb-collapsed .install-row { display: none; }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, #374151, #111827); color: #fff; font-weight: 600; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.sidebar-user .u-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .u-email { font-size: 11px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-link { background: none; border: none; color: var(--muted-foreground); cursor: pointer; font-size: 12.5px; font-family: inherit; padding: 4px; display: inline-flex; align-items: center; gap: 6px; border-radius: 7px; }
.btn-link:hover { color: var(--foreground); background: var(--muted); }
.btn-link svg { width: 16px; height: 16px; }

/* Collapsed sidebar (icons only) */
body.sb-collapsed .sidebar { width: 66px; }
body.sb-collapsed .sidebar-brand { padding: 16px 14px; }
body.sb-collapsed .sb-brand-txt, body.sb-collapsed .sb-chev, body.sb-collapsed .sidebar-nav .nav-label,
body.sb-collapsed .nav-item span, body.sb-collapsed .sidebar-user .u-name, body.sb-collapsed .sidebar-user .u-email,
body.sb-collapsed .sidebar-user .btn-link { display: none; }
body.sb-collapsed .sidebar-nav { padding: 8px 8px; }
body.sb-collapsed .nav-item { justify-content: center; padding: 10px; }
body.sb-collapsed .sb-collapse { left: 66px; }
body.sb-collapsed .main { margin-left: 66px; }
body.sb-collapsed .sidebar-brand img { margin: 0 auto; }

/* Main */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; transition: margin-left .18s ease; }

/* ============ Top header (app chrome) ============ */
.app-header {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: 60px; padding: 0 30px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-header .hsearch { position: relative; flex: 0 1 400px; min-width: 200px; }
.app-header .hsearch svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-foreground); }
.app-header .hsearch input {
  width: 100%; padding: 9px 14px 9px 36px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--muted);
  font-family: inherit; font-size: 13.5px; color: var(--foreground); outline: none;
  transition: all .12s;
}
.app-header .hsearch input:focus { background: #fff; border-color: #c9cdd4; box-shadow: 0 0 0 3px rgba(45,45,45,.08); }
.h-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.cur-switch { display: flex; align-items: center; gap: 2px; background: var(--muted); border-radius: 999px; padding: 3px; border: 1px solid var(--border); }
.cur-switch button {
  border: none; background: none; font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--muted-foreground); transition: all .12s;
}
.cur-switch button.on { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: #fff; color: #3f4655; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: all .12s; }
.icon-btn:hover { background: var(--muted); color: var(--foreground); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; border: 2px solid #fff; }
.upd-status { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted-foreground); padding-left: 4px; }
.upd-status .gd { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }

/* Create dropdown */
.create-dd { position: relative; }
.create-dd .btn { min-width: 128px; }
.create-dd .dd-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 60;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-pop); min-width: 200px; padding: 6px; display: none;
}
.create-dd .dd-menu.open { display: block; }
.create-dd .dd-menu button {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px;
  border: none; background: none; border-radius: 8px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--foreground); text-align: left;
}
.create-dd .dd-menu button:hover { background: var(--muted); }
.create-dd .dd-menu button svg { width: 16px; height: 16px; color: var(--muted-foreground); }
.create-dd .dd-menu .dd-help { font-size: 11px; color: var(--muted-foreground); padding: 6px 12px 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }

/* Page topbar (arbitrary pages) */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 18px 30px 6px;
}
.topbar h1 { font-size: 21px; letter-spacing: -0.02em; }
.topbar .sub { font-size: 13px; color: var(--muted-foreground); margin-top: 3px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 18px 30px 40px; max-width: 1400px; width: 100%; }

/* ============ Cards ============ */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
}
.card-hd { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-hd h3 { font-size: 15.5px; }
.card-hd .card-sub { font-size: 12.5px; color: var(--muted-foreground); margin-top: 2px; }
.card-bd { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.pad { grid-template-columns: 2fr 1fr; }
@media (max-width: 1000px) { .grid.two, .grid.pad { grid-template-columns: 1fr; } }

/* ============ Dashboard specific ============ */
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; padding: 8px 0 18px; flex-wrap: wrap; }
.dash-head h1 { font-size: 23px; letter-spacing: -0.02em; }
.dash-head .dash-sub { font-size: 13px; color: var(--muted-foreground); margin-top: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.vat-badge { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; color: var(--foreground); box-shadow: var(--shadow-card); }
.vat-badge .gd { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }

/* KPI cards */
.kpi-bento { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.kpi-bento .revenue { grid-row: span 2; }
.kpi-bento .kpi-wide { grid-column: span 3; }
@media (max-width: 1000px) { .kpi-bento { grid-template-columns: repeat(2, minmax(0,1fr)); } .kpi-bento .revenue { grid-row: auto; } .kpi-bento .kpi-wide { grid-column: span 2; } }
@media (max-width: 640px) { .kpi-bento { grid-template-columns: 1fr; } .kpi-bento .kpi-wide { grid-column: auto; } }
.kpi-card { padding: 18px 20px; display: flex; flex-direction: column; }
.kpi-card .kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.kpi-card .kpi-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); }
.kpi-card .kpi-value { font-size: 25px; font-weight: 600; letter-spacing: -0.02em; margin-top: 12px; line-height: 1.05; }
.kpi-card .kpi-sub { font-size: 12.5px; color: var(--muted-foreground); margin-top: 7px; }
.kpi-ic { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-ic svg { width: 18px; height: 18px; }
.kpi-card.prominent .kpi-value { font-size: 32px; }
.kpi-card.prominent { padding: 22px 24px; }
.kpi-card.prominent .kpi-sub { font-size: 13px; }
.kpi-card .kpi-divider { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted-foreground); }
.kpi-card .kpi-divider .gd { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; }

/* Stat cards (reports / email tracking / templates) */
.grid.stat { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
@media (max-width: 1100px) { .grid.stat { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px) { .grid.stat { grid-template-columns: 1fr; } }
.stat-card { padding: 18px 20px; border-left: 3px solid var(--accent); }
.stat-card .stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-foreground); }
.stat-card .stat-value { font-size: 26px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; margin-top: 8px; color: var(--foreground); }
.stat-card .stat-sub { font-size: 12px; color: var(--muted-foreground); margin-top: 6px; max-width: 280px; }
.stat-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }

/* Email stats */
.estats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-top: 16px; }
@media (max-width: 1100px) { .estats { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px) { .estats { grid-template-columns: 1fr; } }
.estat-card { padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.estat-card .es-value { font-size: 22px; font-weight: 600; line-height: 1.05; }
.estat-card .es-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-foreground); }
.estat-card .es-sub { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; }
.section-label { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: #9aa2b1; margin: 22px 0 0; }

/* Charts */
.analytics-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 1100px) { .analytics-grid { grid-template-columns: 1fr; } }
.chart-card .card-hd h3 { display: flex; align-items: center; gap: 10px; }
.chart-legend { display: flex; align-items: center; gap: 14px; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-foreground); font-weight: 500; }
.chart-legend .sw { width: 9px; height: 9px; border-radius: 50%; }
.chart-box { position: relative; height: 280px; }

/* Recent documents */
.rec-filter { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rec-filter .fpill {
  border: none; background: none; font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--muted-foreground); padding: 6px 13px; border-radius: 999px; cursor: pointer; transition: all .12s;
}
.rec-filter .fpill:hover { color: var(--foreground); background: var(--muted); }
.rec-filter .fpill.on { background: #fff; color: var(--foreground); box-shadow: 0 0 0 1px var(--border), var(--shadow-card); }
.rec-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.viewall { font-size: 13px; font-weight: 600; color: var(--link); }
.viewall:hover { text-decoration: underline; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 600; padding: 9px 15px;
  transition: all .12s; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { background: #1a1a1a; }
.btn-accent { background: var(--accent); color: var(--accent-foreground); }
.btn-accent:hover { background: #76b812; }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover { background: #e66710; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--foreground); }
.btn-outline:hover { border-color: #c9cdd4; background: var(--muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-ghost { background: transparent; color: var(--muted-foreground); }
.btn-ghost:hover { background: var(--muted); color: var(--foreground); }
.btn-block { width: 100%; }

/* ============ Badges ============ */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-success { background: var(--success-bg); color: #15803d; }
.badge-warning { background: var(--warning-bg); color: #c2410c; }
.badge-danger { background: var(--danger-bg); color: #b91c1c; }
.badge-info    { background: var(--info-bg); color: #075985; }
.badge-muted   { background: var(--muted); color: var(--muted-foreground); }
.badge-accent  { background: #e9f5d8; color: #4d7c0f; }

/* ============ Forms ============ */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; }
.field label .req { color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--input); border-radius: 10px;
  background: #fff; font-family: inherit; font-size: 13.5px; color: var(--foreground);
  transition: border-color .12s, box-shadow .12s; outline: none;
}
.input:focus { border-color: #c9cdd4; box-shadow: 0 0 0 3px rgba(45,45,45,.08); }
textarea.input { resize: vertical; min-height: 70px; }
.input.qty, .input.price { text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.input.qty::-webkit-inner-spin-button, .input.qty::-webkit-outer-spin-button,
.input.price::-webkit-inner-spin-button, .input.price::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.input.qty, .input.qty[type=number], .input.price[type=number] { -moz-appearance: textfield; appearance: textfield; }
.input-suffix { position: relative; }
.input-suffix .suf { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); font-size: 12px; font-weight: 600; }
.input-suffix input { padding-right: 60px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 150px; }
.radio-cards { display: flex; gap: 10px; }
.radio-card { flex: 1; border: 1.5px solid var(--border); border-radius: 12px; padding: 10px; cursor: pointer; text-align: center; background: #fff; transition: all .12s; }
.radio-card.selected { border-color: var(--ring); box-shadow: 0 0 0 2px rgba(45,45,45,.1); background: var(--muted); }
.radio-card input { display: none; }
.radio-card .rc-label { font-weight: 600; font-size: 13px; }
.radio-card .rc-sub { font-size: 11px; color: var(--muted-foreground); }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted-foreground); font-weight: 600; padding: 13px 16px;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--background);
}
table.tbl td { padding: 13px 16px; border-bottom: 1px solid #EEEEEE; vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td { background: #FAFAFB; }
table.tbl .num { text-align: right; }
table.tbl th.num { text-align: right; }
.cell-main { font-weight: 600; }
.doc-no { font-weight: 600; color: var(--link); }
.doc-no:hover { text-decoration: underline; }
.cell-sub { font-size: 12px; color: var(--muted-foreground); margin-top: 1px; white-space: pre-line; line-height: 1.45; }
.row-actions { display: flex; gap: 6px; align-items: center; }
.row-actions .btn { padding: 5px 9px; font-size: 12px; }

/* ============ Modal ============ */
.modal-ov {
  position: fixed; inset: 0; background: rgba(17,17,17,.45); z-index: 80;
  display: none; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto;
}
.modal-ov.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,.22); animation: pop .16s ease;
}
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-hd { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-hd h3 { font-size: 16px; }
.modal-bd { padding: 22px; }
.modal-ft { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.x { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted-foreground); line-height: 1; }
.x:hover { color: var(--foreground); }

/* ============ Toast ============ */
.toast-zone { position: fixed; bottom: 22px; right: 22px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #1f2937; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); display: flex; gap: 8px; align-items: center; max-width: 360px;
  animation: slidein .18s ease;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ Tabs / filters ============ */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--muted-foreground); border: 1px solid transparent; background: none;
}
.tab:hover { background: var(--muted); color: var(--foreground); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters .input { width: auto; }
.searchwrap { position: relative; flex: 1; min-width: 180px; max-width: 320px; }
.searchwrap input { padding-left: 34px; }
.searchwrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-foreground); }

/* ============ Empty state ============ */
.empty { text-align: center; padding: 50px 20px; color: var(--muted-foreground); }
.empty svg { width: 42px; height: 42px; color: #cfd4da; margin-bottom: 10px; }

/* ============ Login page ============ */
.login-wrap { min-height: 100vh; display: flex; }
.login-side {
  width: 46%; background: var(--primary);
  color: #fff; padding: 44px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-side .o1 { position: absolute; top: -80px; right: -80px; width: 320px; height: 320px; border-radius: 50%; background: rgba(132,220,22,.08); }
.login-side .o2 { position: absolute; bottom: -60px; left: -60px; width: 260px; height: 260px; border-radius: 50%; background: rgba(249,115,22,.07); }
.login-side .o3 { position: absolute; top: 33%; right: 12%; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.03); }
.login-side h2 { font-size: 30px; line-height: 1.25; margin: 18px 0 14px; }
.login-side .feat { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; font-size: 14px; color: rgba(255,255,255,.85); }
.login-side .feat-ic { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.1); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.login-side .feat-ic svg { width: 16px; height: 16px; }
.login-side .copy { color: rgba(255,255,255,.45); font-size: 12px; }
.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-box { width: 100%; max-width: 420px; }
.login-box .mb { text-align: center; font-size: 12px; color: var(--muted-foreground); margin-top: 18px; }
@media (max-width: 900px) { .login-side { display: none; } }
.err-box { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; padding: 11px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 14px; display: none; }
.err-box.show { display: block; }
.note-line { display: flex; gap: 8px; align-items: center; background: var(--muted); padding: 11px 14px; border-radius: 9px; font-size: 12px; color: var(--muted-foreground); margin-top: 18px; }
.note-line svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ============ Document print preview (A4) ============ */
.doc-sheet {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-card); padding: 38px 42px; max-width: 780px; margin: 0 auto;
  color: #111; font-size: 13px;
}
.doc-sheet { overflow: hidden; }
.doc-sheet .dhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.doc-sheet .dco { display: flex; gap: 12px; align-items: center; min-width: 0; }
.doc-sheet .dco img { width: 52px; height: 52px; object-fit: contain; flex-shrink: 0; }
.doc-sheet .dco > div { min-width: 0; overflow-wrap: break-word; word-break: break-word; }
.doc-sheet .dco .co-name { font-size: 19px; font-weight: 600; }
.doc-sheet .dco .co-tag { font-size: 11.5px; color: #6b7280; }
.doc-sheet .dtit { text-align: right; min-width: 0; overflow-wrap: break-word; word-break: break-word; flex-shrink: 0; }
.doc-sheet .dtit h2 { font-size: 30px; font-weight: 600; color: var(--accent); letter-spacing: .02em; }
.doc-sheet .dtit .dno { font-size: 13px; font-weight: 600; margin-top: 2px; }
.doc-sheet .dmeta { display: flex; gap: 26px; margin: 26px 0 20px; }
.doc-sheet .dmeta > div { min-width: 0; overflow-wrap: break-word; word-break: break-word; }
.doc-sheet .dmeta .k { font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; color: #9ca3af; font-weight: 600; }
.doc-sheet .dmeta .v { font-size: 13px; font-weight: 600; margin-top: 1px; }
.doc-sheet .billto { background: var(--background); border: 1px solid #eeeeee; border-radius: 9px; padding: 14px 16px; margin-bottom: 22px; overflow-wrap: break-word; word-break: break-word; }
.doc-sheet .billto .k { font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; color: #9ca3af; font-weight: 600; }
.doc-sheet .billto .v { font-size: 14px; font-weight: 600; margin-top: 3px; }
.doc-sheet table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: auto; }
.doc-sheet table th { background: var(--primary); color: #fff; text-align: left; padding: 10px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.doc-sheet table th.num, .doc-sheet table td.num { text-align: right; }
.doc-sheet table td { padding: 9px 12px; border-bottom: 1px solid #f0f0f0; white-space: pre-line; line-height: 1.5; vertical-align: top; overflow-wrap: break-word; word-break: break-word; min-width: 0; }
.doc-sheet table tr:nth-child(even) td { background: #FAFAFA; }
.doc-sheet .totals { margin-left: auto; width: 300px; max-width: 100%; margin-top: 18px; }
.doc-sheet .totals .l { display: flex; justify-content: space-between; padding: 5px 0; color: #6b7280; gap: 12px; }
.doc-sheet .totals .l span:last-child { text-align: right; overflow-wrap: break-word; word-break: break-word; }
.doc-sheet .totals .l.grand { background: var(--primary); color: #fff; padding: 10px 14px; border-radius: 8px; margin-top: 6px; font-size: 15px; font-weight: 600; }
.doc-sheet .totals .l.grand span:last-child { color: var(--accent); }
.doc-sheet .dnotes { margin-top: 26px; font-size: 12px; color: #4b5563; border-top: 1px dashed #d1d5db; padding-top: 16px; overflow-wrap: break-word; word-break: break-word; white-space: pre-line; }
.doc-sheet .dbank { margin-top: 22px; font-size: 12.5px; color: #1f2937; background: #fafafa; border: 1px solid #f0f0f0; border-radius: 9px; padding: 14px 16px; }
.doc-sheet .dbank .k { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #9ca3af; font-weight: 600; }
.doc-sheet .dbank table tr { border-bottom: 1px solid #f5f5f5; }
.doc-sheet .dbank table tr:last-child { border-bottom: none; }
.attach-row { display: flex; align-items: center; }
.attach-row .btn svg, .attach-row svg { width: 15px; height: 15px; margin-right: 2px; }

/* ============ print ============ */
.print-actions { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; }
@media print {
  body { background: #fff !important; }
  .sidebar, .topbar, .app-header, .print-actions, .noprint, .toast-zone { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0 !important; max-width: none !important; }
  .doc-sheet { border: none; box-shadow: none; border-radius: 0; padding: 0; max-width: none; }
  @page { size: A4; margin: 12mm; }
}

/* ============ Misc ============ */
.alert { padding: 12px 15px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; display: flex; gap: 8px; align-items: center; }
.alert.info { background: var(--info-bg); color: var(--info); }
.alert.success { background: var(--success-bg); color: var(--success); }
.alert.warn { background: var(--warning-bg); color: var(--warning); }
.alert.danger { background: var(--danger-bg); color: var(--danger); }
.pill-methods { display: flex; flex-wrap: wrap; gap: 6px; }
.pill-methods span { font-size: 11px; border: 1px solid var(--border); padding: 3px 9px; border-radius: 999px; color: var(--muted-foreground); }
.kv { margin-bottom: 12px; }
.kv .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-foreground); font-weight: 600; }
.kv .v { font-size: 14px; font-weight: 600; margin-top: 2px; }
.role-badge { font-size: 11px; padding: 3px 10px; border-radius: 999px; font-weight: 600; text-transform: capitalize; }
.role-badge.admin { background: var(--primary); color: #fff; }
.role-badge.staff { background: var(--warning-bg); color: var(--warning); }
.role-badge.viewer { background: var(--info-bg); color: var(--info); }

/* ============ PWA install widget ============ */
#installBtn {
  position: fixed; bottom: 20px; right: 20px; z-index: 95;
  display: none; align-items: center; gap: 8px;
  padding: 13px 20px; border-radius: 999px; border: none; cursor: pointer;
  background: var(--primary); color: #fff; font-family: inherit;
  font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.28);
  transition: transform .12s, opacity .2s;
}
#installBtn.show { display: inline-flex; animation: slidein .22s ease; }
#installBtn:hover { transform: translateY(-2px); }
#installBtn:active { transform: scale(.97); }
#installBtn svg { width: 18px; height: 18px; color: var(--accent); }
@media (max-width: 640px) {
  #installBtn { bottom: calc(84px + env(safe-area-inset-bottom)); right: 14px; left: 14px; justify-content: center; padding: 15px; }
}

/* responsive */
.menubtn { display: none; }
.mobile-nav { display: none; }
@media (max-width: 900px) {
  .sidebar, body.sb-collapsed .sidebar { transform: translateX(-100%); transition: transform .18s ease; width: var(--sidebar-w); }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.3); }
  .main, body.sb-collapsed .main { margin-left: 0; }
  .menubtn { display: inline-flex; }
  .sb-collapse { display: none; }
  .app-header { padding: 0 16px; gap: 10px; }
  .app-header .hsearch { flex: 1; }
  .upd-status { display: none; }
  .cur-switch { display: flex; }
  .cur-switch button { padding: 5px 9px; font-size: 12px; }
  .app-header .hsearch { min-width: 0; }
  .create-dd .btn { min-width: 0; padding: 9px 12px; }
  .create-dd .btn .chevr { display: none; }
  .icon-btn, .create-dd .btn { width: 40px; height: 40px; }
  .icon-btn svg { width: 19px; height: 19px; }
  .menubtn-wrap { position: fixed; top: 10px; left: 14px; z-index: 50; }
  .menubtn-wrap .menubtn { height: 40px; width: 40px; padding: 0; justify-content: center; }
  .app-header { padding-left: 60px; }
  .topbar { padding-left: 60px; }

  /* Bottom nav (always visible on scroll) */
  .mobile-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 55;
    background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 24px rgba(16,24,40,.08);
  }
  .mobile-nav .mn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 4px 5px; border-radius: 10px; color: var(--muted-foreground);
    font-size: 10.5px; font-weight: 600; min-width: 0;
  }
  .mobile-nav .mn-item svg { width: 21px; height: 21px; }
  .mobile-nav .mn-item.active { color: var(--primary); background: var(--muted); }
  .mobile-nav .mn-new svg { color: var(--accent); }
  .content, .main .content { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .main { padding-bottom: 0; }
  body:has(.mobile-nav) .toast-zone { bottom: calc(84px + env(safe-area-inset-bottom)); }
}

/* Mobile layout tightening */
@media (max-width: 640px) {
  .content { padding: 14px 14px 90px; }
  .topbar { padding: 14px 14px 4px; }
  .topbar h1 { font-size: 19px; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .topbar-actions .btn { flex: 1; }
  .card-hd { padding: 14px 14px; }
  .card-bd { padding: 14px; }
  .login-main { padding: 24px 18px; }
  .login-box { max-width: 100%; }
  .input, select.input, textarea.input { font-size: 16px; }
  .row > * { min-width: 100%; }
  .create-txt { display: none; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .filters .searchwrap { max-width: none; }
  .doc-sheet { padding: 18px 14px; border-radius: 10px; }
  .doc-sheet .dhead { flex-direction: column; gap: 14px; }
  .doc-sheet .dtit { text-align: left; }
  .doc-sheet .dmeta { flex-wrap: wrap; gap: 14px; }
  .doc-sheet .totals { width: 100%; }
  .modal-ov { padding: 3vh 12px; }
  .modal-hd, .modal-bd, .modal-ft { padding-left: 16px; padding-right: 16px; }
  .toast-zone { left: 14px; right: 14px; bottom: 80px; }
  .toast { max-width: none; width: 100%; }
  .sb-collapse { display: none; }
}