/* ============================================================
   GCC ERP — Design System
   Modern light SaaS: indigo primary, clean white surfaces,
   Inter typography, soft shadows, generous whitespace.
   ============================================================ */

:root {
  /* Color tokens */
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-300: #a5b4fc;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-800: #3730a3;
  --brand-900: #312e81;

  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --success-50: #ecfdf5;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;

  --danger-50: #fef2f2;
  --danger-500: #f43f5e;
  --danger-600: #e11d48;
  --danger-700: #be123c;

  --warning-50: #fffbeb;
  --warning-500: #f59e0b;
  --warning-600: #d97706;

  --info-50: #eff6ff;
  --info-500: #3b82f6;

  /* Surface & text */
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* Brand primary */
  --primary: var(--brand-600);
  --primary-hover: var(--brand-700);
  --primary-soft: var(--brand-50);

  /* Sidebar (dark navy, GCC brand tie-in) */
  --sidebar-w: 264px;
  --sidebar-collapsed-w: 72px;
  --sidebar-bg: #0f172a;
  --sidebar-bg-2: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active-bg: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-item-bg: rgba(255, 255, 255, 0.03);

  /* Topbar */
  --topbar-h: 68px;
  --topbar-bg: rgba(255, 255, 255, 0.85);

  /* Metrics */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.06);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-family, inherit);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }

/* ============================================================
   App entrance (screen-split reveal)
   ============================================================ */
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-100%); } to { opacity: 1; transform: none; } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-100%); } to { opacity: 1; transform: none; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.topbar { animation: fadeInDown 0.5s var(--ease) both; }
.sidebar { animation: slideInLeft 0.5s var(--ease) both; }
.main-content { animation: fadeInUp 0.45s var(--ease) both; }

/* ============================================================
   Scrollbars
   ============================================================ */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 8px; }
*::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(var(--sidebar-w) - 24px);
  height: 46px;
  margin-left: -8px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  line-height: 0;
  flex-shrink: 0;
  transition: all 0.2s var(--ease);
}
.brand:hover { border-color: var(--border-strong); }
.brand img.brand-full-logo {
  flex: 1;
  min-width: 0;
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}
.brand .brand-icon-logo { display: none; width: 30px; height: 30px; }
.topbar.is-collapsed .brand { width: calc(var(--sidebar-collapsed-w) - 16px); margin-left: -12px; gap: 2px; padding: 0 4px; }
.topbar.is-collapsed .brand .brand-full-logo { display: none; }
.topbar.is-collapsed .brand .brand-icon-logo { display: block; width: 26px; height: 26px; }
.topbar.is-collapsed .brand .sidebar-toggle-btn { width: 26px; height: 26px; font-size: 0.75rem; }

.topbar-welcome {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.topbar-welcome strong { color: var(--text); font-weight: 600; }

.page-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}

.topbar-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 1.25rem;
  position: relative;
  transition: all 0.15s ease;
}
.topbar-btn:hover { background: var(--gray-100); color: var(--primary); }
.topbar-btn:active { transform: scale(0.94); }

.sidebar-toggle-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--sidebar-border);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--gray-600);
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { border-color: var(--sidebar-text-active); color: var(--primary); background: var(--gray-100); }

.notif-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  color: #fff;
  background: var(--danger-500);
  border-radius: 10px;
  border: 2px solid var(--surface);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
  border: 1px solid transparent;
}
.user-menu:hover { background: var(--gray-100); }
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13px; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   Layout
   ============================================================ */
.layout { display: flex; min-height: 100vh; padding-top: var(--topbar-h); }
.main-content { flex: 1; padding: 24px; overflow-y: auto; background: var(--bg); }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px 24px;
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  transition: width 0.22s var(--ease);
}
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); }

