/* ============================================================
   DESIGN TOKENS / THEME VARIABLES
   ============================================================ */
:root {
  --accent:         #6366f1;
  --accent-hover:   #4f46e5;
  --accent-light:   #e0e7ff;
  --accent-text:    #3730a3;

  --bg-app:         #f1f5f9;
  --bg-card:        #ffffff;
  --bg-sidebar:     #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-input:       #ffffff;
  --bg-tag:         #f1f5f9;

  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-sidebar:   #94a3b8;
  --text-sidebar-active: #ffffff;

  --border:         #e2e8f0;
  --border-focus:   #6366f1;

  --success:        #10b981;
  --success-bg:     #d1fae5;
  --success-text:   #065f46;
  --warning:        #f59e0b;
  --warning-bg:     #fef3c7;
  --warning-text:   #92400e;
  --danger:         #ef4444;
  --danger-bg:      #fee2e2;
  --danger-text:    #991b1b;
  --info:           #3b82f6;
  --info-bg:        #dbeafe;
  --info-text:      #1e40af;

  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --shadow-xl:  0 20px 25px -5px rgba(0,0,0,.1), 0 10px 10px -5px rgba(0,0,0,.04);

  --sidebar-w:  240px;
  --topbar-h:   60px;
  --r:          8px;
  --r-sm:       5px;
  --r-lg:       12px;
  --r-xl:       16px;

  --transition: 150ms ease;
}

[data-theme="dark"] {
  --bg-app:         #0f172a;
  --bg-card:        #1e293b;
  --bg-sidebar:     #020617;
  --bg-sidebar-hover: #0f172a;
  --bg-input:       #1e293b;
  --bg-tag:         #334155;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-sidebar:   #64748b;

  --border:         #334155;
  --border-focus:   #818cf8;

  --accent-light:   #1e1b4b;
  --accent-text:    #a5b4fc;

  --success-bg:     #064e3b;
  --success-text:   #6ee7b7;
  --warning-bg:     #451a03;
  --warning-text:   #fde68a;
  --danger-bg:      #450a0a;
  --danger-text:    #fca5a5;
  --info-bg:        #1e3a5f;
  --info-text:      #93c5fd;

  --shadow-sm:  0 1px 2px rgba(0,0,0,.3);
  --shadow:     0 1px 3px rgba(0,0,0,.4);
  --shadow-md:  0 4px 6px rgba(0,0,0,.4);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.4);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }
svg { display: block; flex-shrink: 0; }

/* ============================================================
   LAYOUT
   ============================================================ */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
}
.app-shell {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left var(--transition);
}
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 100;
  display: none; /* hidden on desktop */
}
.main {
  flex: 1;
  padding: 28px 28px 48px;
  max-width: 1280px;
  width: 100%;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 190;
}

/* ============================================================
   SUITE SWITCHER
   ============================================================ */
.suite-switcher {
  display: flex; gap: 4px;
  padding: 8px 12px 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.suite-btn {
  flex: 1; padding: 7px 4px;
  font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  border: none; border-radius: 7px; cursor: pointer;
  transition: background .15s, color .15s;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.suite-btn svg { flex-shrink: 0; }
.suite-btn:not(.active) { background: rgba(255,255,255,.07); color: rgba(255,255,255,.4); }
.suite-card.active { background: #6366f1; color: #fff; }
.suite-inv.active  { background: #10b981; color: #fff; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar-logo {
  display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo-img {
  height: 26px; width: auto;
  background: #fff; border-radius: 5px; padding: 3px 8px;
  display: block;
}
.logo-text {
  font-size: .67rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: rgba(255,255,255,.4);
}
.sidebar-nav {
  flex: 1; padding: 12px 10px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r);
  color: var(--text-sidebar);
  font-size: .875rem; font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon { width: 18px; height: 18px; opacity: .7; flex-shrink: 0; }
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { opacity: 1; }
.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.theme-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 12px;
  border-radius: var(--r);
  color: var(--text-sidebar);
  font-size: .825rem;
  transition: background var(--transition), color var(--transition);
}
.theme-btn:hover { background: var(--bg-sidebar-hover); color: #e2e8f0; }
.theme-btn svg { width: 16px; height: 16px; }

/* ============================================================
   TOPBAR (mobile)
   ============================================================ */
.hamburger {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--r);
  color: var(--text-secondary);
  transition: background var(--transition);
}
.hamburger:hover { background: var(--bg-tag); }
.hamburger svg { width: 22px; height: 22px; }
.topbar-title { flex: 1; font-weight: 600; font-size: 1rem; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r);
  font-size: .875rem; font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-tag); color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-tag); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--r);
  color: var(--text-secondary);
  transition: background var(--transition);
}
.btn-icon:hover { background: var(--bg-tag); }
.btn-icon svg { width: 18px; height: 18px; }

