/* ============ PAENG DEE SHOP SALARY ============ */
@font-face {
  font-family: 'Phetsarath OT';
  src: url('Phetsarath%20OT.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-0: #07090f;
  --bg-1: #0a0e1a;
  --bg-2: #11162a;
  --bg-3: #161c33;
  --line: rgba(255,255,255,0.06);
  --line-2: rgba(255,255,255,0.10);
  --ink-0: #f5f7ff;
  --ink-1: #cbd2e6;
  --ink-2: #8b93ad;
  --ink-3: #5a6079;
  --purple: #7c3aed;
  --purple-2: #a855f7;
  --cyan: #06b6d4;
  --cyan-2: #22d3ee;
  --green: #10b981;
  --red: #f43f5e;
  --amber: #f59e0b;
  --grad-pc: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
  --grad-pc-soft: linear-gradient(135deg, rgba(124,58,237,0.18) 0%, rgba(6,182,212,0.18) 100%);
  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 12px 40px -12px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 0 1px rgba(124,58,237,0.4), 0 20px 60px -20px rgba(124,58,237,0.45);
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  background: var(--bg-1);
  color: var(--ink-0);
  font-family: 'Phetsarath OT', 'Noto Sans Lao', 'IBM Plex Sans Thai', 'Inter', -apple-system, system-ui, sans-serif;
  font-size: 14px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-feature-settings: 'tnum'; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
button { font-family: inherit; }

/* ============ AMBIENT BG ============ */
.app {
  position: relative;
  height: 100vh;
  width: 100vw;
  display: grid;
  grid-template-columns: 260px 1fr;
  overflow: hidden;
  background: var(--bg-1);
}
.app::before, .app::after {
  content: '';
  position: absolute;
  inset: auto;
  width: 800px; height: 800px;
  border-radius: 50%;
  filter: blur(160px);
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}
.app::before {
  background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
  top: -300px; left: 100px;
  animation: floatA 18s ease-in-out infinite;
}
.app::after {
  background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
  bottom: -300px; right: 100px;
  animation: floatB 22s ease-in-out infinite;
}
@keyframes floatA { 0%,100%{transform:translate(0,0)} 50%{transform:translate(80px,60px)} }
@keyframes floatB { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-60px,-80px)} }

/* ============ SIDEBAR ============ */
.sidebar {
  position: relative;
  z-index: 2;
  background: rgba(10,14,26,0.7);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 24px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--grad-pc);
  display: grid; place-items: center;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  color: white;
  font-size: 16px;
  box-shadow: 0 8px 24px -8px rgba(124,58,237,0.6);
}
.brand-logo-img {
  width: 42px; height: 42px;
  border-radius: 12px;
  object-fit: contain;
  background: rgba(255,255,255,0.04);
  padding: 2px;
  box-shadow: 0 8px 24px -8px rgba(245,158,11,0.5);
}
.brand-title {
  display: flex; flex-direction: column; gap: 1px;
}
.brand-title b {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ink-0);
}
.brand-title span {
  font-size: 10.5px;
  color: var(--ink-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-label {
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 16px 12px 8px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink-1);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}
.nav-item:hover {
  background: rgba(255,255,255,0.03);
  color: var(--ink-0);
}
.nav-item .icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.18), rgba(6,182,212,0.12));
  color: var(--ink-0);
  border-color: rgba(124,58,237,0.25);
}
.nav-item.active .icon { opacity: 1; color: var(--cyan-2); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -16px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--grad-pc);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px rgba(124,58,237,0.6);
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(124,58,237,0.10), rgba(6,182,212,0.06));
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--grad-pc);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
}
.user-meta b { font-size: 12.5px; display: block; }
.user-meta span { font-size: 10.5px; color: var(--ink-2); }