.nav-section { margin-bottom: 8px; }
.nav-section-title {
  padding: 14px 12px 6px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--sidebar-border);
  background: var(--sidebar-item-bg);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  margin-bottom: 6px;
  transition: all 0.15s ease;
}
.nav-link i { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); border-color: var(--sidebar-text-active); }
.nav-link.active {
  background: var(--sidebar-active-bg);
  border-color: var(--sidebar-active-bg);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.nav-link span { transition: opacity 0.15s ease; }

/* Collapsed sidebar */
.layout.is-collapsed .sidebar { width: var(--sidebar-collapsed-w); padding: 16px 8px 24px; }
.layout.is-collapsed .nav-section-title,
.layout.is-collapsed .nav-link span { opacity: 0; width: 0; pointer-events: none; }
.layout.is-collapsed .nav-link { justify-content: center; padding: 10px 0; }
.layout.is-collapsed .nav-section-title { padding: 14px 0 6px; text-align: center; }

/* ============================================================
   Dashboard
   ============================================================ */
/* ============================================================
   Dashboard
   ============================================================ */

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  flex-shrink: 0;
}
.stat-label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 1.6rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.icon-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.icon-green { background: linear-gradient(135deg, #10b981, #059669); }
.icon-purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.icon-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.icon-teal { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.icon-red { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.icon-indigo { background: linear-gradient(135deg, #818cf8, #4f46e5); }

/* Dashboard toolbar (financial year + refresh) */
.dash-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.dash-toolbar-left { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dash-toolbar-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  white-space: nowrap;
}
.year-tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: 10px;
}
.year-tab {
  border: none;
  background: transparent;
  color: var(--gray-500);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: all 0.15s ease;
}
.year-tab:hover { color: var(--text); }
.year-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ============================================================
   Dashboard Cards (6-card layout)
   ============================================================ */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (max-width: 1600px) { .dash-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1200px) { .dash-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all 0.2s ease;
}
.dash-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }

.dash-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
  position: relative;
}
.dash-card-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
}
.dash-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.dash-badge {
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 650;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-primary { background: var(--brand-50); color: var(--brand-700); }
.badge-success { background: var(--success-50); color: var(--success-700); }
.badge-danger { background: var(--danger-50); color: var(--danger-700); }
.badge-muted { background: var(--gray-100); color: var(--gray-600); border: 1px solid var(--border); }

.dash-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  padding: 2px 16px 10px;
}
.dash-metric { display: flex; flex-direction: column; gap: 2px; }
.dash-metric-label { font-size: 10.5px; color: var(--text-muted); font-weight: 500; }
.dash-metric-value { font-size: 1.15rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1.15; }
.dash-metric-full { grid-column: 1 / -1; }
.dash-divider {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.dash-card-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--gray-100);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}
.dash-card-footer .dash-badge { margin-left: 6px; }

/* Icon gradient variants for dash cards */
.icon-secondary { background: linear-gradient(135deg, #64748b, #475569); }
.icon-success { background: linear-gradient(135deg, #10b981, #059669); }
.icon-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.icon-info { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
.icon-primary { background: linear-gradient(135deg, #818cf8, #4f46e5); }

/* Text color utilities */
.text-success { color: var(--success-600); }
.text-danger { color: var(--danger-500); }
.text-primary { color: var(--brand-600); }
.text-secondary { color: var(--gray-500); }
.text-warning { color: var(--warning-500); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.panel-title { font-size: 1.05rem; font-weight: 700; margin: 0 0 8px; letter-spacing: -0.01em; }
.panel-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; }

/* ============================================================
   Shared module primitives (gcc-*)
   Reusable cross-module building blocks (Accounts, and any future
   module that needs a list + detail-split layout on a panel).
   ============================================================ */

/* Master-detail split: account list (left) + detail panel (right) */
.gcc-split {
  display: grid; grid-template-columns: minmax(320px, 44%) 1fr;
  gap: 16px; align-items: start;
}
@media (max-width: 1280px) { .gcc-split { grid-template-columns: 1fr; } }

/* Panel shell (card with header / body / footer) */
.gcc-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.gcc-panel-head {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); display: flex; align-items: center;
  justify-content: space-between; gap: 10px;
}
.gcc-panel-title { font-size: 13.5px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.gcc-panel-title .bi { color: var(--brand-600); font-size: 15px; }
.gcc-panel-sub { font-size: 11px; color: var(--text-muted); }
.gcc-panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Toolbar (search + date + buttons row) */
.gcc-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.gcc-search { position: relative; flex: 1; min-width: 150px; }
.gcc-search input {
  width: 100%; padding: 7px 10px 7px 30px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12.5px; color: var(--text);
  background: var(--surface); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.gcc-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12); }
.gcc-search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 12px; }
.gcc-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--gray-700); font-size: 12.5px;
  font-weight: 600; cursor: pointer; transition: all 0.15s ease; white-space: nowrap;
}
.gcc-btn:hover { border-color: var(--border-strong); background: var(--gray-50); color: var(--text); }
.gcc-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.gcc-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.gcc-btn.primary:hover { background: var(--primary-hover); }
.gcc-btn.ghost { border-color: transparent; background: transparent; color: var(--gray-600); }
.gcc-btn.ghost:hover { background: var(--gray-100); color: var(--text); }
.gcc-date {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text); background: var(--surface);
}
.gcc-input, .gcc-select {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text); background: var(--surface);
  min-width: 0;
}
.gcc-input:focus, .gcc-select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.gcc-input:disabled, .gcc-input[readonly] { background: var(--gray-100); color: var(--gray-600); }
.gcc-select { padding-right: 24px; }

/* Charm chip (stat value inside statement header / toolbar) */
.gcc-chip {
  display: flex; flex-direction: column; gap: 1px; padding: 5px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); min-width: 96px;
}
.gcc-chip-label { font-size: 9.5px; font-weight: 650; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.gcc-chip-value { font-size: 15px; font-weight: 750; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.gcc-chip-value.positive { color: var(--success-600); }
.gcc-chip-value.negative { color: var(--danger-600); }

/* Table scroll container + shared table */
.gcc-table-scroll { flex: 1; overflow: auto; min-height: 0; }
.gcc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.gcc-table thead th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  text-align: left; padding: 8px 10px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--gray-600); border-bottom: 2px solid var(--border);
  white-space: nowrap; cursor: pointer; user-select: none;
}
.gcc-table th.bp-num, .gcc-table td.bp-num,
.gcc-table th.gcc-num, .gcc-table td.gcc-num { text-align: right; }
.gcc-table th.gcc-center, .gcc-table td.gcc-center { text-align: center; }
.gcc-table tbody td { padding: 7px 10px; border-bottom: 1px solid var(--gray-100); }
.gcc-table tbody tr:nth-child(even) { background: var(--surface-2); }
.gcc-table tbody tr:hover { background: var(--gray-50); }
.gcc-table tfoot td {
  position: sticky; bottom: 0; z-index: 2; background: var(--gray-900); color: #fff;
  font-weight: 700; padding: 8px 10px;
}
.gcc-table tfoot td.gcc-num { text-align: right; }

/* ============================================================
   Admin panel (drawer)
   ============================================================ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s var(--ease);
}
.drawer-overlay.show { opacity: 1; visibility: visible; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(560px, 94vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 2001;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
  transform: translateX(64px);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.34s var(--ease-slide), opacity 0.24s ease, visibility 0s linear 0.34s;
  display: flex;
  flex-direction: column;
}
.drawer.show { transform: translateX(0); opacity: 1; visibility: visible; transition: transform 0.34s var(--ease-slide), opacity 0.24s ease, visibility 0s; }
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.drawer-header h2 { font-size: 1.15rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.drawer-header p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }
.drawer-close {
  width: 36px; height: 36px; border: none; background: var(--gray-100);
  border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--gray-500); font-size: 1.1rem; transition: all 0.15s ease;
}
.drawer-close:hover { background: var(--gray-200); color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }

/* Panel tabs */
.panel-tabs { display: flex; gap: 4px; padding: 4px; background: var(--gray-100); border-radius: 12px; margin-bottom: 20px; }
.panel-tab {
  flex: 1; border: none; background: transparent; padding: 9px 12px;
  border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--gray-500);
  cursor: pointer; transition: all 0.15s ease; display: flex; align-items: center; justify-content: center; gap: 7px;
}
.panel-tab:hover { color: var(--text); }
.panel-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* Users table */
.admin-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search-field {
  position: relative;
}
.search-field i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-400); font-size: 14px; }
.search-field input {
  width: 260px; max-width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  background: var(--surface-2);
  transition: all 0.15s ease;
}
.search-field input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--brand-100);
  background: #fff;
}