/* ============================================================
   CARDS / PANELS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-body { padding: 20px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: .9rem; font-weight: 600; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 24px; gap: 12px; flex-wrap: wrap;
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -.3px; }
.page-header p { font-size: .875rem; color: var(--text-secondary); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============================================================
   STAT CARDS (dashboard)
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.stat-label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.stat-icon {
  width: 36px; height: 36px;
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-light);
  color: var(--accent);
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-value { font-size: 1.65rem; font-weight: 700; letter-spacing: -.5px; line-height: 1; }
.stat-sub { font-size: .78rem; color: var(--text-muted); margin-top: 6px; }

/* ============================================================
   CREDIT CARD VISUAL
   ============================================================ */
.cc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.cc-card {
  border-radius: var(--r-xl);
  padding: 22px 24px;
  position: relative; overflow: hidden;
  color: white;
  min-height: 175px;
  display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
  user-select: none;
}
.cc-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-xl); }
.cc-card::before {
  content: '';
  position: absolute; top: -40px; right: -40px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
}
.cc-card::after {
  content: '';
  position: absolute; bottom: -60px; right: 30px;
  width: 200px; height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.cc-top { display: flex; align-items: center; justify-content: space-between; }
.cc-chip {
  width: 36px; height: 28px;
  background: linear-gradient(135deg, #fde68a, #f59e0b);
  border-radius: 5px;
  position: relative;
}
.cc-chip::after {
  content: '';
  position: absolute; inset: 5px;
  border: 1.5px solid rgba(0,0,0,.15);
  border-radius: 3px;
}
.cc-bank-logo {
  display: flex; gap: -4px;
}
.cc-bank-logo span {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-block;
}
.cc-bank-logo span:first-child { background: rgba(255,255,255,.8); margin-right: -10px; }
.cc-bank-logo span:last-child  { background: rgba(255,255,255,.5); }
.cc-number {
  font-size: 1rem; letter-spacing: .15em; font-weight: 500;
  margin-top: 20px; opacity: .9;
}
.cc-bottom {
  display: flex; align-items: flex-end; justify-content: space-between;
}
.cc-holder { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; opacity: .75; }
.cc-holder strong { display: block; font-size: .95rem; opacity: 1; letter-spacing: .03em; margin-top: 2px; }
.cc-limit { text-align: right; }
.cc-limit-label { font-size: .68rem; opacity: .7; text-transform: uppercase; letter-spacing: .05em; }
.cc-limit-value { font-size: .95rem; font-weight: 600; }
.cc-actions {
  display: flex; gap: 8px; margin-top: 16px;
}
.cc-actions .btn { flex: 1; font-size: .78rem; padding: 7px 10px; }

/* Card wrapper in cards view */
.cc-card-wrap {
  display: flex; flex-direction: column; gap: 12px;
}

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.progress-wrap { margin-top: 8px; }
.progress-label {
  display: flex; justify-content: space-between;
  font-size: .75rem; color: var(--text-secondary);
  margin-bottom: 6px;
}
.progress-bar {
  height: 6px; background: var(--border);
  border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px;
  background: var(--success);
  transition: width .5s ease;
}
.progress-fill.warn  { background: var(--warning); }
.progress-fill.alert { background: var(--danger); }
.progress-alert {
  display: flex; align-items: center; gap: 6px;
  font-size: .75rem; color: var(--danger);
  margin-top: 6px; font-weight: 500;
}
.progress-alert svg { width: 13px; height: 13px; }

/* ============================================================
   CHARTS
   ============================================================ */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.chart-container { padding: 20px; }
.chart-title { font-size: .875rem; font-weight: 600; margin-bottom: 16px; }
.donut-wrap {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.donut-svg { flex-shrink: 0; overflow: visible; }
.donut-legend { flex: 1; min-width: 120px; }
.legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: .78rem; padding: 4px 0;
  color: var(--text-secondary);
}
.legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.legend-label { flex: 1; }
.legend-value { font-weight: 600; color: var(--text-primary); }
.bar-chart-svg { width: 100%; overflow: visible; }
.bar-chart-wrap { overflow-x: auto; }
.no-data { text-align: center; color: var(--text-muted); font-size: .875rem; padding: 32px 0; }

/* ============================================================
   TRANSACTIONS TABLE
   ============================================================ */
.filters-bar {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 16px;
}
.search-wrap {
  position: relative; flex: 1; min-width: 200px;
}
.search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); width: 16px; height: 16px; pointer-events: none;
}
.search-input {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-input); color: var(--text-primary);
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
.filter-select {
  padding: 8px 30px 8px 10px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-input); color: var(--text-primary);
  font-size: .875rem; min-width: 130px;
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  transition: border-color var(--transition);
}
.filter-select:focus { outline: none; border-color: var(--border-focus); }
.date-range-wrap {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.date-range-wrap input[type="date"] {
  padding: 7px 10px; font-size: .8rem;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-input); color: var(--text-primary);
  cursor: pointer;
}
.date-range-wrap input[type="date"]:focus { outline: none; border-color: var(--border-focus); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--text-primary); }
thead th.sort-asc::after  { content: ' ↑'; }
thead th.sort-desc::after { content: ' ↓'; }
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-app); }
tbody td {
  padding: 11px 14px;
  font-size: .875rem;
  vertical-align: middle;
}
.td-desc { max-width: 220px; }
.td-desc span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-desc small { font-size: .75rem; color: var(--text-muted); }
.td-amount { font-weight: 600; white-space: nowrap; }
.td-actions { display: flex; gap: 4px; }
.receipt-thumb {
  width: 28px; height: 28px; border-radius: 4px;
  object-fit: cover; cursor: pointer;
  border: 1px solid var(--border);
}

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 99px;
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  white-space: nowrap;
}
.badge-pending    { background: var(--warning-bg); color: var(--warning-text); }
.badge-validated  { background: var(--success-bg); color: var(--success-text); }
.badge-refused    { background: var(--danger-bg);  color: var(--danger-text);  }
.badge-reimbursed { background: var(--info-bg);    color: var(--info-text);    }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.cat-badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: .72rem; font-weight: 500;
  background: var(--bg-tag); color: var(--text-secondary);
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap; gap: 8px;
}
.pagination-info { font-size: .78rem; color: var(--text-muted); }
.pagination-btns { display: flex; gap: 4px; align-items: center; }
.page-btn {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: .8rem; color: var(--text-secondary);
  background: var(--bg-input);
  transition: all var(--transition);
}
.page-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: .8rem; font-weight: 500; color: var(--text-secondary); }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-input); color: var(--text-primary);
  font-size: .875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-input.error, .form-select.error { border-color: var(--danger); }
