/* =============================================
   PPN PMS — Global Dark Theme Stylesheet
   ============================================= */

:root {
  --bg:     #030810;    /* deep navy black */
  --s1:     #071526;    /* dark navy surface */
  --s2:     #0B1E36;    /* medium navy surface */
  --b1:     #0E2847;    /* border subtle */
  --b2:     #163860;    /* border medium */
  --c-proj: #29ABE2;    /* PPN sky blue — primary accent */
  --c-prov: #39B54A;    /* PPN green */
  --c-cat:  #1E88E5;    /* PPN medium blue */
  --c-item: #C8A415;    /* PPN gold */
  --c-flow: #4FC3F7;    /* light blue */
  --text:   #e2e8f0;
  --muted:  #64748b;
  --danger: #f87171;
  --success:#39B54A;
  --mono:   'IBM Plex Mono', 'Noto Sans Lao', monospace;
  --body:   'Noto Sans Lao', sans-serif;
  --sidebar-w: 240px;
  --topbar-h:  56px;
  --radius:    10px;
  --radius-sm: 6px;
  /* RGB triplets for rgba() dynamic theming */
  --c-proj-rgb: 41, 171, 226;
  --c-prov-rgb: 57, 181, 74;
  --c-cat-rgb:  30, 136, 229;
  --c-item-rgb: 200, 164, 21;
}

/* ── Reset ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; overflow-x: hidden; }
body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--c-proj); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Grid background (subtle, dark-theme aesthetic) ── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(var(--c-proj-rgb),.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--c-proj-rgb),.04) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none; z-index: 0;
  mix-blend-mode: overlay; opacity: .35;
}

/* ── Layout ─────────────────────────────────── */
.app-wrap {
  display: flex;
  min-height: 100vh;
  position: relative; z-index: 1;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  overflow: hidden;
  background: var(--s1);
  border-right: 1px solid var(--b1);
  box-shadow: 2px 0 16px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  position: fixed; top: 0; left: 0;
  z-index: 100;
  transition: transform .3s ease;
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar-header {
  padding: 14px 16px;
  border-bottom: 2px solid var(--c-proj);
  background: linear-gradient(180deg, rgba(var(--c-proj-rgb),.06) 0%, transparent 100%);
}
.logo {
  display: flex; align-items: center; gap: 10px;
}
.logo-has-img {
  gap: 8px;
}
.sidebar-logo-img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.logo-icon {
  font-size: 24px; color: var(--c-proj);
  animation: pulse-slow 3s infinite;
}
@keyframes pulse-slow { 0%,100%{opacity:1} 50%{opacity:.6} }
.logo-name { font-family: var(--mono); font-weight: 700; font-size: 14px; color: var(--text); }
.logo-sub  { font-family: var(--mono); font-size: 11px; color: var(--c-proj); opacity: .7; }

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 12px 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.nav-section-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  padding: 14px 10px 5px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  transition: all .2s;
  text-decoration: none;
  position: relative;
}
.nav-item:hover { background: var(--s2); color: var(--text); text-decoration: none; }
.nav-item.active { background: rgba(var(--c-proj-rgb),.12); color: var(--c-proj); box-shadow: inset 3px 0 0 var(--c-proj); }
.nav-item.active .nav-icon { color: var(--c-proj) !important; }
.nav-icon { font-size: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--c-item);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  font-family: var(--mono);
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--b1);
}
.company-name { font-size: 11px; color: var(--muted); font-weight: 600; }
.company-dept  { font-size: 10px; color: var(--muted); font-family: var(--mono); margin-top: 2px; opacity: .8; }

/* ── Main area ───────────────────────────────── */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;        /* allow flex item to shrink below content width */
  overflow-x: hidden;  /* clip any overflowing child (e.g. wide tables) */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin .3s ease;
}
.main-area.expanded { margin-left: 0; }