.users-table { width: 100%; border-collapse: collapse; }
.users-table thead th {
  position: sticky; top: 0; z-index: 2;
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.users-table tbody td { padding: 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; font-size: 13.5px; }
.users-table tbody tr { transition: background 0.12s ease; }
.users-table tbody tr:nth-child(even) { background: var(--surface-2); }
.users-table tbody tr:hover { background: var(--gray-50); }
.users-table tbody tr:last-child td { border-bottom: none; }

.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell .user-avatar { width: 38px; height: 38px; font-size: 14px; }
.user-cell .name { font-weight: 600; color: var(--text); }
.user-cell .email { font-size: 12.5px; color: var(--text-muted); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
}
.badge-role-admin { background: var(--brand-50); color: var(--brand-700); }
.badge-role-user { background: var(--gray-100); color: var(--gray-600); }
.badge-status-active { background: var(--success-50); color: var(--success-700); }
.badge-status-inactive { background: var(--danger-50); color: var(--danger-700); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions button {
  width: 32px; height: 32px; border: 1px solid var(--border);
  background: #fff; border-radius: 8px; display: inline-flex; align-items: center;
  justify-content: center; cursor: pointer; color: var(--gray-500);
  font-size: 14px; transition: all 0.15s ease;
}
.row-actions button:hover { border-color: var(--primary); color: var(--primary); background: var(--brand-50); }
.row-actions button.danger:hover { border-color: var(--danger-500); color: var(--danger-600); background: var(--danger-50); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; color: var(--gray-300); margin-bottom: 12px; }
.empty-state h4 { margin: 0 0 4px; color: var(--text); font-weight: 650; }
.empty-state p { margin: 0; font-size: 13px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  transition: all 0.15s ease; line-height: 1;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }
.btn-secondary { background: #fff; color: var(--gray-700); border-color: var(--border); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--border-strong); }
.btn-danger { background: var(--danger-600); color: #fff; }
.btn-danger:hover { background: var(--danger-700); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn:disabled, .btn[disabled] {
  opacity: 0.55; cursor: not-allowed; box-shadow: none; transform: none;
  pointer-events: none;
}

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--gray-700); }
.form-control, .form-select {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13.5px;
  background: #fff;
  transition: all 0.15s ease;
  color: var(--text);
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--brand-100);
}
.form-control:disabled, .form-select:disabled,
.form-control[readonly] {
  background: var(--gray-100); color: var(--gray-600); cursor: not-allowed;
}

/* Permissions (roles) grid */
.perm-section { margin-top: 20px; }
.perm-section-title { font-size: 13px; font-weight: 700; margin: 0 0 10px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.perm-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 900px) { .perm-grid { grid-template-columns: repeat(3, 1fr); } }
.perm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer; transition: all 0.15s ease; font-size: 13px;
}
.perm-item:hover { border-color: var(--border-strong); background: var(--gray-50); }
.perm-item input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }

