/* ═══════════════════════════════════════════════════════════════════════════
   Rihotech — Main Stylesheet
   Figtree font · CSS custom properties · Primary-color sidebar/topbar
   Light/dark mode · Sneat-inspired layout · Mobile-first responsive
   ═══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap');

/* ── 1. CSS CUSTOM PROPERTIES ─────────────────────────────────────────────── */
:root {
  /* Primary — overridden at runtime via inline <style> from SiteSetting */
  --primary:        #4f46e5;
  --primary-dark:   #3730a3;
  --primary-light:  #818cf8;
  --primary-shadow: rgba(79,70,229,.25);

  /* Layout */
  --sidebar-width:     260px;
  --topbar-height:      60px;
  --sidebar-collapsed:  72px;

  /* Surface / background */
  --bg-body:       #f4f5fb;
  --bg-card:       #ffffff;
  --bg-sidebar:    var(--primary);
  --bg-topbar:     var(--primary);
  --bg-input:      #ffffff;
  --bg-hover:      rgba(255,255,255,.12);

  /* Text */
  --text-body:     #3b3b4f;
  --text-muted:    #8c8ca0;
  --text-sidebar:  rgba(255,255,255,.85);
  --text-sidebar-active: #ffffff;
  --text-heading:  #1e1e2d;

  /* Borders */
  --border:        #e4e4ee;
  --border-input:  #d0d0e0;
  --radius:        10px;
  --radius-sm:      6px;
  --radius-lg:     16px;

  /* Shadows */
  --shadow-sm:  0 1px 4px rgba(0,0,0,.06);
  --shadow:     0 2px 12px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.12);

  /* Status colours */
  --c-success:  #22c55e;
  --c-warning:  #f59e0b;
  --c-danger:   #ef4444;
  --c-info:     #3b82f6;
  --c-purple:   #8b5cf6;
  --c-pending:  #f59e0b;
  --c-open:     #3b82f6;
  --c-resolved: #22c55e;
  --c-closed:   #6b7280;

  /* Transition */
  --transition: all .22s cubic-bezier(.4,0,.2,1);
}

/* ── 2. DARK MODE ─────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-body:    #151521;
  --bg-card:    #1e1e2d;
  --bg-input:   #252535;
  --bg-hover:   rgba(255,255,255,.08);
  --text-body:  #d0d0e6;
  --text-muted: #6b6b8a;
  --text-heading: #e4e4f8;
  --border:      #2e2e45;
  --border-input:#3a3a55;
  --shadow-sm:  0 1px 4px rgba(0,0,0,.3);
  --shadow:     0 2px 12px rgba(0,0,0,.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.5);
}

/* ── 3. RESET & BASE ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: 'Figtree', system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-body);
  background: var(--bg-body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.btn:hover, .btn:active, .btn:focus,
.service-card:hover, .service-card:active,
.card-header a:hover,
.breadcrumb a:hover,
.nav-link:hover, .sidebar-link:hover { text-decoration: none; }

img, svg { display: block; max-width: 100%; }

/* ── 4. LAYOUT SHELL ──────────────────────────────────────────────────────── */
.layout-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── 5. SIDEBAR ───────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  transition: var(--transition);
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 600;
  min-height: var(--topbar-height);
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }

.sidebar-logo-text { white-space: nowrap; }

.sidebar-inner {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}

.sidebar-section-label {
  padding: 10px 20px 4px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.5);
  white-space: nowrap;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-sidebar);
  border-radius: 0;
  font-size: .92rem;
  font-weight: 500;
  transition: var(--transition);
  min-height: 44px;
  white-space: nowrap;
  text-decoration: none;
}

.sidebar-nav a svg,
.sidebar-nav a .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .75;
}

.sidebar-nav a:hover {
  background: var(--bg-hover);
  color: #fff;
}

.sidebar-nav a:hover svg,
.sidebar-nav a:hover .nav-icon { opacity: 1; }