/* ============ MAIN ============ */
.main {
  position: relative;
  z-index: 1;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 32px 60px;
}
.main::-webkit-scrollbar { width: 8px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 4px; }
.main::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}
.topbar h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.topbar .sub {
  font-size: 13px;
  color: var(--ink-2);
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  width: 240px;
  color: var(--ink-2);
  font-size: 12.5px;
}
.search input {
  background: none; border: none; outline: none;
  color: var(--ink-0); font-size: 13px;
  flex: 1;
  font-family: inherit;
}
.search input::placeholder { color: var(--ink-3); }

.btn {
  border: 1px solid var(--line-2);
  background: rgba(255,255,255,0.03);
  color: var(--ink-0);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.18s;
}
.btn:hover { background: rgba(255,255,255,0.07); border-color: rgba(255,255,255,0.18); }
.btn-primary {
  background: var(--grad-pc);
  border-color: transparent;
  color: white;
  box-shadow: 0 8px 24px -10px rgba(124,58,237,0.6);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 30px -10px rgba(124,58,237,0.7); }
.btn-ghost { background: transparent; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* ============ PAGE TRANSITION ============ */
.page {
  animation: pageIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ CARDS ============ */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.01));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.card-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-h h3 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 0;
  color: var(--ink-0);
}
.card-h .sub { font-size: 11.5px; color: var(--ink-3); }