.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Alert / toast */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 500; margin-bottom: 16px;
}
.alert-success { background: var(--success-50); color: var(--success-700); border: 1px solid rgba(16,185,129,0.2); }
.alert-danger { background: var(--danger-50); color: var(--danger-700); border: 1px solid rgba(244,63,94,0.2); }
.alert-info { background: var(--info-50); color: #1d4ed8; border: 1px solid rgba(59,130,246,0.2); }

.toast-stack {
  position: fixed; top: calc(var(--topbar-h) + 16px); right: 16px;
  z-index: 3000; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--gray-900); color: #fff; padding: 14px 18px;
  border-radius: 12px; box-shadow: var(--shadow-xl); font-size: 13.5px;
  min-width: 260px; max-width: 380px;
  transform: translateX(120%); transition: transform 0.3s var(--ease);
}
.toast.show { transform: translateX(0); }
.toast i.bi-check-circle { color: var(--success-500); }
.toast i.bi-x-circle { color: var(--danger-500); }

/* Confirm modal */
.confirm-overlay {
  position: fixed; inset: 0; background: var(--scrim-modal);
  backdrop-filter: blur(3px);
  /* Above .modal-overlay's 2600 — a confirm is almost always triggered from
     inside an already-open modal (e.g. deleting a row), so it must render
     on top of it, not behind it. */
  z-index: 2650; display: flex; align-items: center; justify-content: flex-end;
  opacity: 0; visibility: hidden;
  transition: opacity 0.2s var(--ease), visibility 0s linear 0.36s;
}
.confirm-overlay.show { opacity: 1; visibility: visible; transition: opacity 0.2s var(--ease), visibility 0s; }
.confirm-box {
  background: var(--surface); border: 1px solid var(--border); border-right: none;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg); padding: 28px;
  width: min(420px, 92vw); box-shadow: var(--shadow-xl);
  height: 100vh; display: flex; flex-direction: column; justify-content: center;
  transform: translateX(100%); opacity: 0;
  transition: transform 0.36s var(--ease-slide), opacity 0.24s ease;
}
.confirm-overlay.show .confirm-box { transform: translateX(0); opacity: 1; }
.confirm-box h3 { margin: 0 0 8px; font-size: 1.1rem; }
.confirm-box p { margin: 0 0 20px; color: var(--text-muted); font-size: 13.5px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Generic modal — right-edge sheet, same family as the admin drawer.
   Enters sliding from the right, exits sliding back to the right. */
.modal-overlay {
  position: fixed; inset: 0; background: var(--scrim-modal);
  backdrop-filter: blur(3px);
  z-index: 2600; display: flex; align-items: stretch; justify-content: flex-end;
  opacity: 0; visibility: hidden;
  transition: opacity 0.2s var(--ease), visibility 0s linear 0.45s;
}
.modal-overlay.show { opacity: 1; visibility: visible; transition: opacity 0.2s var(--ease), visibility 0s; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border); border-right: none;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
  width: min(1100px, 100vw); height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateX(100%);
  /* Longer than the drawer/confirm-box on purpose: this sheet travels up to
     1650px (modal-box-xl) vs. the drawer's fixed 64px or confirm-box's
     ~420px, so the same duration would cover far more distance in the same
     time and read as an abrupt snap rather than a slide. */
  transition: transform 0.45s var(--ease-slide);
}
.modal-box.modal-box-xl { width: min(1650px, 100vw); height: 100%; max-height: none; }
.modal-box.modal-box-detail { width: min(550px, 100vw); height: 100%; max-height: none; }
.modal-box.modal-box-email { width: min(760px, 100vw); height: 100%; max-height: none; }
.modal-box.modal-box-stmt { width: min(1080px, 94vw); height: 100%; max-height: none; }
.modal-overlay.show .modal-box { transform: translateX(0); }