.sidebar-nav a.active {
  background: rgba(255,255,255,.18);
  color: var(--text-sidebar-active);
  font-weight: 600;
}

.sidebar-nav a.active svg,
.sidebar-nav a.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
}

/* Sidebar close button (mobile) */
.sidebar-close {
  display: none;
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  border-radius: 6px;
  width: 30px; height: 30px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ── 5b. SIDEBAR COLLAPSED (desktop) ──────────────────────────────────────── */
.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-section-label,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-footer .btn-text { display: none; }

.sidebar.collapsed .sidebar-logo {
  justify-content: center;
  padding: 18px 10px;
}

.sidebar.collapsed .sidebar-nav a {
  justify-content: center;
  padding: 10px;
  gap: 0;
  position: relative;
}

.sidebar.collapsed .sidebar-footer > * {
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
}

/* Tooltip on collapsed nav items */
.sidebar.collapsed .sidebar-nav a::after {
  content: attr(data-title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(20,20,35,.92);
  color: #fff;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: .78rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 500;
  opacity: 0;
  transition: opacity .15s;
}

.sidebar.collapsed .sidebar-nav a:hover::after {
  opacity: 1;
}

.layout-page.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed) !important;
}

/* ── 6. CONTENT AREA ──────────────────────────────────────────────────────── */
.layout-page {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  transition: margin-left .22s cubic-bezier(.4,0,.2,1);
}

/* ── 7. TOPBAR ────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--bg-topbar);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

.topbar-menu-toggle {
  display: flex;
  background: none;
  border: none;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  line-height: 0;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.topbar-menu-toggle:hover { background: rgba(255,255,255,.12); color: #fff; }

/* Dark mode toggle */
.dark-mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 8px;
  color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.1);
  border: none;
  cursor: pointer;
  transition: var(--transition);
}
.dark-mode-toggle:hover { background: rgba(255,255,255,.2); color: #fff; }

.topbar-title {
  color: #fff;
  font-weight: 600;
  font-size: 1.05rem;
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 8px;
  color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.1);
  border: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.topbar-icon-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

.topbar-badge {
  position: absolute;
  top: 5px; right: 5px;
  background: var(--c-danger);
  color: #fff;
  border-radius: 20px;
  min-width: 16px; height: 16px;
  font-size: .65rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

/* User avatar chip */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,.9);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 6px 4px 4px;
  border-radius: 30px;
  background: rgba(255,255,255,.1);
  transition: var(--transition);
  text-decoration: none;
  min-height: 44px;
  border: none;
}