/* ── Topbar ──────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--s1);
  border-bottom: 1px solid var(--b1);
  box-shadow: 0 2px 10px rgba(0,0,0,.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.sidebar-toggle {
  background: none; border: none;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  padding: 6px;
}
.sidebar-toggle span {
  display: block; width: 20px; height: 2px;
  background: var(--muted); border-radius: 2px;
  transition: all .25s;
}
.sidebar-toggle:hover span { background: var(--text); }

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
  font-family: var(--mono);
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); text-decoration: none; }
.bc-sep { color: var(--b2); }
.bc-current { color: var(--text); }

.user-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: 100px;
  padding: 4px 10px 4px 4px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-proj), var(--c-prov));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; }
.user-name  { font-size: 12px; font-weight: 700; line-height: 1.2; }
.user-role  { font-size: 10px; color: var(--muted); font-family: var(--mono); line-height: 1.2; }
.logout-btn {
  color: var(--muted); font-size: 16px; padding: 2px 4px;
  border-radius: 4px; transition: color .2s;
}
.logout-btn:hover { color: var(--danger); text-decoration: none; }

/* ── Language switcher ───────────────────────── */
.lang-switcher {
  display: flex; align-items: center; gap: 2px;
  background: var(--s2); border: 1px solid var(--b1);
  border-radius: 20px; padding: 2px 4px;
}
.lang-sep { color: var(--b2); font-size: 12px; }
.lang-btn {
  background: none; border: none; cursor: pointer;
  font-size: 11px; font-weight: 700; font-family: var(--mono);
  color: var(--muted); padding: 3px 8px; border-radius: 16px;
  transition: all .2s;
}
.lang-btn:hover { color: var(--text); background: var(--b1); }
.lang-active { color: var(--c-proj) !important; background: rgba(var(--c-proj-rgb),.12) !important; }

/* ── Page content ─────────────────────────────── */
.page-content { padding: 28px 28px 60px; flex: 1; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.page-title {
  font-size: 22px; font-weight: 800; color: var(--text);
}
.page-title small {
  display: block; font-size: 13px; font-weight: 400;
  color: var(--muted); margin-top: 2px;
}

/* ── Cards ────────────────────────────────────── */
.card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.card-title {
  font-size: 14px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}

/* ── Stat cards (dashboard) ─────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: 14px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
  transition: all .25s;
  cursor: default;
  box-shadow: 0 1px 4px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
.stat-card:hover { border-color: var(--b2); transform: translateY(-2px); }
.stat-icon { font-size: 24px; }
.stat-value {
  font-size: 28px; font-weight: 800;
  font-family: var(--mono);
  line-height: 1;
}
.stat-label { font-size: 12px; color: var(--muted); font-weight: 600; }

/* ── Table ────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead tr {
  border-bottom: 1px solid var(--b1);
}
.data-table th {
  text-align: left; padding: 10px 14px;
  font-family: var(--mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); white-space: nowrap;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--b1); }
.data-table tbody tr { transition: background .15s; }
.data-table tbody tr:hover { background: var(--s2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .actions { display: flex; gap: 6px; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
  transition: all .2s; text-decoration: none;
  font-family: var(--body);
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--c-proj); color: #fff;
  border-color: var(--c-proj);
}
.btn-primary:hover { background: color-mix(in srgb, var(--c-proj) 80%, black 20%); }
.btn-success {
  background: var(--c-prov); color: #fff;
  border-color: var(--c-prov);
}
.btn-success:hover { background: color-mix(in srgb, var(--c-prov) 80%, black 20%); }
.btn-danger {
  background: transparent; color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: rgba(248,113,113,.1); }
.btn-ghost {
  background: transparent; color: var(--muted);
  border-color: var(--b2);
}
.btn-ghost:hover { border-color: var(--text); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-icon { padding: 7px; }

/* ── Badges ──────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  font-family: var(--mono); white-space: nowrap;
}
.badge-green  { background: rgba(var(--c-prov-rgb),.15); color: var(--c-prov); }
.badge-orange { background: rgba(var(--c-item-rgb),.15); color: var(--c-item); }
.badge-red    { background: rgba(248,113,113,.15);       color: var(--danger); }
.badge-muted  { background: rgba(100,116,139,.12);       color: var(--muted);  }
.badge-blue   { background: rgba(var(--c-proj-rgb),.12); color: var(--c-proj); }
.badge-purple { background: rgba(var(--c-cat-rgb),.12);  color: var(--c-cat);  }

/* ── Forms ───────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label {
  font-size: 12px; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: .5px; font-family: var(--mono);
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select, textarea {
  background: var(--s2);
  border: 1px solid var(--b2);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--body);
  width: 100%;
  transition: border .2s;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--c-proj);
  box-shadow: 0 0 0 3px rgba(var(--c-proj-rgb),.14);
}
textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 2px; }

.form-actions {
  display: flex; align-items: center; gap: 10px;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--b1);
}

/* ── Flash messages ─────────────────────────── */
.flash {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 20px; font-size: 14px;
  border: 1px solid;
}
.flash-icon {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; flex-shrink: 0;
}
.flash-success {
  background: rgba(var(--c-prov-rgb),.08);
  border-color: rgba(var(--c-prov-rgb),.3);
  color: var(--c-prov);
}
.flash-success .flash-icon { background: rgba(var(--c-prov-rgb),.2); }
.flash-error {
  background: rgba(248,113,113,.08);
  border-color: rgba(248,113,113,.3);
  color: var(--danger);
}
.flash-error .flash-icon { background: rgba(248,113,113,.2); }
.flash-info {
  background: rgba(var(--c-proj-rgb),.08);
  border-color: rgba(var(--c-proj-rgb),.3);
  color: var(--c-proj);
}
.flash-info .flash-icon { background: rgba(var(--c-proj-rgb),.2); }

/* ── Filters bar ─────────────────────────────── */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 20px; align-items: center;
}
.filters-bar select,
.filters-bar input[type="text"],
.filters-bar input[type="date"] {
  min-width: 160px;
  max-width: 220px;
}
.filters-bar .btn { flex-shrink: 0; }

