/* AK Computer - mobile-first app-like UI */
:root {
  --primary: #1a56db;
  --primary-dark: #1e429f;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --ok: #059669;
  --bad: #dc2626;
  --warn: #d97706;
  --info: #0284c7;
  --radius: 12px;
  --topbar-h: 52px;
  --bottomnav-h: 60px;
  --card-alt: rgba(0,0,0,.04);
  --label: #334155;
  --input-bg: #ffffff;
  --input-text: #16233b;
}

/* Dark mode: no explicit choice follows the OS (prefers-color-scheme);
   an explicit choice (data-theme, set by the toggle in the avatar menu and
   persisted per-user via user_preferences) always wins over the OS setting -
   the media-query block below is guarded with :not([data-theme="light"])
   and the unconditional [data-theme="dark"] block comes after it in source
   order, so both directions of override work with equal CSS specificity. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420; --card: #1a2233; --text: #e8edf5; --muted: #93a2ba;
    --border: #2e3a52; --card-alt: rgba(255,255,255,.05);
    --label: #cbd5e1; --input-bg: #232d42; --input-text: #e8edf5;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1420; --card: #1a2233; --text: #e8edf5; --muted: #93a2ba;
  --border: #2e3a52; --card-alt: rgba(255,255,255,.05);
  --label: #cbd5e1; --input-bg: #232d42; --input-text: #e8edf5;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 50;
  background: var(--primary); color: #fff; display: flex; align-items: center; gap: 10px;
  padding: 0 12px; padding-top: env(safe-area-inset-top);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.menu-btn { background: none; border: 0; color: #fff; cursor: pointer; padding: 6px; display: flex; }
.topbar-title { font-weight: 600; font-size: 17px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: flex; align-items: center; gap: 14px; }
.ico-svg { display: block; }

/* desktop-only search bar in the top bar (hidden on mobile - the reference
   design only shows it on the wide dashboard layout) */
.topbar-search {
  display: none; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 12px; width: 340px; color: var(--muted); position: relative;
}
.topbar-search input {
  border: 0; background: none; outline: none; flex: 1; font-size: 13.5px; color: var(--text);
}
.topbar-search-results {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 200;
  background: var(--card); border-radius: 10px; box-shadow: 0 8px 24px rgba(15,23,42,.18); overflow: hidden;
}
.topbar-search-results.show { display: block; }
.topbar-search-results a { display: block; padding: 10px 14px; font-size: 13.5px; color: var(--text); border-bottom: 1px solid var(--border); }
.topbar-search-results a:last-child { border-bottom: none; }
.topbar-search-results a:hover { background: var(--bg); }
.search-group-label { padding: 8px 14px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }

.saved-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.saved-filter-chip {
  display: inline-flex; align-items: center; gap: 4px; background: var(--card-alt); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 12.5px;
}
.saved-filter-chip a { color: var(--text); }
.saved-filter-del {
  background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1;
  padding: 2px 6px; border-radius: 50%;
}
.saved-filter-del:hover { background: var(--border); color: var(--bad); }

/* mobile-accessible search box inside the sidebar drawer (the topbar one
   above is desktop-only) - results flow inline rather than as a floating
   overlay, since .sidebar itself scrolls and would clip an absolutely
   positioned dropdown */