.form-error { font-size: .75rem; color: var(--danger); display: none; }
.form-error.show { display: block; }
.form-select {
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  padding-right: 30px; cursor: pointer;
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.color-preview { display: flex; align-items: center; gap: 8px; }
.color-preview input[type="color"] {
  width: 40px; height: 34px; padding: 2px; cursor: pointer;
  border-radius: var(--r); border: 1px solid var(--border);
  background: var(--bg-input);
}
.color-preview span { font-size: .78rem; color: var(--text-muted); }
.file-upload {
  border: 2px dashed var(--border); border-radius: var(--r);
  padding: 16px; text-align: center; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}
.file-upload:hover { border-color: var(--accent); background: var(--accent-light); }
.file-upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-upload-icon { color: var(--text-muted); margin: 0 auto 6px; }
.file-upload-icon svg { width: 28px; height: 28px; }
.file-upload p { font-size: .8rem; color: var(--text-muted); }
.file-preview { margin-top: 10px; position: relative; display: inline-block; }
.file-preview img { max-height: 80px; border-radius: var(--r); border: 1px solid var(--border); }
.file-preview-remove {
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: white;
  font-size: .75rem; display: flex; align-items: center; justify-content: center;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.5); backdrop-filter: blur(2px);
  z-index: 300;
}
.modal-overlay.open { display: block; }
.modal {
  display: none; position: fixed;
  top: 50%; left: 50%; transform: translate(-50%, -48%);
  z-index: 310;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: hidden;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: var(--shadow-xl);
}
.modal.open {
  opacity: 1; pointer-events: all;
  transform: translate(-50%, -50%);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--r-sm);
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--bg-tag); color: var(--text-primary); }
.modal-close svg { width: 18px; height: 18px; }
.modal-body { overflow-y: auto; padding: 20px; flex: 1; }

/* ============================================================
   CONFIRM DIALOG
   ============================================================ */