/* ── Search ──────────────────────────────────── */
.search-wrap { position: relative; flex: 1; min-width: 160px; }
.search-wrap input { padding-left: 34px; }
.search-icon {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted); font-size: 14px; pointer-events: none;
}

/* ── Pagination ──────────────────────────────── */
.pagination {
  display: flex; gap: 4px; margin-top: 20px;
  justify-content: center; flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  font-family: var(--mono); font-size: 13px;
  border: 1px solid var(--b1); color: var(--muted);
  transition: all .2s; text-decoration: none;
}
.pagination a:hover { border-color: var(--c-proj); color: var(--c-proj); text-decoration: none; }
.pagination .current { background: var(--c-proj); color: #fff; border-color: var(--c-proj); }
.pagination .disabled { opacity: .35; pointer-events: none; }

/* ── Login page ──────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 420px;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-top: 3px solid var(--c-proj);
  border-radius: 20px;
  padding: 40px 36px;
  animation: fadeUp .5s ease both;
  box-shadow: 0 20px 60px rgba(var(--c-proj-rgb),.25), 0 0 0 1px rgba(var(--c-proj-rgb),.1);
}
@keyframes fadeUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo-img {
  width: 110px;
  height: 110px;
  object-fit: contain;
  display: block;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #fff;
  padding: 6px;
  box-shadow: 0 4px 20px rgba(var(--c-proj-rgb),.25);
}
.login-logo .logo-icon-lg {
  font-size: 40px; color: var(--c-proj);
  display: block; margin-bottom: 8px;
}
.login-logo h2 {
  font-size: 20px; font-weight: 800;
  background: linear-gradient(135deg, var(--text), var(--c-proj));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-logo p { font-size: 12px; color: var(--muted); margin-top: 4px; font-family: var(--mono); }

/* ── Modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  z-index: 200; display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--s1);
  border: 1px solid var(--b2);
  border-radius: 16px;
  width: 100%; max-width: 500px;
  padding: 28px;
  animation: fadeUp .25s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 20px; line-height: 1;
}
.modal-close:hover { color: var(--text); }

/* ── Detail view ─────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.detail-row {
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 0;
  border-bottom: 1px solid var(--b1);
}
.detail-row.full { grid-column: 1 / -1; }
.detail-label { font-size: 11px; color: var(--muted); font-family: var(--mono); text-transform: uppercase; }
.detail-value { font-size: 14px; color: var(--text); }

/* ── Timeline (approval log) ─────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; gap: 14px; padding-bottom: 20px;
  position: relative;
}
.timeline-item::before {
  content: ''; position: absolute;
  left: 14px; top: 28px; bottom: 0;
  width: 1px; background: var(--b1);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--b2);
  background: var(--s2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; flex-shrink: 0;
}
.timeline-body { flex: 1; }
.timeline-title { font-size: 13px; font-weight: 700; }
.timeline-meta  { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
.timeline-comment { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ── Empty state ─────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ── Chip / tag ──────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.chip-proj   { background: rgba(var(--c-proj-rgb),.12); border:1px solid rgba(var(--c-proj-rgb),.3); color:var(--c-proj); }
.chip-prov   { background: rgba(var(--c-prov-rgb),.12); border:1px solid rgba(var(--c-prov-rgb),.3); color:var(--c-prov); }
.chip-cat    { background: rgba(var(--c-cat-rgb),.12);  border:1px solid rgba(var(--c-cat-rgb),.3);  color:var(--c-cat);  }
.chip-item   { background: rgba(var(--c-item-rgb),.12); border:1px solid rgba(var(--c-item-rgb),.3); color:var(--c-item); }

/* ── Divider ─────────────────────────────────── */
.divider {
  height: 1px; background: var(--b1);
  margin: 20px 0;
}

/* ── Utilities ───────────────────────────────── */
.text-muted   { color: var(--muted); }
.text-proj    { color: var(--c-proj); }
.text-prov    { color: var(--c-prov); }
.text-cat     { color: var(--c-cat); }
.text-item    { color: var(--c-item); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.mono         { font-family: var(--mono); }
.fw-700       { font-weight: 700; }
.fw-800       { font-weight: 800; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.mb-4         { margin-bottom: 4px; }
.mb-16        { margin-bottom: 16px; }
.gap-8        { gap: 8px; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }

/* ── Layout utility: responsive 2-col grids ────── */
.layout-split {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}
.layout-split-sm {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

/* ── Sidebar backdrop overlay (mobile) ──────────── */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-backdrop.open { display: block; }

/* ── Tablet (≤1100px) ───────────────────────────── */
@media (max-width: 1100px) {
  :root { --sidebar-w: 220px; }
  .stats-grid      { grid-template-columns: repeat(3, 1fr); }
  .layout-split    { grid-template-columns: 280px 1fr; }
  .layout-split-sm { grid-template-columns: 1fr 260px; }
}

/* ── Mobile (≤768px) ────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 265px; }

  /* Sidebar slides in over content */
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    box-shadow: 6px 0 32px rgba(0,0,0,.2);
  }
  .sidebar.open  { transform: translateX(0); }
  .main-area     { margin-left: 0 !important; }

  /* Topbar */
  .topbar   { padding: 0 12px; }
  .breadcrumb { display: none; }
  .user-info  { display: none; }
  .user-pill  { padding: 4px 8px 4px 4px; gap: 6px; }

  /* Page */
  .page-content { padding: 14px 12px 52px; }
  .page-header  { flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .page-title   { font-size: 17px; }

  /* Cards */
  .card        { padding: 14px; border-radius: 12px; }
  .card-header { margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat-card  { padding: 14px; }
  .stat-value { font-size: 22px; }

  /* Tables */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 560px; }
  .data-table th, .data-table td { padding: 9px 10px; font-size: 12.5px; }

  /* Forms + layout grids → single column */
  .form-grid, .detail-grid,
  .layout-split, .layout-split-sm { grid-template-columns: 1fr; }

  /* Filters */
  .filters-bar { flex-direction: column !important; align-items: stretch !important; }
  /* When a <form> is nested inside .filters-bar (e.g. provinces, categories pages) */
  .filters-bar form { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
  .filters-bar select,
  .filters-bar input[type="text"],
  .filters-bar input[type="date"] { max-width: 100% !important; min-width: 0 !important; width: 100% !important; }
  /* Search wrap becomes full-width on mobile */
  .search-wrap { flex: none; min-width: 0; width: 100%; }
  .search-wrap input { min-width: 0 !important; }

  /* Misc */
  .flash  { font-size: 13px; padding: 10px 12px; }
  .btn    { padding: 7px 12px; font-size: 12.5px; }
  .btn-sm { padding: 4px 9px; font-size: 11.5px; }
  .login-card { padding: 28px 20px; }
  .modal      { padding: 20px; }
}

/* ── Extra-small (≤480px) ───────────────────────── */
@media (max-width: 480px) {
  .page-title   { font-size: 15px; }
  .stats-grid   { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-value   { font-size: 20px; }
  .stat-card    { padding: 12px; }
  .card         { padding: 12px; }
  .page-content { padding: 12px 10px 48px; }
  .topbar       { padding: 0 10px; }
  .login-card   { padding: 22px 16px; border-radius: 16px; }
  .login-logo-img { width: 80px; height: 80px; }
  .login-logo h2  { font-size: 17px; }
  .user-avatar  { width: 26px; height: 26px; font-size: 11px; }
  .user-pill    { padding: 3px 6px 3px 3px; }
  .data-table th, .data-table td { padding: 8px; font-size: 12px; }
}

@media print {
  .sidebar, .topbar, .btn, .filters-bar, .pagination,
  .sidebar-toggle, .modal-overlay, .page-header > div:last-child
  { display: none !important; }
  .main-area { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  a { color: inherit !important; text-decoration: none !important; }
}