.sidebar-search {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
  border-radius: 9px; padding: 9px 12px; margin: 0 14px 12px; color: #94a3b8;
}
.sidebar-search input { border: 0; background: none; outline: none; flex: 1; font-size: 13.5px; color: #fff; }
.sidebar-search-results { display: none; margin: 0 14px 12px; background: rgba(255,255,255,.06); border-radius: 10px; overflow: hidden; }
.sidebar-search-results.show { display: block; }
.sidebar-search-results a { display: block; padding: 10px 14px; font-size: 13.5px; color: #e2e8f0; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-search-results a:last-child { border-bottom: none; }
.sidebar-search-results .search-group-label { color: #94a3b8; }
@media (min-width: 1024px) {
  .sidebar-search, .sidebar-search-results { display: none !important; }
}

/* ---------- notification bell ---------- */
.topbar-bell { position: relative; cursor: pointer; color: #fff; display: flex; }
.bell-badge {
  position: absolute; top: -4px; right: -6px; background: #dc2626; color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 10px; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px; line-height: 1;
}
.bell-panel, .avatar-panel {
  display: none; position: absolute; top: calc(100% + 14px); right: -10px; z-index: 200;
  background: var(--card); color: var(--text); border-radius: 10px; min-width: 220px;
  box-shadow: 0 8px 24px rgba(15,23,42,.18); overflow: hidden;
}
.bell-panel.show, .avatar-panel.show { display: block; }
.bell-panel a {
  display: block; padding: 11px 14px; font-size: 13.5px; color: var(--text); border-bottom: 1px solid var(--border);
}
.bell-panel a:last-child { border-bottom: none; }
.bell-panel a:active, .avatar-panel a:active { background: var(--bg); }
.bell-empty { padding: 14px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- avatar ---------- */
.topbar-avatar {
  position: relative; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.22);
  color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; cursor: pointer;
  flex-shrink: 0;
}
.avatar-panel-name { padding: 12px 14px; font-size: 13.5px; font-weight: 600; border-bottom: 1px solid var(--border); }
.avatar-panel-name span { display: block; font-weight: 400; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.avatar-panel a { display: flex; align-items: center; gap: 8px; padding: 11px 14px; font-size: 13.5px; color: var(--bad); }
.avatar-panel button {
  display: flex; align-items: center; gap: 8px; padding: 11px 14px; font-size: 13.5px; color: var(--text);
  width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--border); cursor: pointer; font-family: inherit;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 270px; z-index: 70;
  background: #0f172a; color: #cbd5e1; transform: translateX(-100%);
  transition: transform .22s ease; overflow-y: auto; padding-bottom: 20px;
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; display: none;
}
.sidebar-overlay.show { display: block; }
.sidebar-head { padding: 18px 16px; background: linear-gradient(120deg, #1a56db, #1e429f); display: flex; gap: 12px; align-items: center; }
.sidebar-avatar { width: 46px; height: 46px; background: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.sidebar-appname { font-weight: 700; font-size: 17px; color: #fff; }
.sidebar-username { font-size: 11.5px; color: #dbeafe; margin-top: 2px; line-height: 1.4; }
.sidebar-links .nav-link, .nav-group-head {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; width: 100%;
  color: #cbd5e1; font-size: 14.5px; border: 0; border-left: 3px solid transparent;
  background: none; cursor: pointer; text-align: left; font-family: inherit;
}
.sidebar-links .nav-link.active, .nav-group-head.active { background: #1e293b; border-left-color: var(--primary); color: #fff; }
.nav-ico { width: 22px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-chev { margin-left: auto; display: flex; transition: transform .18s; transform: rotate(90deg); }
.nav-group.open .nav-chev { transform: rotate(-90deg); }
.nav-sub { display: none; background: #0b1120; }
.nav-group.open .nav-sub { display: block; }
.nav-sub-row { display: flex; align-items: center; }
.nav-sub-row a:first-child {
  flex: 1; display: block; padding: 10px 14px 10px 50px; color: #94a3b8; font-size: 13.5px;
  border-left: 3px solid transparent;
}
.nav-sub-row a:first-child.active { color: #fff; border-left-color: var(--primary); background: #16213a; }
.nav-plus {
  width: 34px; height: 34px; margin-right: 10px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #60a5fa; font-size: 17px; font-weight: 700; flex-shrink: 0;
}
.nav-plus:active { background: #1e293b; }
.sidebar-foot { padding: 14px 16px; color: #475569; font-size: 11px; }

/* ---------- Content ---------- */
.content {
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 12px) 12px calc(var(--bottomnav-h) + 20px);
  max-width: 1100px; margin: 0 auto;
}
/* Login & other guest pages: the box sits near the TOP (no scrolling to
   find the form on a phone), not vertically centered. */
.content-full { padding: 28px 12px 20px; min-height: 100vh; display: flex; flex-direction: column; justify-content: flex-start; }

/* ---------- Bottom nav (mobile app feel) ---------- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--border); z-index: 50;
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted); gap: 2px;
}
.bottomnav a span { display: flex; }
.bottomnav a.active { color: var(--primary); font-weight: 600; }

/* center + FAB in bottom nav */
.fab-center {
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
  background: #dc2626; color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center;
  margin-top: -26px; box-shadow: 0 4px 14px rgba(220,38,38,.45);
  flex-shrink: 0; align-self: flex-start;
}
.fab-center:active { background: #b91c1c; }

/* ---------- quick action sheet ---------- */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 80; display: none; }
.sheet-overlay.show { display: block; }
.action-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(110%); transition: transform .22s ease;
  max-height: 70vh; overflow-y: auto;
}
.action-sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 4px auto 12px; }
.action-sheet h3 { font-size: 15px; margin-bottom: 12px; }
.sheet-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.sheet-item {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 10px 4px; border-radius: 12px;
  font-size: 11.5px; color: var(--text); text-align: center;
}
.sheet-item span {
  width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: #e0eafe; color: #1a56db;
}
.sheet-item:active { background: var(--bg); }
.sheet-item:nth-of-type(4n+2) span { background: #fee2e2; color: #dc2626; }
.sheet-item:nth-of-type(4n+3) span { background: #ede9fe; color: #7c3aed; }
.sheet-item:nth-of-type(4n+4) span { background: #ffedd5; color: #ea580c; }
@media (min-width: 1024px) {
  .action-sheet { left: auto; right: 24px; bottom: 24px; width: 420px; border-radius: 18px; }
  .fab-center { display: none; }
}

/* ---------- Vyapar-style dashboard ---------- */
.duo-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.duo-card { border-radius: var(--radius); padding: 14px; }
.duo-card .duo-label { font-size: 13px; font-weight: 600; }
.duo-card .duo-value { font-size: 21px; font-weight: 800; margin-top: 4px; }
.duo-get { background: #d1fae5; } .duo-get .duo-label { color: #065f46; } .duo-get .duo-value { color: #059669; }
.duo-give { background: #fee2e2; } .duo-give .duo-label { color: #991b1b; } .duo-give .duo-value { color: #dc2626; }
.tile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
@media (min-width: 700px) { .tile-grid { grid-template-columns: repeat(4, 1fr); } }
.tile {
  background: var(--card); border-radius: var(--radius); padding: 22px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: var(--text); font-weight: 600; font-size: 14px;
  box-shadow: 0 1px 3px rgba(15,23,42,.06);
}
.tile span {
  width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  background: #e0eafe; color: #1a56db;
}
.tile:active { background: #eff6ff; }
.tile:nth-of-type(4n+2) span { background: #fee2e2; color: #dc2626; }
.tile:nth-of-type(4n+3) span { background: #d1fae5; color: #059669; }
.tile:nth-of-type(4n+4) span { background: #ede9fe; color: #7c3aed; }
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; height: auto; display: block; }

/* balance colors in lists */
.bal-get { color: var(--ok); font-weight: 700; white-space: nowrap; }
.bal-give { color: var(--bad); font-weight: 700; white-space: nowrap; }
.bal-sub { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }

/* ---------- Clean card-list rows (party list, ledgers, bank details -
   a Vyapar-style vertical list instead of a table: bold description +
   muted date/subtext on the left, a colored amount on the right) ---------- */
.list-card { padding: 4px 16px; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--border); color: var(--text);
}
.list-row:last-child { border-bottom: none; }
a.list-row:active { background: var(--bg); margin: 0 -16px; padding-left: 16px; padding-right: 16px; width: calc(100% + 32px); }
.list-row-main { flex: 1; min-width: 0; }
.list-row-sub { font-size: 12.5px; margin-top: 2px; }
.list-row-val { text-align: right; flex-shrink: 0; font-size: 15px; }

/* Same list look, but applied to a real <table> (report_pdf.php's PDF
   converter and the CSV exporter both require <table> markup to work) -
   used for reports like the Bank Ledger that read better as a passbook
   list than a wide multi-column grid. */
.list-style-table table { min-width: 0; }
.list-style-table thead { display: none; }
.list-style-table tbody tr {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.list-style-table td { border-bottom: 1px solid var(--border); padding: 12px 4px; }
.list-style-table tr:last-child td { border-bottom: none; }
.list-style-table td:first-child { flex: 1; min-width: 0; }
.list-style-table .list-row-sub { display: block; font-size: 12px; margin-top: 2px; }
.list-style-table td a { color: inherit; text-decoration: none; }
.list-style-table td a:active { opacity: .6; }

/* ---------- Cards / layout ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(15,23,42,.06); }
.card h2 { font-size: 17px; margin-bottom: 12px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }
.settings-cat-list { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(15,23,42,.06); overflow: hidden; margin-bottom: 14px; }
.settings-cat-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.settings-cat-row:last-child { border-bottom: none; }
.settings-cat-row:active { background: var(--bg); }
.settings-cat-row .sc-ico { font-size: 20px; width: 28px; text-align: center; flex-shrink: 0; }
.settings-cat-row .sc-label { flex: 1; font-size: 15px; }
.settings-cat-row .sc-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.settings-cat-row .sc-chev { color: var(--muted); font-size: 16px; }
.settings-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--text); text-decoration: none; font-weight: 600; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.grid-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
}
.stat { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 3px rgba(15,23,42,.06); }
.stat .stat-label { font-size: 12px; color: var(--muted); }
.stat .stat-value { font-size: 20px; font-weight: 700; margin-top: 2px; }
.stat.s-ok .stat-value { color: var(--ok); }
.stat.s-bad .stat-value { color: var(--bad); }
.stat.s-warn .stat-value { color: var(--warn); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--label); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=password],
input[type=tel], input[type=email], input[type=file], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; background: var(--input-bg); color: var(--input-text); -webkit-appearance: none; appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='2' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12); }
.form-row { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 10px; }
@media (min-width: 700px) { .form-row.cols-2 { grid-template-columns: 1fr 1fr; } .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; } .form-row.cols-4 { grid-template-columns: repeat(4, 1fr); } }
.field { margin-bottom: 10px; }
.check-inline { display: flex; align-items: center; gap: 8px; font-weight: normal; }
.check-inline input { width: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--primary); color: #fff; border: 0; border-radius: 10px;
  padding: 10px 16px; font-size: 14.5px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:active { background: var(--primary-dark); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-danger { background: var(--bad); }
.btn-success { background: var(--ok); }
.btn-wa { background: #25d366; }
.btn-muted { background: #64748b; }
.btn-block { width: 100%; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); background: var(--card); box-shadow: 0 1px 3px rgba(15,23,42,.06); margin-bottom: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 550px; }
th { text-align: left; padding: 10px 12px; background: #f8fafc; color: #475569; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.table-sm { min-width: 0; }

/* ---------- Badges & flash ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; text-transform: capitalize; }
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-bad { background: #fee2e2; color: #991b1b; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-info { background: #e0f2fe; color: #075985; }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; font-weight: 500; }
.flash-success { background: #d1fae5; color: #065f46; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-info { background: #e0f2fe; color: #075985; }

/* ---------- Billing item rows ---------- */
.bill-items { margin-bottom: 12px; }
.bill-row { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 8px; position: relative; }
.bill-row .row-line { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 8px; align-items: end; }
@media (max-width: 600px) { .bill-row .row-line { grid-template-columns: 1fr 1fr; } .bill-row .row-line .cell-item { grid-column: 1 / -1; } }
.row-del { background: none; border: 0; color: var(--bad); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.bill-totals { max-width: 380px; margin-left: auto; }
.bill-totals .t-line { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14.5px; }
.bill-totals .t-grand { font-size: 18px; font-weight: 700; border-top: 2px solid var(--text); padding-top: 8px; }

/* ---------- Item summary list (page 1 of the Vyapar-style 2-step Sale entry) ---------- */
.bill-summary-list { margin-bottom: 10px; }
.bsum-row { display: flex; justify-content: space-between; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.bsum-main strong { display: block; }
.bsum-main .muted { font-size: 12px; margin-top: 2px; }
.bsum-val { text-align: right; font-weight: 700; white-space: nowrap; margin-left: 10px; }
.bsum-del { background: none; border: 0; color: var(--bad); font-size: 18px; padding: 4px 0 4px 10px; margin-left: 4px; }
.bsum-empty { color: var(--muted); text-align: center; padding: 18px; border: 1px dashed var(--border); border-radius: 10px; }

/* ---------- Add Item panel (full-screen overlay = the "second page") ---------- */
.add-item-panel { position: fixed; inset: 0; background: var(--bg); z-index: 200; overflow-y: auto; display: none; }
.add-item-panel.show { display: block; }
.aip-header { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; }
.aip-header button { background: none; border: 0; font-size: 20px; cursor: pointer; padding: 4px; }
.aip-header h2 { margin: 0; font-size: 18px; flex: 1; }
.aip-body { padding: 14px 16px 24px; max-width: 560px; margin: 0 auto 80px; }
.aip-footer { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #fff; border-top: 1px solid var(--border); z-index: 2; }
.aip-footer button { flex: 1; border: 0; padding: 16px; font-size: 15px; font-weight: 700; cursor: pointer; }
.aip-footer .aip-savenew { background: #fff; color: var(--primary); }
.aip-footer .aip-save { background: var(--primary); color: #fff; }
.bill-row.panel-mode { background: none; border: 0; padding: 0; margin-bottom: 0; }
.bill-row.panel-mode .row-line { display: block; }
.bill-row.panel-mode .row-line > div { margin-bottom: 14px; }
.bill-row.panel-mode .row-del { display: none; }
.bill-row.panel-mode .i-total-wrap { display: none; } /* live subtotal shown in the Totals & Taxes box instead */
.cf-section { margin-top: 4px; }
.cf-section h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 18px 0 10px; }
.aip-totals { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 18px; }
.aip-totals h4 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 0 0 10px; }
.aip-totals .t-line { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14.5px; }
.aip-totals .t-grand { font-size: 17px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }

/* item search dropdown */
.isearch-wrap { position: relative; }
.isearch-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 40; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 260px; overflow-y: auto; display: none;
}
.isearch-results.show { display: block; }
.isearch-results .ir { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.isearch-results .ir:active, .isearch-results .ir:hover { background: #eff6ff; }
.isearch-results .ir small { color: var(--muted); display: block; }

/* ---------- Login ---------- */
.login-box { max-width: 380px; margin: 0 auto; width: 100%; }
.login-logo { text-align: center; font-size: 44px; margin-bottom: 8px; }
.login-title { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 20px; }

/* ---------- Invoice print ---------- */
.inv-paper { background: #fff; max-width: 800px; margin: 0 auto; padding: 24px; border-radius: 8px; }
.inv-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; border-bottom: 2px solid var(--text); padding-bottom: 12px; margin-bottom: 12px; }
.inv-firm h1 { font-size: 22px; }
.inv-meta { text-align: right; font-size: 13px; }
.inv-title { font-size: 18px; font-weight: 700; }
.inv-table { min-width: 0; font-size: 13.5px; }
.no-print { }
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: #fff; }
  .topbar, .sidebar, .bottomnav, .no-print, .flash, .sidebar-overlay,
  .action-sheet, .sheet-overlay, .fab-center { display: none !important; }
  .content, .content:not(.content-full) { padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
  .inv-paper { box-shadow: none; padding: 0; max-width: 100%; }
  .card { box-shadow: none; }
  .table-wrap { overflow: visible !important; box-shadow: none; }
  table { min-width: 0 !important; }
}

/* ---------- Desktop layout: light docked sidebar + light top bar with
   search, matching a standard SaaS dashboard look (mobile keeps the blue
   app-style top bar; only the ≥1024px desktop layout switches to light) ---------- */
@media (min-width: 1024px) {
  .menu-btn { display: none; }
  .sidebar {
    transform: none; box-shadow: none; background: var(--card); color: var(--text);
    border-right: 1px solid var(--border);
  }
  .sidebar-overlay { display: none !important; }
  .sidebar-head { background: var(--card); border-bottom: 1px solid var(--border); }
  .sidebar-avatar { background: var(--primary); border-radius: 10px; font-size: 20px; }
  .sidebar-appname { color: var(--text); }
  .sidebar-username { color: var(--muted); }
  .sidebar-links .nav-link, .nav-group-head { color: var(--text); }
  .sidebar-links .nav-link:hover, .nav-group-head:hover { background: var(--bg); }
  .sidebar-links .nav-link.active, .nav-group-head.active { background: #e8f0fe; border-left-color: var(--primary); color: var(--primary); }
  .nav-sub { background: var(--bg); }
  .nav-sub-row a:first-child { color: var(--muted); }
  .nav-sub-row a:first-child.active { color: var(--primary); background: #e8f0fe; }
  .sidebar-foot { color: var(--muted); }

  .topbar { left: 270px; background: var(--card); color: var(--text); box-shadow: 0 1px 0 var(--border); }
  .topbar-title { color: var(--text); }
  .topbar-search { display: flex; }
  .topbar-bell { color: var(--muted); }
  .topbar-avatar { background: var(--primary); }

  .content:not(.content-full) {
    margin-left: 270px; max-width: none;
    padding: calc(var(--topbar-h) + 24px) 28px 40px;
  }
  .content:not(.content-full) > * { max-width: 1100px; }
  .bottomnav { display: none; }
  .grid-stats { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1440px) {
  .content:not(.content-full) > * { max-width: 1250px; }
}

/* ---------- The one AK Computer bill design (used by sale_view.php print/
   view and mirrored in includes/pdf.php's invoice_pdf() for the PDF/WhatsApp
   copy - there used to be a 20-theme colour picker; it's gone, this is it). */
.inv-bill { --navy: #0f2341; --navy-dark: #091629; --teal: #0b6e94; --teal-dark: #08546e;
  --orange: #ff763f; --gold: #d4af37; --purple: #7c3aed; --blue: #2563eb; --pink: #d0348a;
  --red: #c41e1e; --green: #128a3e; --row-alt: #eef6fc; --amber-bg: #ffebcc;
  --lavender-bg: #f6f4fd; --lavender-border: #d1c7f2; }
.inv-topbar { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--teal), var(--orange)); margin: -8px -8px 16px; }
.inv-head2 { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 20px; }
.inv-logo { font-size: 25px; font-weight: 800; }
.inv-logo .ak { color: var(--blue); } .inv-logo .computer { color: var(--navy); }
.inv-tagline { font-style: italic; color: var(--teal-dark); font-size: 12.5px; margin: 2px 0 8px; }
.inv-contact { font-size: 12px; color: #64748b; margin: 3px 0; padding-left: 14px; position: relative; }
.inv-contact::before { content: ''; position: absolute; left: 0; top: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--teal); }
.inv-box2 { background: var(--navy); color: #fff; border-radius: 10px; padding: 14px 18px; min-width: 220px; position: relative; }
.inv-box2 .inv-box-title { font-size: 20px; font-weight: 800; }
.inv-box2 .inv-box-rule { width: 40px; height: 3px; background: var(--orange); margin: 5px 0 10px; border-radius: 2px; }
.inv-box2 .inv-box-row { font-size: 12.5px; display: flex; gap: 8px; margin: 4px 0; }
.inv-box2 .inv-box-row span:first-child { color: #c3cee0; min-width: 68px; }
.inv-box2 .inv-box-row span:last-child { font-weight: 700; }
.inv-seal { position: absolute; right: 14px; bottom: -26px; width: 60px; height: 60px; border-radius: 50%;
  background: var(--gold); border: 2px solid var(--navy); color: var(--navy-dark); display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; font-weight: 800; font-size: 6.5px; line-height: 1.35; }
.inv-billto-pill { display: inline-block; background: linear-gradient(90deg, var(--teal), var(--blue)); color: #fff;
  font-weight: 700; font-size: 11.5px; padding: 5px 16px; border-radius: 12px; margin-bottom: 10px; }
.inv-billto-name { font-size: 14px; font-weight: 700; color: var(--navy); }
.inv-table2 thead th { background: var(--teal) !important; color: #fff !important; font-size: 11px; }
.inv-table2 tbody tr:nth-child(even) td { background: var(--row-alt); }
.inv-pay-totals { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 16px; align-items: flex-start; }
.inv-pay-block { flex: 1 1 300px; min-width: 280px; }
.inv-totals-block { flex: 1 1 220px; min-width: 220px; max-width: 260px; margin-left: auto; }
.inv-pay-pill { display: inline-block; background: linear-gradient(90deg, var(--purple), var(--blue)); color: #fff;
  font-weight: 700; font-size: 11px; padding: 5px 14px; border-radius: 12px; margin-bottom: 10px; }
.inv-bank-box { background: var(--lavender-bg); border: 1px solid var(--lavender-border); border-radius: 8px; padding: 10px 14px; font-size: 12px; }
.inv-bank-box div { margin: 3px 0; } .inv-bank-box span:first-child { color: #64748b; display: inline-block; min-width: 70px; }
.inv-qr-row { display: flex; gap: 14px; align-items: flex-start; margin-top: 14px; }
.inv-qr-row img { width: 78px; height: 78px; border: 1px solid var(--border); border-radius: 8px; }
.inv-scan-label { font-size: 10.5px; font-weight: 700; color: var(--blue); margin-bottom: 4px; }
.inv-thankyou { font-family: Georgia, 'Times New Roman', serif; font-style: italic; color: var(--pink); font-size: 19px; margin-bottom: 4px; }
.inv-thankyou-note { font-size: 10.5px; color: #64748b; max-width: 240px; }
.inv-t-line { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 0; color: #475569; }
.inv-total-bar, .inv-balance-bar, .inv-paid-bar { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 4px; margin: 6px 0; font-weight: 800; }
.inv-total-bar { background: var(--navy); color: #fff; font-size: 14px; }
.inv-balance-bar { background: var(--amber-bg); color: var(--red); font-size: 13px; }
.inv-paid-bar { background: #d8f3e0; color: var(--green); font-size: 12.5px; justify-content: center; }
.inv-sig-row2 { display: flex; justify-content: space-between; gap: 20px; padding-top: 44px; font-size: 12.5px; margin-top: 30px; position: relative; }
.inv-sig-line { border-top: 1px solid #94a3b8; padding-top: 6px; min-width: 170px; text-align: center; color: #475569; }
.inv-stamp { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); width: 76px; height: 76px; border-radius: 50%;
  border: 1.5px solid var(--navy); display: flex; align-items: center; justify-content: center; }
.inv-stamp::before { content: ''; position: absolute; inset: 5px; border: 0.8px solid var(--navy); border-radius: 50%; }
.inv-stamp-text { text-align: center; font-size: 6.3px; font-weight: 700; color: var(--navy); line-height: 1.5; }
.inv-footer-bar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center;
  background: linear-gradient(90deg, #ffdd8c, #ffedba); color: var(--navy); padding: 10px 16px; border-radius: 6px; margin-top: 34px; font-size: 11px; }
.inv-footer-bar strong { display: block; font-size: 11px; margin-bottom: 4px; }
.inv-social-icons { display: flex; gap: 6px; }
.inv-social-icons span { width: 18px; height: 18px; border-radius: 50%; color: #fff; font-size: 8px;
  font-weight: 700; display: flex; align-items: center; justify-content: center; }
.inv-social-icons span:nth-child(1) { background: #3b5998; }
.inv-social-icons span:nth-child(2) { background: #d1348a; }
.inv-social-icons span:nth-child(3) { background: #22b34f; }
.inv-social-icons span:nth-child(4) { background: #d92121; }
.inv-bottom-strip { background: var(--navy); color: #c3cee0; text-align: center; font-size: 10.5px; padding: 7px; border-radius: 0 0 6px 6px; }

/* ---------- Bill Design 2 (purple / orange), mirrors invoice_pdf_design2() ---------- */
.inv2-bill { --pp: #6d28d9; --ppd: #4c1d95; --ppl: #8b5cf6; --org: #ff7a1a; --nvy: #1e1b3a; }
.inv2-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: linear-gradient(110deg, #fff 0 46%, var(--pp) 46%); border-radius: 10px; padding: 14px 16px; margin: -8px -8px 14px; }
.inv2-logo { font-size: 26px; font-weight: 800; } .inv2-logo .ak { color: var(--pp); } .inv2-logo .cmp { color: var(--nvy); }
.inv2-tagline { font-style: italic; color: var(--pp); font-size: 12.5px; border-top: 2px solid var(--org); display: inline-block; padding-top: 2px; margin: 2px 0 8px; }
.inv2-contact { font-size: 12px; color: #64748b; margin: 3px 0; }
.inv2-head-right { text-align: right; min-width: 250px; }
.inv2-title { font-size: 30px; font-weight: 800; color: #fff; margin-bottom: 8px; }
.inv2-info { background: #fff; border: 1px solid #ddd6f3; border-radius: 9px; padding: 8px 12px; text-align: left; }
.inv2-info-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin: 5px 0; }
.inv2-info-row .ib { width: 18px; height: 18px; border-radius: 4px; color: #fff; font-size: 9px; display: inline-flex; align-items: center; justify-content: center; }
.inv2-info-row .il { color: #64748b; min-width: 66px; } .inv2-info-row .iv { font-weight: 700; color: var(--nvy); }
.inv2-billrow { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 14px; }
.inv2-billto { display: inline-block; background: linear-gradient(90deg, var(--pp), var(--ppl)); color: #fff; font-weight: 700; font-size: 12px; padding: 5px 16px; border-radius: 13px; }
.inv2-cust { font-size: 15px; font-weight: 800; color: var(--nvy); margin-top: 8px; }
.inv2-badges { display: flex; gap: 14px; }
.inv2-badge { text-align: center; width: 62px; }
.inv2-hex { width: 42px; height: 46px; margin: 0 auto 5px; color: #fff; font-size: 18px; display: flex; align-items: center; justify-content: center; clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); }
.inv2-badge-t { font-size: 8px; font-weight: 700; color: var(--nvy); line-height: 1.2; }
.inv2-table thead th { background: linear-gradient(90deg, var(--pp), var(--ppl)) !important; color: #fff !important; font-size: 11px; }
.inv2-table tbody tr:nth-child(even) td { background: #f8f6fe; }
.inv2-sq { display: inline-block; min-width: 22px; padding: 2px 4px; border-radius: 4px; color: #fff; font-weight: 700; font-size: 11px; text-align: center; }
.inv2-payrow { display: flex; gap: 22px; flex-wrap: wrap; align-items: flex-start; margin-top: 16px; }
.inv2-payblock { flex: 1 1 300px; min-width: 280px; }
.inv2-totals { flex: 1 1 230px; min-width: 230px; max-width: 265px; margin-left: auto; }
.inv2-pay-pill, .inv2-scan-pill { display: inline-block; background: linear-gradient(90deg, var(--pp), var(--ppl)); color: #fff; font-weight: 700; font-size: 11px; padding: 5px 16px; border-radius: 13px; margin-bottom: 10px; }
.inv2-scan-pill { font-size: 9.5px; padding: 4px 10px; }
.inv2-bank { position: relative; background: #f7f5fe; border: 1px solid #ddd6f3; border-radius: 9px; padding: 11px 14px; font-size: 12px; overflow: hidden; }
.inv2-bank div { margin: 3px 0; } .inv2-bank span { color: #64748b; display: inline-block; min-width: 68px; }
.inv2-bank::after { content: ''; position: absolute; right: 0; bottom: 0; border-width: 0 0 18px 18px; border-style: solid; border-color: transparent transparent var(--org) transparent; }
.inv2-scanrow { display: flex; gap: 14px; align-items: flex-start; margin-top: 14px; }
.inv2-qr { width: 76px; height: 76px; border: 1px solid #ddd6f3; border-radius: 6px; }
.inv2-thanks { font-family: Georgia, serif; font-style: italic; color: var(--pp); font-size: 20px; }
.inv2-stars { color: var(--org); font-size: 16px; letter-spacing: 3px; margin-top: 4px; }
.inv2-t { display: flex; justify-content: space-between; font-size: 12.5px; padding: 5px 2px; color: #475569; border-bottom: 1px solid #eee; }
.inv2-total-bar { display: flex; justify-content: space-between; background: linear-gradient(90deg, var(--pp), #2563eb); color: #fff; font-weight: 800; font-size: 15px; padding: 9px 12px; border-radius: 4px; margin: 5px 0; }
.inv2-balance-bar { display: flex; justify-content: space-between; background: #fff1d6; border-left: 5px solid var(--org); color: #b3260b; font-weight: 800; font-size: 13.5px; padding: 8px 12px; margin-top: 5px; }
.inv2-paid-bar { text-align: center; background: #d8f3e0; color: #0f9d58; font-weight: 800; padding: 8px; margin-top: 5px; border-radius: 4px; }
.inv2-trustrow { display: flex; justify-content: center; gap: 26px; flex-wrap: wrap; margin: 20px 0; }
.inv2-trust { text-align: center; width: 84px; }
.inv2-trust-c { width: 34px; height: 34px; margin: 0 auto 5px; border: 2px solid; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.inv2-trust-t { font-size: 8px; font-weight: 700; color: var(--nvy); }
.inv2-footer { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; background: linear-gradient(90deg, var(--pp), var(--ppd)); color: #fff; padding: 11px 16px; border-radius: 6px; margin-top: 20px; font-size: 11px; }
.inv2-social { display: flex; gap: 6px; margin-top: 4px; }
.inv2-social span { width: 18px; height: 18px; border-radius: 50%; background: #fff; color: var(--pp); font-size: 8px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.inv2-sigrow { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; padding-top: 30px; font-size: 12.5px; }
.inv2-sig { border-top: 1px solid #94a3b8; padding-top: 6px; min-width: 180px; text-align: center; color: #475569; }
.inv2-stamp { width: 74px; height: 74px; border: 1.5px solid var(--pp); border-radius: 50%; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 6.5px; font-weight: 700; color: var(--pp); line-height: 1.5; }
.inv2-bottom { background: var(--ppd); color: #ddd3f5; font-size: 10.5px; padding: 7px 14px; border-radius: 4px; margin-top: 12px; }

/* ---------- Aging / Collection report ---------- */
.aging-table th { white-space: nowrap; }
.aging-table td.ag-b1 { color: #0f9d58; } /* 0-30 green */
.aging-table td.ag-b2 { color: #d9a400; } /* 31-60 amber */
.aging-table td.ag-b3 { color: #e8590c; } /* 61-90 orange */
.aging-table td.ag-b4 { color: #d92121; font-weight: 700; } /* 90+ red */
.aging-table tr.ag-total td { background: #eef4ff; border-top: 2px solid var(--primary); }
.aging-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.aging-legend span { display: inline-flex; align-items: center; gap: 6px; }
.aging-legend .ag-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.aging-legend .ag-b1 { background: #0f9d58; } .aging-legend .ag-b2 { background: #f5c518; }
.aging-legend .ag-b3 { background: #e8590c; } .aging-legend .ag-b4 { background: #d92121; }

/* misc */
.muted { color: var(--muted); font-size: 13px; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }
.right { text-align: right; }
.big-otp { font-size: 26px; letter-spacing: 8px; text-align: center; font-weight: 700; }
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: flex-end; }
.filterbar > div { flex: 1; min-width: 130px; }
.photo-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.searchbox { margin-bottom: 12px; }
.list-count { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* ---------- Vyapar-style serial picker & credit/cash toggle ---------- */
.sp-scan { display: flex; gap: 8px; margin: 6px 0; }
.sp-list { max-height: 150px; overflow-y: auto; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.sp-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-weight: normal; border-bottom: 1px dashed var(--border); }
.sp-row:last-child { border-bottom: 0; }
.sp-row input { width: auto; }
.cc-toggle { display: inline-flex; border: 2px solid var(--primary); border-radius: 999px; overflow: hidden; }
.cc-toggle button { border: 0; background: #fff; color: var(--primary); padding: 8px 22px; font-weight: 700; font-size: 14px; cursor: pointer; }
.cc-toggle button.on-credit { background: #059669; color: #fff; }
.cc-toggle button.on-cash { background: var(--primary); color: #fff; }

/* ---------- AMC / site visit calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 10px; }
.cal-dow { text-align: center; font-weight: 700; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-cell { background: var(--card); border-radius: 8px; min-height: 70px; padding: 4px; border: 1px solid var(--border); }
.cal-cell.cal-blank { background: transparent; border: none; }
.cal-cell.cal-today { border-color: var(--primary); border-width: 2px; }
.cal-daynum { font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.cal-event { display: block; font-size: 10px; line-height: 1.3; padding: 2px 4px; margin-bottom: 2px; border-radius: 4px; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event.cal-amc { background: #fef3c7; color: #92400e; }
.cal-event.cal-visit { background: #e0f2fe; color: #075985; }
@media (max-width: 700px) {
  .cal-grid { gap: 2px; }
  .cal-cell { min-height: 50px; padding: 2px; }
  .cal-event { font-size: 9px; }
}

/* ---------- Admin impersonation ("Login as User") banner ---------- */
.impersonate-bar {
  background: #f59e0b; color: #451a03; padding: 10px 14px; border-radius: 10px;
  margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; font-weight: 600; font-size: 13.5px;
}
.impersonate-bar .btn { background: #451a03; color: #fff; }

/* ---------- Export "what to display" dialog (Vyapar-style) ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 95; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.show { display: flex; }
.modal-box { background: var(--card); border-radius: var(--radius); width: 100%; max-width: 380px; max-height: 85vh; overflow-y: auto; padding: 18px; }
.modal-box h3 { font-size: 16px; margin-bottom: 14px; }
.modal-check-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.modal-check-row:last-of-type { border-bottom: none; }
.modal-check-row input { width: 18px; height: 18px; }
.modal-box .field { margin-top: 14px; }
.modal-box .field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.modal-box .field input[type=text] { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ---------- Vyapar-style tabbed Filters sheet ---------- */
.vyf-box { max-width: 560px; width: 100%; padding: 0; overflow: hidden; display: flex; flex-direction: column; max-height: 88vh; }
.vyf-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.vyf-head h3 { margin: 0; font-size: 18px; }
.vyf-x { background: none; border: none; font-size: 17px; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.vyf-body { display: flex; min-height: 0; flex: 1; }
.vyf-tabs { flex: 0 0 40%; max-width: 190px; background: var(--bg); border-right: 1px solid var(--border); overflow-y: auto; }
.vyf-tab { display: block; width: 100%; text-align: left; padding: 15px 16px; border: none; background: none; font-size: 15px; color: var(--muted); cursor: pointer; border-bottom: 1px solid var(--border); }
.vyf-tab.on { background: var(--card); color: var(--text); font-weight: 700; box-shadow: inset 3px 0 0 var(--primary); }
.vyf-panels { flex: 1; overflow-y: auto; }
.vyf-panel { display: none; }
.vyf-panel.on { display: block; }
.vyf-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 15px; cursor: pointer; }
.vyf-opt span { flex: 1; }
.vyf-opt input[type=radio] { width: 20px; height: 20px; accent-color: var(--primary); flex-shrink: 0; }
.vyf-foot { display: flex; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--border); }
.vyf-foot .btn { flex: 1; }
.vyf-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.vyf-chip { display: inline-block; padding: 5px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); font-size: 13px; font-weight: 600; }

/* ---------- Reports hub: vertical categorized list + favorites ---------- */
.fav-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fav-chip { white-space: nowrap; }
.report-cat { margin-bottom: 6px; }
.report-cat:last-child { margin-bottom: 0; }
.report-cat-h {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--muted); padding: 14px 4px 6px; border-top: 1px solid var(--border);
}
.report-cat:first-child .report-cat-h { border-top: none; padding-top: 2px; }
.report-row {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.report-row:last-child { border-bottom: none; }
.report-row-link { flex: 1; padding: 12px 4px; color: var(--text); font-size: 14.5px; }
.report-row-link.active { color: var(--primary); font-weight: 700; }
.star-btn {
  background: none; border: 0; font-size: 19px; color: #cbd5e1; cursor: pointer;
  padding: 8px 6px; line-height: 1; flex-shrink: 0;
}
.star-btn.is-fav { color: #f59e0b; }

/* ---------- Smart Dashboard ---------- */
/* Mobile first: the owner reads this on a phone, so KPIs are two per row and
   only widen on a real screen. */
.smart-summary { border-left: 4px solid var(--primary); }
.smart-summary .ss-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.smart-summary .ss-text { font-size: 15px; line-height: 1.6; margin: 8px 0 10px; }
.hchip { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; text-decoration: none; white-space: nowrap; }
.hchip.h-ok { background: #dcfce7; color: #166534; }
.hchip.h-warn { background: #fef3c7; color: #92400e; }
.hchip.h-bad { background: #fee2e2; color: #991b1b; }

.range-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rchip { background: var(--bg); border: 1px solid var(--border); color: var(--text);
         font-size: 13px; padding: 6px 11px; border-radius: 999px; cursor: pointer; }
.rchip.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.rcustom { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.rcustom input[type=date] { width: auto; padding: 5px 8px; font-size: 13px; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { display: block; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
       padding: 12px; text-decoration: none; color: var(--text); }
.kpi:active { transform: scale(.99); }
.kpi .kpi-label { font-size: 12px; color: var(--muted); }
.kpi .kpi-value { font-size: 19px; font-weight: 700; margin-top: 2px; }
.kpi .kpi-delta { font-size: 12px; margin-top: 3px; font-weight: 600; }
.kpi .kpi-delta.up { color: var(--ok); }
.kpi .kpi-delta.down { color: var(--bad); }
.kpi.s-ok .kpi-value { color: var(--ok); }
.kpi.s-bad .kpi-value { color: var(--bad); }
.kpi.s-warn .kpi-value { color: var(--warn); }

.act { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.act:last-child { border-bottom: none; }
.act .act-ico { font-size: 20px; flex-shrink: 0; }
.act .act-body { flex: 1; font-size: 14px; line-height: 1.45; }
.act .act-group { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.act .btn { flex-shrink: 0; }
.act-bad .act-ico { filter: none; }

.alertrow { display: block; padding: 9px 0; border-bottom: 1px solid var(--border);
            text-decoration: none; color: var(--text); font-size: 14px; }
.alertrow:last-child { border-bottom: none; }
.alertrow.al-bad { color: var(--bad); }
.alertrow.al-warn { color: var(--warn); }
.alertrow.al-ok { color: var(--ok); }

a.stat { text-decoration: none; color: inherit; display: block; }

@media (min-width: 700px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
}