.confirm-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.5); backdrop-filter: blur(2px);
  z-index: 400;
}
.confirm-overlay.open { display: block; }
.confirm-dialog {
  display: none; position: fixed;
  top: 50%; left: 50%; transform: translate(-50%, -48%);
  z-index: 410;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: min(400px, calc(100vw - 32px));
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  box-shadow: var(--shadow-xl);
}
.confirm-dialog.open { display: block; opacity: 1; pointer-events: all; transform: translate(-50%, -50%); }
.confirm-body { padding: 28px 24px 20px; text-align: center; }
.confirm-icon-wrap svg { width: 44px; height: 44px; margin: 0 auto 14px; display: block; }
.confirm-dialog h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 8px; }
.confirm-dialog p { font-size: .875rem; color: var(--text-secondary); }
.confirm-footer { display: flex; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }
.confirm-footer .btn { flex: 1; justify-content: center; }

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 500; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  font-size: .875rem; font-weight: 500;
  max-width: 340px;
  pointer-events: all;
  transform: translateX(120%);
  transition: transform .3s ease;
  border-left: 4px solid var(--accent);
}
.toast.show { transform: translateX(0); }
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-icon svg { width: 16px; height: 16px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon   { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon    { color: var(--info); }
.toast-close {
  margin-left: auto; color: var(--text-muted); flex-shrink: 0;
  font-size: 1.1rem; line-height: 1; cursor: pointer;
  transition: color var(--transition); align-self: flex-start;
}
.toast-close:hover { color: var(--text-primary); }

/* ============================================================
   SKELETON LOADERS
   ============================================================ */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skel {
  background: linear-gradient(90deg, var(--border) 25%, var(--bg-app) 50%, var(--border) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r);
}
.skeleton-wrap { padding: 4px 0; }
.skel-title  { height: 28px; width: 220px; margin-bottom: 24px; border-radius: var(--r-sm); }
.skel-grid   { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.skel-grid-2 { grid-template-columns: 1fr 1fr; }
.skel-stat   { height: 100px; border-radius: var(--r-lg); }
.skel-chart  { height: 260px; border-radius: var(--r-lg); }
.skel-table  { height: 300px; border-radius: var(--r-lg); }

/* ============================================================
   ALERT BANNER
   ============================================================ */
.alert-banner {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-radius: var(--r);
  margin-bottom: 8px; font-size: .875rem;
  border: 1px solid;
}
.alert-warning {
  background: var(--warning-bg); color: var(--warning-text);
  border-color: rgba(245,158,11,.3);
}
.alert-danger {
  background: var(--danger-bg); color: var(--danger-text);
  border-color: rgba(239,68,68,.3);
}
.alert-banner svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }

/* ============================================================
   SETTINGS PAGE
   ============================================================ */
.settings-section { margin-bottom: 28px; }
.settings-section h2 { font-size: .9rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; gap: 16px;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-info h4 { font-size: .875rem; font-weight: 500; }
.settings-row-info p  { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.toggle-switch {
  position: relative; width: 42px; height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border); border-radius: 99px; cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; border-radius: 50%;
  background: white; box-shadow: var(--shadow-sm);
  top: 3px; left: 3px;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ============================================================
   RECEIPT VIEWER
   ============================================================ */
.receipt-viewer { text-align: center; }
.receipt-viewer img { max-width: 100%; max-height: 500px; border-radius: var(--r); border: 1px solid var(--border); margin: 0 auto; }

/* ============================================================
   CARDS VIEW
   ============================================================ */
.cards-view-header { margin-bottom: 24px; }
.cards-empty {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.cards-empty svg { margin: 0 auto 16px; opacity: .4; }
.cards-empty h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.cards-empty p { font-size: .875rem; }

/* ============================================================
   DASHBOARD CARD ROW
   ============================================================ */
.dash-card-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.dash-card-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.dash-card-item-top {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.dash-card-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.dash-card-name { font-size: .875rem; font-weight: 600; flex: 1; }
.dash-card-last4 { font-size: .75rem; color: var(--text-muted); font-family: monospace; }

/* ============================================================
   UTILITY
   ============================================================ */
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .8rem; }
.font-mono   { font-family: monospace; }
.text-right  { text-align: right; }
.flex        { display: flex; }
.items-center { align-items: center; }
.gap-8       { gap: 8px; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mb-16       { margin-bottom: 16px; }
.divider     { height: 1px; background: var(--border); margin: 16px 0; }
.section-title {
  font-size: .875rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 12px;
}
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted); font-size: .875rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .app-shell { margin-left: 0; }
  .topbar { display: flex; }
  .main { padding: 16px 16px 40px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .skel-grid { grid-template-columns: 1fr 1fr; }
  .skel-grid-2 { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .dash-card-row { grid-template-columns: 1fr; }
  .cc-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .modal { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .donut-wrap { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
  padding: 16px;
}
.login-screen.hidden { display: none; }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 36px 32px 28px;
  width: min(420px, 100%);
  box-shadow: var(--shadow-xl);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo-img { height: 54px; width: auto; display: block; margin: 0 auto 14px; }
.login-logo svg { margin: 0 auto 12px; }
.login-logo h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -.4px; margin-bottom: 4px; }
.login-logo p  { font-size: .85rem; color: var(--text-muted); }
.pwd-wrap {
  position: relative;
}
.pwd-wrap .form-input { padding-right: 40px; }
.pwd-eye {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--transition);
}
.pwd-eye:hover { color: var(--text-primary); }
.pwd-eye svg   { width: 16px; height: 16px; }
.login-options {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; margin-bottom: 4px;
}
.remember-label {
  display: flex; align-items: center; gap: 7px;
  font-size: .8rem; color: var(--text-secondary); cursor: pointer;
}
.remember-label input { cursor: pointer; }
.login-hint-inline { font-size: .75rem; color: var(--text-muted); }
.login-error {
  background: var(--danger-bg); color: var(--danger-text);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--r); padding: 9px 12px;
  font-size: .825rem; margin-top: 12px;
  display: flex; align-items: center; gap: 6px;
}
.login-default-hint {
  text-align: center; margin-top: 18px;
  font-size: .75rem; color: var(--text-muted);
  padding-top: 16px; border-top: 1px solid var(--border);
}
.login-default-hint code {
  background: var(--bg-tag); padding: 1px 6px; border-radius: 4px;
  font-family: monospace; font-size: .8rem; color: var(--accent);
}

/* ============================================================
   SIDEBAR USER / LOGOUT
   ============================================================ */
.sidebar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: var(--r);
  margin-bottom: 6px;
  border: 1px solid rgba(255,255,255,.07);
}
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  display: block; font-size: .8rem; font-weight: 600;
  color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role { font-size: .7rem; color: var(--text-sidebar); }
.logout-btn {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-sidebar); flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.logout-btn:hover { background: rgba(239,68,68,.15); color: #f87171; }
.logout-btn svg { width: 15px; height: 15px; }

/* ============================================================
   RAPPORT CPA — SETTINGS SECTION
   ============================================================ */
.report-options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin-bottom: 20px;
}
.report-options .form-group { margin: 0; }
.report-preview-btns {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.report-year-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; background: var(--accent-light);
  color: var(--accent-text); border-radius: 99px;
  font-size: .78rem; font-weight: 600;
}

/* ============================================================
   CHANGE PASSWORD FORM
   ============================================================ */
.pwd-strength {
  height: 4px; border-radius: 99px;
  background: var(--border); margin-top: 6px; overflow: hidden;
}
.pwd-strength-fill {
  height: 100%; border-radius: 99px;
  transition: width .3s, background .3s;
}
.pwd-strength-label { font-size: .72rem; color: var(--text-muted); margin-top: 3px; }

/* ============================================================
   APP SUITE SWITCHER (sidebar)
   ============================================================ */
.suite-section {
  padding: 10px 10px 4px;
  border-top: 1px solid rgba(255,255,255,.06);
  margin-top: 4px;
}
.suite-label {
  font-size: .65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: #475569; padding: 0 4px 6px;
}
.nav-suite {
  color: #10b981 !important;
  font-size: .8rem;
}
.nav-suite:hover { background: rgba(16,185,129,.12) !important; }
.nav-suite .nav-icon { opacity: 1 !important; }

/* Invoice suite — green accent for nav */
#navInvoice .nav-item.active { background: #10b981; color: #fff; }
#navInvoice .nav-item:hover  { background: rgba(16,185,129,.12); color: #e2e8f0; }

/* ============================================================
   INVOICE — CONTACTS
   ============================================================ */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}
.contact-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.contact-card:hover { box-shadow: var(--shadow-md); }
.contact-card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.contact-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 700; color: #fff;
}
.contact-avatar.client   { background: #6366f1; }
.contact-avatar.supplier { background: #10b981; }
.contact-name { font-size: .9rem; font-weight: 600; color: var(--text-primary); }
.contact-meta { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.contact-stats {
  display: flex; gap: 0;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.contact-stat-item {
  flex: 1; text-align: center;
  padding: 0 8px;
  border-right: 1px solid var(--border);
}
.contact-stat-item:last-child { border-right: none; }
.contact-stat-val { font-size: .88rem; font-weight: 700; color: var(--text-primary); }
.contact-stat-lbl { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-top: 2px; }