/* Loading */
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--gray-200); border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.center-loading { display: flex; align-items: center; justify-content: center; padding: 60px 0; }
.charts-loading { display: flex; align-items: center; justify-content: center; padding: 24px 0; }

/* Analytics / charts */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px 16px 12px;
  transition: all 0.2s ease;
}
.chart-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.chart-card-wide { grid-column: 1 / -1; }
.chart-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.chart-card-title { font-size: 0.9rem; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.chart-card-sub { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.chart-toggle { display: flex; gap: 4px; }
.chart-toggle-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chart-toggle-btn:hover { background: var(--bg); }
.chart-toggle-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.chart-canvas { position: relative; width: 100%; min-height: 260px; }

@media (max-width: 1200px) { .charts-grid { grid-template-columns: 1fr; } .chart-card-wide { grid-column: auto; } }

/* Entrance animations — slide + fade + a touch of scale. Each group has its
   own direction (top cards from above, charts from their own side, bottom
   cards from below) but triggerEntranceAnimations() in app.js fires every
   card's animation with a 0ms delay, so all three groups land together
   instead of cascading one after another. */
@keyframes slideFromTop {
  from { transform: translateY(-34px) scale(0.97); opacity: 0; }
  60% { opacity: 1; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes slideFromBottom {
  from { transform: translateY(34px) scale(0.97); opacity: 0; }
  60% { opacity: 1; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes slideFromLeft {
  from { transform: translateX(-56px); opacity: 0; }
  60% { opacity: 1; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideFromRight {
  from { transform: translateX(56px); opacity: 0; }
  60% { opacity: 1; }
  to { transform: translateX(0); opacity: 1; }
}

.animate-slide-top {
  animation: slideFromTop 0.65s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.animate-slide-bottom {
  animation: slideFromBottom 0.65s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.animate-slide-left {
  animation: slideFromLeft 0.75s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.animate-slide-right {
  animation: slideFromRight 0.75s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Initially hidden — revealed by the animation itself (animation-fill-mode:
   both applies the 0%-keyframe opacity before the delay elapses, so cards
   stay invisible until their turn instead of flashing then waiting). Once
   an entrance finishes, JS swaps the animate-* class for .settled so
   :hover transforms (see .dash-card:hover) aren't fighting a
   still-applied animation end-state. */
.dash-grid .dash-card,
.charts-grid .chart-card,
.bottom-cards-grid .dash-card {
  opacity: 0;
}
.dash-grid .dash-card.settled,
.charts-grid .chart-card.settled,
.bottom-cards-grid .dash-card.settled {
  opacity: 1;
}

/* Bottom Cards Grid */
.bottom-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  align-items: stretch;
  margin-top: 24px;
}
.bottom-cards-grid .dash-card {
  min-width: 0;
}

/* Income Statement Body */
.income-statement-body {
  font-family: 'Inter', sans-serif;
}
.is-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.is-row:last-child { border-bottom: none; }
.is-row.total { font-weight: 600; }
.is-row.net { font-weight: 700; font-size: 14px; padding-top: 12px; }
.is-label { color: var(--text-muted); font-weight: 500; }
.is-value { font-weight: 600; text-align: right; }
.is-divider {
  height: 2px;
  background: var(--border);
  margin: 4px 0;
}
.is-divider.thick {
  height: 3px;
  background: var(--primary);
  margin: 8px 0;
}

/* Key Indicators Body */
.key-indicators-body {
  font-family: 'Inter', sans-serif;
}
.ki-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.ki-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ki-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.ki-row:last-child { border-bottom: none; }
.ki-label { color: var(--text-muted); font-weight: 500; }
.ki-value { font-weight: 600; font-size: 14px; }
.ki-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* HR Body */
.hr-body {
  font-family: 'Inter', sans-serif;
}
.hr-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.hr-row:last-child { border-bottom: none; }
.hr-label { color: var(--text-muted); font-weight: 500; }
.hr-value { font-weight: 600; font-size: 14px; }
.hr-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Responsive */
@media (max-width: 1200px) {
  .bottom-cards-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: var(--topbar-h); transform: translateX(-100%); z-index: 1500; height: calc(100vh - var(--topbar-h)); }
  .sidebar.mobile-open { transform: translateX(0); }
  .layout.is-collapsed .sidebar { width: var(--sidebar-w); transform: translateX(-100%); }
  .main-content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .user-meta { display: none; }
}

/* ============================================================
   Admin: expandable user rows (row click expands in place instead
   of opening a second modal) + a wider drawer while expanded.
   ============================================================ */
.drawer.drawer-wide { width: min(900px, 96vw); }

.users-table tbody tr.user-row { cursor: pointer; }
.users-table tbody tr.user-row:hover { background: var(--gray-50); }
.users-table tbody tr.user-row.expanded { background: var(--brand-50); }
.users-table tbody tr.user-row.expanded td { border-bottom-color: transparent; }
.users-table tbody tr.user-row-new { cursor: default; }

.user-detail-row td { padding: 0; border-bottom: 1px solid var(--gray-100); background: var(--surface-2); }
.user-detail { padding: 20px 22px 22px; }

.role-section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 10px; flex-wrap: wrap; }
.role-section-header .perm-section-title { margin: 0; }
.role-section-actions { display: flex; gap: 8px; }

.role-grid-full { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 760px) { .role-grid-full { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .role-grid-full { grid-template-columns: repeat(4, 1fr); } }

.role-grid-dash { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (min-width: 600px) { .role-grid-dash { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .role-grid-dash { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1200px) { .role-grid-dash { grid-template-columns: repeat(6, 1fr); } }
.perm-item-compact { padding: 5px 8px; gap: 6px; font-size: 12px; border-radius: 8px; }
.perm-item-compact input[type="checkbox"] { width: 14px; height: 14px; margin: 0; }
.perm-item-compact { line-height: 1.1; }

.user-detail-footer { display: flex; align-items: center; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.user-detail-footer .spacer { flex: 1; }

/* ============================================================
   Profile view
   ============================================================ */
.profile-hero { text-align: center; padding: 8px 0 24px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.profile-avatar-lg {
  width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-700));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; box-shadow: var(--shadow-md);
}
.profile-name { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.profile-email { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.profile-badges { display: flex; align-items: center; justify-content: center; gap: 8px; }

.info-card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 22px; }
.info-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--gray-100); font-size: 13.5px; }
.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.info-row-label i { color: var(--gray-400); font-size: 14px; }
.info-row-value { font-weight: 600; color: var(--text); }

.security-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: #fff; border: 1px solid var(--border); border-radius: 12px;
  cursor: pointer; transition: all 0.15s ease; font-size: 13.5px; font-weight: 600; color: var(--gray-800);
}
.security-toggle:hover { border-color: var(--border-strong); background: var(--gray-50); }
.security-toggle.active { border-color: var(--primary); background: var(--brand-50); color: var(--primary); }
.security-toggle-label { display: flex; align-items: center; gap: 10px; }
.security-toggle-icon {
  width: 32px; height: 32px; border-radius: 8px; background: var(--gray-100); color: var(--gray-500);
  display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; transition: all 0.15s ease;
}
.security-toggle.active .security-toggle-icon { background: var(--primary); color: #fff; }
.security-toggle-chevron { transition: transform 0.25s ease; color: var(--gray-400); }
.security-toggle.active .security-toggle-chevron { transform: rotate(180deg); color: var(--primary); }
.password-section { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.password-section.open { max-height: 420px; }
.password-section-inner { padding-top: 16px; }

/* ============================================================
   Skins, density, and motion preferences
   Skin values are applied by the boot script from the cached
   user settings (data-skin on the html element). Midnight is the
   only dark skin; ocean and sunset are light skins that swap the
   brand ramp and sidebar gradient.
   ============================================================ */

:root {
  --toast-bg: #0f172a;
  --toast-text: #ffffff;
  --tfoot-bg: #0f172a;
  --tfoot-text: #ffffff;
  --skeleton-a: #eef1f6;
  --skeleton-b: #e2e8f0;
  --scrim: rgba(15, 23, 42, 0.45);
  --ring: rgba(99, 102, 241, 0.14);
  --grad-deep-a: #1e3a5f;
  --grad-deep-b: #2c5282;
  --scrim-modal: rgba(15, 23, 42, 0.5);
  --ease-slide: cubic-bezier(0.32, 0.72, 0, 1);
}

html[data-skin="ocean"] {
  --brand-50: #eff9f8;
  --brand-100: #d7f1ef;
  --brand-200: #afE3df;
  --brand-300: #7ecdc8;
  --brand-400: #45b0ab;
  --brand-500: #1f948f;
  --brand-600: #0d7d78;
  --brand-700: #0a6360;
  --brand-800: #094f4d;
  --brand-900: #083f3e;
  --sidebar-active-bg: linear-gradient(135deg, #0d9488 0%, #0ea5e9 100%);
  --ring: rgba(13, 125, 120, 0.15);
}

html[data-skin="sunset"] {
  --brand-50: #fdf6ec;
  --brand-100: #faead0;
  --brand-200: #f3d3a4;
  --brand-300: #eab46f;
  --brand-400: #e0953e;
  --brand-500: #d07d1e;
  --brand-600: #b3641a;
  --brand-700: #8f4d17;
  --brand-800: #743e19;
  --brand-900: #5e3316;
  --bg: #faf7f2;
  --sidebar-active-bg: linear-gradient(135deg, #d97706 0%, #dc2626 100%);
  --ring: rgba(179, 100, 26, 0.16);
}

html[data-skin="midnight"] {
  --bg: #0b1120;
  --surface: #131a2b;
  --surface-2: #0f1526;
  --border: #24304a;
  --border-strong: #33415e;
  --text: #e8edf7;
  --text-muted: #9aa7bd;
  --text-faint: #64748b;

  --gray-50: #131a2b;
  --gray-100: #1a2338;
  --gray-200: #24304a;
  --gray-300: #33415e;
  --gray-400: #52617f;
  --gray-500: #7c8aa5;
  --gray-600: #9aa7bd;
  --gray-700: #c2cbdb;
  --gray-800: #dbe2ee;
  --gray-900: #e8edf7;

  --brand-50: rgba(99, 102, 241, 0.14);
  --brand-100: rgba(99, 102, 241, 0.24);
  --brand-200: rgba(99, 102, 241, 0.38);
  --brand-300: #8f97f9;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #7b83f4;
  --brand-700: #929af6;
  --brand-800: #a8aef8;
  --brand-900: #c3c7fa;
  --primary: #6366f1;
  --primary-hover: #7b83f4;
  --primary-soft: rgba(99, 102, 241, 0.14);

  --success-50: rgba(16, 185, 129, 0.14);
  --danger-50: rgba(244, 63, 94, 0.13);
  --warning-50: rgba(245, 158, 11, 0.13);
  --info-50: rgba(59, 130, 246, 0.13);

  --sidebar-bg: #0b1120;
  --sidebar-bg-2: #131a2b;
  --sidebar-border: rgba(255, 255, 255, 0.07);
  --topbar-bg: rgba(19, 26, 43, 0.85);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.5), 0 1px 2px -1px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 8px -2px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 20px -6px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 24px 30px -8px rgba(0, 0, 0, 0.6);

  --toast-bg: #1e293b;
  --toast-text: #e8edf7;
  --tfoot-bg: #1e293b;
  --tfoot-text: #e8edf7;
  --skeleton-a: #1a2338;
  --skeleton-b: #24304a;
  --scrim: rgba(2, 6, 17, 0.66);
  --grad-deep-a: #16233c;
  --grad-deep-b: #1f3152;
}

/* Surface-following fixes for elements that hardcoded white. */
html[data-skin="midnight"] .search-field input:focus { background: var(--surface); }
html[data-skin="midnight"] .row-actions button { background: var(--surface); }
html[data-skin="midnight"] .security-toggle { background: var(--surface); }
html[data-skin="midnight"] .gcc-table tfoot td { background: var(--tfoot-bg); color: var(--tfoot-text); }
html[data-skin="midnight"] .toast { background: var(--toast-bg); color: var(--toast-text); border: 1px solid var(--border); }
html[data-skin="midnight"] .nav-section-title { color: #5b6a86; }
html[data-skin="midnight"] .brand, html[data-skin="midnight"] .modal-box { background: var(--surface); }
html[data-skin="midnight"] .user-avatar,
html[data-skin="midnight"] .profile-avatar-lg { background: linear-gradient(135deg, #4f46e5, #7c3aed); }

/* Toast + footer tokens (all skins). */
.toast { background: var(--toast-bg); color: var(--toast-text); }
.gcc-table tfoot td { background: var(--tfoot-bg); color: var(--tfoot-text); }
.drawer-overlay { background: var(--scrim); }
.drawer { box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35); }

/* ---------- Density ---------- */
html[data-density="compact"] .gcc-table { font-size: 11.8px; }
html[data-density="compact"] .gcc-table tbody td { padding: 3px 8px; }
html[data-density="compact"] .gcc-table thead th { padding: 5px 8px; }
html[data-density="compact"] .gcc-panel-head { padding: 8px 12px; }
html[data-density="compact"] .main-content { padding: 14px; }
html[data-density="compact"] .gcc-input, html[data-density="compact"] .gcc-select,
html[data-density="compact"] .gcc-date { padding: 3px 6px; }
html[data-density="compact"] .gcc-btn { padding: 4px 9px; }

/* ---------- Motion ---------- */
html[data-motion="always"] *,
html[data-motion="always"] *::before,
html[data-motion="always"] *::after {
  animation-duration: 0.001s !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001s !important;
  scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  html[data-motion="auto"] *,
  html[data-motion="auto"] *::before,
  html[data-motion="auto"] *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Focus visibility ---------- */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.topbar-btn:focus-visible, .nav-link:focus-visible, .gcc-btn:focus-visible {
  outline-offset: 3px;
}

/* ---------- Skeleton shimmer (module loading states) ---------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--skeleton-a);
  border-radius: 8px;
  min-height: 14px;
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- Settings drawer sections ---------- */
.settings-section { margin-bottom: 26px; }
.settings-section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 12px;
}
.settings-section-title i { color: var(--primary); font-size: 14px; }
.settings-section-title:not(:first-child) { margin-top: 8px; }
.skin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .skin-grid { grid-template-columns: repeat(4, 1fr); } }
.skin-card {
  position: relative;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  cursor: pointer;
  background: var(--surface);
  transition: border-color 0.15s ease, transform 0.15s ease;
  text-align: left;
  font: inherit;
  color: inherit;
}
.skin-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.skin-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.skin-card .skin-check {
  position: absolute; top: 6px; right: 6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: none; align-items: center; justify-content: center; font-size: 11px;
}
.skin-card.active .skin-check { display: inline-flex; }
.skin-preview {
  height: 62px; border-radius: 8px; margin-bottom: 7px; overflow: hidden;
  display: flex; flex-direction: column;
  border: 1px solid rgba(15, 23, 42, 0.08);
}
.skin-preview .sp-top { height: 12px; }
.skin-preview .sp-body { flex: 1; display: flex; }
.skin-preview .sp-side { width: 26%; }
.skin-preview .sp-main { flex: 1; padding: 5px; display: flex; flex-direction: column; gap: 4px; }
.skin-preview .sp-card { border-radius: 4px; height: 12px; }
.skin-name { font-size: 12px; font-weight: 600; }

.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 11px 0; border-bottom: 1px solid var(--gray-100);
}
.setting-row:last-child { border-bottom: none; }
.setting-row-label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.setting-row-sub { font-size: 11.5px; color: var(--text-muted); font-weight: 400; margin-top: 2px; }
.setting-row select {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 12.5px; font-family: inherit;
  min-width: 150px;
}
.settings-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }

/* ---------- App boot splash ---------- */
.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  background: linear-gradient(160deg, var(--brand-900, #312e81) 0%, var(--brand-600, #4f46e5) 55%, #7c3aed 100%);
  opacity: 1;
  transition: opacity 0.45s ease, visibility 0.45s;
}
html[data-skin="midnight"] .boot-splash {
  background: linear-gradient(160deg, #020617 0%, #0f172a 55%, #1e1b4b 100%);
}
.boot-splash.leaving { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-mark {
  width: 92px; height: 92px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 24px;
  backdrop-filter: blur(6px);
  animation: bootMarkPop 0.7s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
.boot-mark svg { width: 58px; height: 58px; }
.boot-mark .bm-stroke {
  stroke: #fff; stroke-width: 2.4; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 320; stroke-dashoffset: 320;
  animation: bmDraw 1.5s ease forwards;
}
.boot-mark .bm-fill {
  fill: rgba(255, 255, 255, 0.9); opacity: 0;
  animation: bmFadeIn 0.6s ease 1s forwards;
}
@keyframes bmDraw { to { stroke-dashoffset: 0; } }
@keyframes bmFadeIn { to { opacity: 1; } }
@keyframes bootMarkPop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
.boot-wordmark {
  color: #fff; font-weight: 800; font-size: 1.5rem; letter-spacing: 0.42em;
  text-indent: 0.42em; text-transform: uppercase;
  animation: bootFadeUp 0.6s ease 0.35s both;
}
.boot-tagline {
  color: rgba(255, 255, 255, 0.62); font-size: 0.8rem; letter-spacing: 0.14em;
  text-transform: uppercase; margin-top: -16px;
  animation: bootFadeUp 0.6s ease 0.55s both;
}
@keyframes bootFadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.boot-bar {
  width: 220px; height: 4px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  animation: bootFadeUp 0.5s ease 0.7s both;
}
.boot-bar i {
  display: block; height: 100%; width: 38%;
  border-radius: 4px;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  animation: bootBarSlide 1.1s ease-in-out infinite;
}
@keyframes bootBarSlide { from { transform: translateX(-120%); } to { transform: translateX(680%); } }
/* Entrance keyframes on shell only play after boot (see app.js booted class). */
body:not(.booted) .topbar,
body:not(.booted) .sidebar,
body:not(.booted) .main-content { animation: none; opacity: 0; }
body.booted .topbar { animation: fadeInDown 0.5s var(--ease) both; }
body.booted .sidebar { animation: slideInLeft 0.5s var(--ease) both; }
body.booted .main-content { animation: fadeInUp 0.45s var(--ease) both; }

/* ---------- Page transition ---------- */
.page-enter { animation: pageEnter 0.28s var(--ease) both; }
@keyframes pageEnter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Document viewer variant (cheque copy viewer). */
.modal-box.modal-box-doc {
  width: min(1380px, 100vw);
  height: 100%;
  max-height: none;
}

html[data-skin="ocean"] {
  --grad-deep-a: #083f3e;
  --grad-deep-b: #0d7d78;
}
html[data-skin="sunset"] {
  --grad-deep-a: #5e3316;
  --grad-deep-b: #8f4d17;
}