.topbar-user:hover { background: rgba(255,255,255,.2); color: #fff; }

.topbar-user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.topbar-user-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── 8. PAGE CONTENT ──────────────────────────────────────────────────────── */
.content-wrapper {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 20px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.3;
}

.page-subtitle {
  font-size: .88rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Breadcrumbs */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  margin-top: 4px;
}

.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { color: var(--border); }
.breadcrumb-current { color: var(--text-body); font-weight: 500; }

/* ── 9. CARDS ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-heading);
}

.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── 10. STATS CARDS ──────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.stat-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1.3rem;
}

.stat-icon-primary { background: rgba(79,70,229,.12); color: var(--primary); }
.stat-icon-success { background: rgba(34,197,94,.12);  color: var(--c-success); }
.stat-icon-warning { background: rgba(245,158,11,.12); color: var(--c-warning); }
.stat-icon-danger  { background: rgba(239,68,68,.12);  color: var(--c-danger); }
.stat-icon-info    { background: rgba(59,130,246,.12); color: var(--c-info); }
.stat-icon-purple  { background: rgba(139,92,246,.12); color: var(--c-purple); }

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}

.stat-label {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── 11. TABLES ───────────────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.table th, .table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--bg-body);
}

.table tbody tr:hover { background: var(--bg-body); }
.table tbody tr:last-child td { border-bottom: none; }

.table-clickable tbody tr { cursor: pointer; }
.table-clickable tbody tr:hover td { background: rgba(79,70,229,.04); }

/* ── 12. FORMS ────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: .92rem;
  font-family: inherit;
  color: var(--text-body);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.5;
  min-height: 44px;
  appearance: none;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-shadow);
}

.form-control::placeholder { color: var(--text-muted); opacity: .7; }

select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: .8rem; color: var(--c-danger); margin-top: 4px; }

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  flex: 1;
}

.input-group-append .btn {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: none;
}

/* ── 13. BUTTONS ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: .9rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
  min-height: 44px;
  user-select: none;
}

.btn:disabled, .btn[disabled] {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-secondary {
  background: #6b7280;
  color: #fff;
  border-color: #6b7280;
}
.btn-secondary:hover { background: #4b5563; border-color: #4b5563; color: #fff; }

.btn-success { background: var(--c-success); color: #fff; border-color: var(--c-success); }
.btn-success:hover { background: #16a34a; border-color: #16a34a; color: #fff; }

.btn-danger { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }

.btn-warning { background: var(--c-warning); color: #fff; border-color: var(--c-warning); }
.btn-warning:hover { background: #d97706; border-color: #d97706; color: #fff; }

.btn-info { background: var(--c-info); color: #fff; border-color: var(--c-info); }

.btn-outline-primary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline-primary:hover { background: var(--primary); color: #fff; }

.btn-outline-secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-input);
}
.btn-outline-secondary:hover { background: var(--bg-body); color: var(--text-body); }

.btn-sm  { padding: 6px 12px; font-size: .82rem; min-height: 34px; }
.btn-lg  { padding: 13px 26px; font-size: 1rem; min-height: 50px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); min-height: unset; }

.btn-loading { pointer-events: none; opacity: .75; }

/* ── 14. BADGES / STATUS CHIPS ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.5;
}

.badge-primary { background: rgba(79,70,229,.12); color: var(--primary); }
.badge-success { background: rgba(34,197,94,.12);  color: #16a34a; }
.badge-warning { background: rgba(245,158,11,.12); color: #d97706; }
.badge-danger  { background: rgba(239,68,68,.12);  color: #dc2626; }
.badge-info    { background: rgba(59,130,246,.12); color: #2563eb; }
.badge-sent    { background: rgba(34,197,94,.12);  color: #16a34a; }
.badge-failed  { background: rgba(239,68,68,.12);  color: #dc2626; }
.badge-secondary { background: rgba(107,114,128,.12); color: #4b5563; }
.badge-purple  { background: rgba(139,92,246,.12); color: #7c3aed; }

/* Status-specific */
.badge-pending   { background: rgba(245,158,11,.12); color: #d97706; }
.badge-processing { background: rgba(59,130,246,.12); color: #2563eb; }
.badge-validated { background: rgba(34,197,94,.12);  color: #16a34a; }
.badge-completed { background: rgba(34,197,94,.12);  color: #16a34a; }
.badge-open      { background: rgba(59,130,246,.12); color: #2563eb; }
.badge-in_review { background: rgba(139,92,246,.12); color: #7c3aed; }
.badge-approved  { background: rgba(34,197,94,.12);  color: #16a34a; }
.badge-rejected  { background: rgba(239,68,68,.12);  color: #dc2626; }
.badge-resolved  { background: rgba(34,197,94,.12);  color: #16a34a; }
.badge-closed    { background: rgba(107,114,128,.12); color: #4b5563; }
.badge-active    { background: rgba(34,197,94,.12);  color: #16a34a; }
.badge-inactive  { background: rgba(107,114,128,.12); color: #4b5563; }
.badge-suspended { background: rgba(239,68,68,.12);  color: #dc2626; }

/* ── 15. ALERTS ───────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
  margin-bottom: 16px;
}

.alert-success { background: rgba(34,197,94,.1);  border-color: rgba(34,197,94,.25);  color: #166534; }
.alert-danger  { background: rgba(239,68,68,.1);  border-color: rgba(239,68,68,.25);  color: #991b1b; }
.alert-warning { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.25); color: #92400e; }
.alert-info    { background: rgba(59,130,246,.1); border-color: rgba(59,130,246,.25); color: #1e40af; }

[data-theme="dark"] .alert-success { color: #4ade80; }
[data-theme="dark"] .alert-danger  { color: #f87171; }
[data-theme="dark"] .alert-warning { color: #fcd34d; }
[data-theme="dark"] .alert-info    { color: #93c5fd; }

/* ── 16. MODALS ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(.97);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.modal-backdrop.open .modal { transform: none; }

.modal-lg { max-width: 720px; }
.modal-sm { max-width: 380px; }

.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-heading);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  line-height: 0;
  transition: var(--transition);
  min-width: 30px;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover { background: var(--bg-body); color: var(--text-body); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ── 17. DROPDOWNS ────────────────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 300;
  overflow: hidden;
  display: none;
}

.dropdown-menu.show { display: block; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: .88rem;
  color: var(--text-body);
  transition: background .12s;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--bg-body); }
.dropdown-item.text-danger { color: var(--c-danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── 18. AUTH PAGES ───────────────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  padding: 20px;
}

.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
  color: var(--primary);
  font-size: 1.35rem;
  font-weight: 700;
}

.auth-logo img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }

.auth-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 6px;
  text-align: center;
}

.auth-subtitle {
  font-size: .88rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
}

/* ── 19. NOTIFICATION PANEL ───────────────────────────────────────────────── */
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 320px;
  max-height: 420px;
  display: none;
  flex-direction: column;
  z-index: 300;
  overflow: hidden;
}

.notif-panel.show { display: flex; }

.notif-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-heading);
}

.notif-list { overflow-y: auto; flex: 1; }

.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
  text-decoration: none;
}

.notif-item:hover { background: var(--bg-body); }
.notif-item.unread { background: rgba(79,70,229,.04); }
.notif-item.unread:hover { background: rgba(79,70,229,.08); }

.notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 6px;
  flex-shrink: 0;
}

.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: .85rem; font-weight: 600; color: var(--text-heading); }
.notif-msg { font-size: .8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-time { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }

/* ── 20. COMPLAINT THREAD CHAT ────────────────────────────────────────────── */
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
}

.chat-msg {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-msg.me { align-self: flex-end; align-items: flex-end; }
.chat-msg.other { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg.me .chat-bubble    { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.other .chat-bubble { background: var(--bg-body); color: var(--text-body); border-bottom-left-radius: 4px; border: 1px solid var(--border); }

.chat-meta { font-size: .72rem; color: var(--text-muted); padding: 0 4px; }

/* ── 21. PAGINATION ───────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  color: var(--text-body);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.page-link:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 700; }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ── 22. UTILITIES ────────────────────────────────────────────────────────── */
.d-flex       { display: flex; }
.d-none       { display: none !important; }
.align-center { align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.flex-1       { flex: 1; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); }
.text-danger  { color: var(--c-danger); }
.text-success { color: var(--c-success); }
.text-primary { color: var(--primary); }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.fs-sm        { font-size: .82rem; }
.fs-lg        { font-size: 1.1rem; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.ms-auto { margin-left: auto; }
.w-100 { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
.spinner-dark { border-color: rgba(0,0,0,.15); border-top-color: var(--primary); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ── 23. OVERLAY (sidebar mobile) ────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 199;
}

.sidebar-overlay.show { display: block; }

/* ── 24. RESPONSIVE — Mobile first ───────────────────────────────────────── */
@media (max-width: 991px) {
  html, body { overflow-x: hidden; max-width: 100%; }

  /* Sidebar off-canvas */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.collapsed { width: var(--sidebar-width); }

  .sidebar-close { display: flex; }

  .layout-page { margin-left: 0 !important; }
  .layout-page.sidebar-collapsed { margin-left: 0 !important; }

  .layout-wrapper { max-width: 100vw; }
  .content-wrapper { padding: 16px; overflow-x: hidden; max-width: 100%; }

  /* Modal full-screen on mobile */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    transform: translateY(100%);
  }
  .modal-backdrop.open .modal { transform: translateY(0); }

  /* Hide less-important table columns */
  .table .hide-mobile { display: none; }

  /* Notif panel full width */
  .notif-panel { position: fixed; top: calc(var(--topbar-height) + 8px); left: 8px; right: 8px; width: auto; border-radius: var(--radius); }

  /* Stats wrap tighter */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 576px) {
  html { font-size: 14px; }

  .auth-card { padding: 28px 20px; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Prevent iOS zoom on input focus */
  input, select, textarea { font-size: 16px !important; }

  .card-header { flex-direction: column; align-items: flex-start; }

  .btn-block-mobile { width: 100%; justify-content: center; }

  .topbar-title { display: none; }
  .topbar-actions { margin-left: auto; }
}

/* ── 25. RESPONSIVE PAGE GRID HELPERS ────────────────────────────────────── */
.page-grid-2     { display:grid; grid-template-columns:1fr 1fr;   gap:1.5rem; align-items:start; }
.page-grid-wide  { display:grid; grid-template-columns:1fr 1.5fr; gap:1.5rem; align-items:start; }
.page-grid-aside { display:grid; grid-template-columns:2fr 1fr;   gap:1.5rem; align-items:start; }
.form-row-2      { display:grid; grid-template-columns:1fr 1fr;   gap:1rem; }

/* Prevent grid children from overflowing their tracks */
.page-grid-2 > *, .page-grid-wide > *, .page-grid-aside > *,
.nin-grid > *, .data-grid > *, .form-row-2 > * { min-width: 0; }

/* 3-column stats variant — collapses responsively */
.stats-cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .stats-cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stats-cols-3 { grid-template-columns: 1fr; } }

@media (max-width: 900px) {
  .page-grid-2,
  .page-grid-wide,
  .page-grid-aside { grid-template-columns: 1fr; }
  /* Existing nin-grid / data-grid already handled at 900px */
  .nin-grid  { grid-template-columns: 1fr !important; }
  .data-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 576px) {
  .form-row-2 { grid-template-columns: 1fr !important; }
  .slip-type-grid { grid-template-columns: 1fr 1fr !important; }
  .service-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .page-grid-2, .page-grid-wide, .page-grid-aside { grid-template-columns: 1fr !important; }
}

/* ── 25. WALLET BALANCE DISPLAY ───────────────────────────────────────────── */
.wallet-display {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.wallet-display::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}

.wallet-label { font-size: .82rem; opacity: .8; font-weight: 500; }
.wallet-amount { font-size: 2rem; font-weight: 700; margin: 4px 0; letter-spacing: -.02em; }
.wallet-account { font-size: .82rem; opacity: .75; }

/* ── 26. SERVICE GRID ─────────────────────────────────────────────────────── */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.service-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  text-decoration: none;
  color: var(--text-body);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.service-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-shadow);
  transform: translateY(-2px);
  color: var(--primary);
  text-decoration: none;
}

.service-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: rgba(79,70,229,.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  color: var(--primary);
}

.service-name { font-size: .88rem; font-weight: 600; text-decoration: none; }
.service-price { font-size: .78rem; color: var(--text-muted); }

/* ── 27. SLIP RESULT AREA ─────────────────────────────────────────────────── */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-photo {
  width: 90px; height: 90px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid var(--border);
}

.result-field {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}

.result-field:last-child { border-bottom: none; }
.result-field-label { color: var(--text-muted); min-width: 140px; font-size: .85rem; }
.result-field-value { color: var(--text-heading); font-weight: 500; }

/* ── 28. EMPTY STATE ──────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: .4; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--text-body); margin-bottom: 4px; }
.empty-state-msg { font-size: .88rem; }