/* ============ STAT CARDS ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  position: relative;
  padding: 20px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.005));
  border: 1px solid var(--line);
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease;
}
.stat:hover { transform: translateY(-2px); border-color: var(--line-2); }
.stat::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  opacity: 0.22;
  filter: blur(20px);
  pointer-events: none;
}
.stat.purple::before { background: #7c3aed; }
.stat.cyan::before   { background: #06b6d4; }
.stat.green::before  { background: #10b981; }
.stat.amber::before  { background: #f59e0b; }
.stat .stat-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.stat .stat-label {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
}
.stat .stat-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
}
.stat.purple .stat-icon { background: rgba(124,58,237,0.15); border-color: rgba(124,58,237,0.3); color: var(--purple-2); }
.stat.cyan .stat-icon   { background: rgba(6,182,212,0.15); border-color: rgba(6,182,212,0.3); color: var(--cyan-2); }
.stat.green .stat-icon  { background: rgba(16,185,129,0.15); border-color: rgba(16,185,129,0.3); color: var(--green); }
.stat.amber .stat-icon  { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.3); color: var(--amber); }
.stat .stat-val {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.015em;
  font-family: 'JetBrains Mono', monospace;
  font-feature-settings: 'tnum';
}
.stat .stat-trend {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--ink-2);
  display: flex; align-items: center; gap: 6px;
}
.stat .stat-trend b { color: var(--green); font-weight: 600; }
.stat .stat-trend.down b { color: var(--red); }

/* ============ TABLES ============ */
.table-wrap {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.005));
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.015);
}
tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--ink-1);
  vertical-align: middle;
}
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody tr:last-child td { border-bottom: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  border: 1px solid var(--line-2);
  background: rgba(255,255,255,0.03);
}
.chip.green { background: rgba(16,185,129,0.10); color: #34d399; border-color: rgba(16,185,129,0.25); }
.chip.amber { background: rgba(245,158,11,0.10); color: #fbbf24; border-color: rgba(245,158,11,0.25); }
.chip.red   { background: rgba(244,63,94,0.10); color: #fb7185; border-color: rgba(244,63,94,0.25); }
.chip.cyan  { background: rgba(6,182,212,0.10); color: #22d3ee; border-color: rgba(6,182,212,0.25); }
.chip.purple{ background: rgba(124,58,237,0.10); color: #a78bfa; border-color: rgba(124,58,237,0.25); }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ============ FORM ============ */
.field {
  display: flex; flex-direction: column; gap: 6px;
}
.field label {
  font-size: 11.5px;
  color: var(--ink-2);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.input, .select, .textarea {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--ink-0);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: rgba(124,58,237,0.5);
  background: rgba(124,58,237,0.04);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b93ad' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.textarea { min-height: 90px; resize: vertical; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7,9,15,0.6);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: grid;
  place-items: center;
  animation: backdropIn 0.2s ease both;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 520px;
  max-width: 90vw;
  background: linear-gradient(180deg, rgba(22,28,51,0.95), rgba(17,22,42,0.95));
  border: 1px solid var(--line-2);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.7);
  animation: modalIn 0.3s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal .modal-sub { color: var(--ink-2); font-size: 12.5px; margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ============ MISC ============ */
.row { display: flex; gap: 16px; align-items: stretch; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-2); }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

.progress {
  height: 6px; background: rgba(255,255,255,0.05); border-radius: 999px; overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  background: var(--grad-pc);
  border-radius: 999px;
  transition: width 0.6s ease;
}

/* employee tiny avatar */
.emp {
  display: inline-flex; align-items: center; gap: 10px;
}
.emp-av {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.emp-av.c1 { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.emp-av.c2 { background: linear-gradient(135deg, #06b6d4, #22d3ee); }
.emp-av.c3 { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.emp-av.c4 { background: linear-gradient(135deg, #10b981, #06b6d4); }

/* shimmery hover for entire row of summary */
.summary-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.summary-row:last-child { border-bottom: none; }
.summary-row .label { font-size: 12.5px; color: var(--ink-2); }
.summary-row .val { font-family: 'JetBrains Mono', monospace; font-weight: 600; font-size: 13.5px; }

/* tab pills */
.tabs {
  display: inline-flex;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  padding: 4px;
  border-radius: 12px;
  gap: 2px;
}
.tab {
  padding: 7px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.tab:hover { color: var(--ink-0); }
.tab.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.25), rgba(6,182,212,0.15));
  color: var(--ink-0);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset;
}

/* status dot pulse */
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.6); }
  50% { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 2s ease-out infinite; }

/* ring */
.ring {
  position: relative;
  width: 140px; height: 140px;
}
.ring svg { transform: rotate(-90deg); }
.ring .ring-label {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
}
.ring .ring-label b {
  font-size: 24px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  display: block;
}
.ring .ring-label span {
  font-size: 10.5px;
  color: var(--ink-2);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* tooltip on hover for chart bars */
.bar-tip {
  position: absolute;
  background: rgba(22,28,51,0.95);
  border: 1px solid var(--line-2);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 11.5px;
  pointer-events: none;
  white-space: nowrap;
  transform: translate(-50%, -120%);
  z-index: 10;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,0.5);
}
.bar-tip b { color: var(--cyan-2); }

/* row delete button */
.row-actions {
  display: flex; align-items: center; gap: 6px;
  justify-content: flex-end;
  opacity: 0.55;
  transition: opacity 0.18s;
}
tbody tr:hover .row-actions { opacity: 1; }
.icon-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  color: var(--ink-2);
  display: grid; place-items: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--ink-0); }
.icon-btn.danger:hover {
  background: rgba(244,63,94,0.12);
  border-color: rgba(244,63,94,0.35);
  color: #fb7185;
}

/* clickable chip (status toggle) */
.chip.clickable { cursor: pointer; transition: filter 0.15s, transform 0.15s; user-select: none; }
.chip.clickable:hover { filter: brightness(1.2); transform: translateY(-1px); }

/* row remove animation */
@keyframes rowOut {
  to { opacity: 0; transform: translateX(20px); }
}
tr.removing { animation: rowOut 0.25s ease forwards; }

/* ============================================================
 * RESPONSIVE — mobile drawer + stacked layouts
 * ============================================================ */

/* Hamburger button (visible only on mobile) */
.menu-btn {
  display: none;
  width: 38px; height: 38px;
  border: 1px solid var(--line-2);
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  color: var(--ink-0);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.menu-btn:active { transform: scale(0.95); }
.sidebar-close {
  display: none;
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink-1);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(7,9,15,0.55);
  backdrop-filter: blur(4px);
  z-index: 90;
  animation: backdropIn 0.2s ease both;
}

/* ---------- TABLET (≤ 1024px) ---------- */
@media (max-width: 1024px) {
  .app { grid-template-columns: 220px 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .search { width: 180px; }
  .main { padding: 20px 22px 60px; }
  .topbar h1 { font-size: 22px; }
}

/* ---------- PHONE (≤ 720px) ---------- */
@media (max-width: 720px) {
  html, body, #root { height: auto; min-height: 100%; }
  body { overflow-y: auto; overflow-x: hidden; }

  .app {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .app::before, .app::after { width: 400px; height: 400px; filter: blur(120px); }

  /* Sidebar becomes off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    bottom: 0;
    width: 270px;
    z-index: 100;
    transform: translateX(-105%);
    transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
    overflow-y: auto;
    border-right: 1px solid var(--line-2);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 30px 0 80px -10px rgba(0,0,0,0.6); }
  .sidebar.open ~ .sidebar-backdrop,
  .sidebar-backdrop.open { display: block; }
  .sidebar-close { display: flex; }

  /* Main panel */
  .main {
    height: auto;
    overflow: visible;
    padding: 16px 14px 60px;
  }

  /* Topbar — show hamburger, hide search, stack actions */
  .menu-btn { display: inline-flex; }
  .topbar {
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
  }
  .topbar > div:first-child { order: 1; flex: 1; min-width: 0; }
  .topbar-actions { order: 2; flex-wrap: wrap; gap: 8px; width: 100%; }
  .topbar h1 { font-size: 19px; }
  .topbar .sub { font-size: 12px; }
  .search { display: none; }
  .btn { padding: 8px 12px; font-size: 12.5px; }
  .btn-icon { width: 34px; height: 34px; padding: 6px; }

  /* Cards & stats */
  .stat-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; margin-bottom: 16px; }
  .stat { padding: 14px; }
  .stat .stat-val { font-size: 20px; }
  .stat .stat-icon { width: 30px; height: 30px; }
  .stat .stat-label { font-size: 11px; }
  .stat .stat-h { margin-bottom: 12px; }
  .stat::before { width: 80px; height: 80px; top: -20px; right: -20px; }

  .card { padding: 14px; border-radius: 14px; }
  .card-h { flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
  .card-h h3 { font-size: 13.5px; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 12px; }

  /* Tables — scroll horizontally if needed */
  .card > table,
  .card table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .card table thead, .card table tbody, .card table tfoot { display: table; width: 100%; min-width: 540px; }
  thead th, tbody td { padding: 10px 12px; font-size: 12px; }
  thead th { font-size: 10px; }

  /* Always-visible row actions on touchscreens */
  .row-actions { opacity: 1; }
  .icon-btn { width: 32px; height: 32px; }

  /* Tabs */
  .tabs { flex-wrap: wrap; }
  .tab { padding: 6px 10px; font-size: 11.5px; }

  /* Modal */
  .modal {
    width: 100%;
    max-width: 100vw;
    max-height: 92dvh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    padding: 18px;
    margin: 0;
    align-self: end;
  }
  .modal-backdrop { align-items: end; }
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .modal h2 { font-size: 16px; }

  /* Ring */
  .ring { width: 110px; height: 110px; }
  .ring .ring-label b { font-size: 20px; }

  /* Brand on smaller drawer */
  .brand { padding: 8px 8px 18px; }
  .brand-title b { font-size: 12.5px; }
  .brand-title span { font-size: 10px; }
}

/* ---------- SMALL PHONE (≤ 380px) ---------- */
@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr !important; }
  .topbar h1 { font-size: 17px; }
  .btn { padding: 7px 10px; font-size: 12px; }
  .modal { padding: 14px; }
}
