/* dCondomino — Design System v2 */

/* ─── Design Tokens ──────────────────────────────────────── */
:root {
  --sidebar-w: 260px;

  /* Neutrals */
  --bg: #f8f9fb;
  --surface: #ffffff;
  --text: #111827;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --border: #e5e7eb;
  --border-soft: #f3f4f6;

  /* Brand — derived colors auto-update when --primary changes */
  --primary: #059669;
  --primary-hover: color-mix(in srgb, var(--primary) 80%, black);
  --primary-bg: color-mix(in srgb, var(--primary) 10%, white);
  --primary-ring: color-mix(in srgb, var(--primary) 20%, transparent);

  /* Semantic */
  --success: #059669;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: #2563eb;
  --info-bg: #dbeafe;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .06);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, .1);

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  /* Sidebar */
  --sidebar-bg: #0f172a;

  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur: 150ms;
}

/* ─── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; }

/* ─── App Layout ─────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg);
  color: #e2e8f0;
  padding: 24px 16px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}
.sidebar-logo {
  width: 100%;
  max-height: 80px;
  object-fit: contain;
  margin-bottom: 12px;
}
.brand {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  padding: 0 8px;
  letter-spacing: -.02em;
}
.brand-sub {
  color: color-mix(in srgb, var(--sidebar-bg) 30%, #94a3b8);
  font-size: 13px;
  padding: 0 8px;
  margin-top: 2px;
  margin-bottom: 24px;
}

/* Sidebar nav */
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #475569;
  padding: 16px 8px 6px;
}
.nav-section:first-child { padding-top: 0; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--dur) var(--ease);
  border-left: 3px solid transparent;
  margin-left: -3px;
}
.nav a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .7;
}
.nav a:hover {
  color: #e2e8f0;
  background: rgba(255, 255, 255, .06);
}
.nav a:hover svg { opacity: 1; }
.nav a.active {
  color: #fff;
  background: rgba(5, 150, 105, .1);
  border-left-color: var(--primary);
}
.nav a.active svg { opacity: 1; color: var(--primary); }

/* Sidebar light theme (auto-applied when nav bg is light) */
.sidebar-light { color: #374151; border-right: 1px solid var(--border); }
.sidebar-light .brand { color: #111827; }
.sidebar-light .brand-sub { color: #6b7280; }
.sidebar-light .nav-section { color: #9ca3af; }
.sidebar-light .nav a { color: #4b5563; }
.sidebar-light .nav a svg { color: #6b7280; }
.sidebar-light .nav a:hover { color: #111827; background: rgba(0, 0, 0, .05); }
.sidebar-light .nav a:hover svg { color: #111827; }
.sidebar-light .nav a.active { color: var(--primary); background: var(--primary-bg); border-left-color: var(--primary); }
.sidebar-light .nav a.active svg { color: var(--primary); }
.sidebar-light .sidebar-footer { border-top-color: rgba(0, 0, 0, .08); }
.sidebar-light .sidebar-avatar { background: var(--primary-bg); }
.sidebar-light .sidebar-user-email { color: #4b5563; }
.sidebar-light .sidebar-logout { color: #9ca3af !important; }
.sidebar-light .sidebar-logout:hover { color: #111827 !important; }
.sidebar-light .sidebar-collapse-btn { background: rgba(0, 0, 0, .04); border-color: rgba(0, 0, 0, .08); color: #9ca3af; }
.sidebar-light .sidebar-collapse-btn:hover { background: rgba(0, 0, 0, .08); color: #374151; }

/* Sidebar collapse toggle */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px;
  margin-top: 8px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: var(--radius);
  color: #64748b;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.sidebar-collapse-btn:hover { background: rgba(255, 255, 255, .1); color: #e2e8f0; }
.sidebar-collapse-btn svg { transition: transform 200ms var(--ease); }

/* Sidebar collapsed state — desktop only */
.sidebar {
  transition: width 200ms var(--ease), padding 200ms var(--ease);
}
.nav a span {
  transition: opacity 150ms var(--ease);
  white-space: nowrap;
}
@media (min-width: 1025px) {
  body.sidebar-collapsed .app { grid-template-columns: 64px 1fr; }
  body.sidebar-collapsed .sidebar { width: 64px; padding: 16px 8px; overflow: visible; }
  body.sidebar-collapsed .sidebar-logo,
  body.sidebar-collapsed .brand,
  body.sidebar-collapsed .brand-sub,
  body.sidebar-collapsed .nav-section { display: none; }
  body.sidebar-collapsed .nav a span { opacity: 0; width: 0; overflow: hidden; position: absolute; }
  body.sidebar-collapsed .nav a {
    justify-content: center;
    padding: 10px;
    position: relative;
    margin-left: 0;
    border-left: 0;
  }
  body.sidebar-collapsed .nav a.active { border-left: 0; border-radius: var(--radius); }
  body.sidebar-collapsed .nav a:hover span {
    opacity: 1;
    width: auto;
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #e2e8f0;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    pointer-events: none;
  }
  body.sidebar-collapsed .sidebar-user-info { display: none; }
  body.sidebar-collapsed .sidebar-user { justify-content: center; }
  body.sidebar-collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
}
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: rgba(5, 150, 105, .2);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-email {
  font-size: 13px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logout {
  font-size: 12px;
  color: #64748b !important;
  transition: color var(--dur) var(--ease);
}
.sidebar-logout:hover { color: #e2e8f0 !important; }

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--text);
  line-height: 0;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .4);
  z-index: 35;
  opacity: 0;
  transition: opacity 200ms var(--ease);
}
.sidebar-overlay.open { display: block; opacity: 1; }

/* ─── Main Content ───────────────────────────────────────── */
.main {
  padding: 28px 32px;
  min-width: 0;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}
.topbar .btns { margin-top: 0; flex-shrink: 0; }
.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.2;
  color: var(--text);
}
.page-subtitle {
  color: var(--text-2);
  font-size: 14px;
  margin-top: 4px;
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-xs);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.card-header .section-title { margin-bottom: 0; }
.section-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}

/* ─── Metrics ────────────────────────────────────────────── */
.metric {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 6px;
}
.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.metric-value.sm { font-size: 22px; }

/* ─── Grid Helpers ───────────────────────────────────────── */
.grid   { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.layout { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; }

/* ─── Tables ─────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr { background: var(--border-soft); }
th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
tbody tr { transition: background var(--dur) var(--ease); }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
td a:not(.btn) { font-weight: 500; }

/* ─── Forms ──────────────────────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { min-height: 80px; resize: vertical; }
select { cursor: pointer; }
input[type="checkbox"] { width: auto; accent-color: var(--primary); cursor: pointer; }
input[type="color"] { width: 56px; height: 42px; padding: 4px; cursor: pointer; border-radius: var(--radius); }

.form-group { margin-bottom: 16px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-hint {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
}
.form-error {
  font-size: 13px;
  color: var(--danger);
  margin-top: 4px;
  font-weight: 500;
}
.form-inline {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.form-note {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 8px;
}

/* Upload box */
.upload-box {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  background: var(--border-soft);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.upload-box:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

/* ─── Buttons ────────────────────────────────────────────── */
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--dur) var(--ease);
  line-height: 1.4;
}
.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(5, 150, 105, .3);
}
.btn.primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 4px rgba(5, 150, 105, .3);
}
.btn.secondary {
  background: var(--border-soft);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--border); }
.btn.danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 1px 2px rgba(220, 38, 38, .3);
}
.btn.danger:hover { background: #b91c1c; }
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

/* ─── Status Badges ──────────────────────────────────────── */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status.ok  { background: var(--success-bg); color: var(--success); }
.status.warn { background: var(--warning-bg); color: var(--warning); }
.status.bad  { background: var(--danger-bg); color: var(--danger); }
.status-sm { padding: 2px 8px; font-size: 11px; }

/* ─── Messages (Django) ──────────────────────────────────── */
.messages { list-style: none; padding: 0; margin: 0 0 20px 0; }
.messages li {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideDown 200ms var(--ease);
}
.messages .success { background: var(--success-bg); color: #065f46; }
.messages .error   { background: var(--danger-bg);  color: #991b1b; }
.messages .warning { background: var(--warning-bg); color: #92400e; }
.messages .info    { background: var(--info-bg);    color: #1e40af; }

/* ─── Modal Overlay ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 150ms var(--ease);
}
.modal-overlay > .card {
  min-width: 380px;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn 200ms var(--ease);
}

/* ─── Receipt Component ──────────────────────────────────── */
.receipt {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.receipt-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
  margin-bottom: 14px;
}
.receipt-title { font-size: 20px; font-weight: 800; }
.receipt-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.receipt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}
.receipt-field {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.receipt-field small {
  display: block;
  color: var(--text-2);
  margin-bottom: 2px;
  font-size: 12px;
}
.receipt-field strong { font-size: 14px; }

/* ─── Summary Row (Dashboard) ────────────────────────────── */
.summary-list { display: flex; flex-direction: column; gap: 10px; }
.summary-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background var(--dur) var(--ease);
}
.summary-row:hover { background: var(--border-soft); }
.summary-row strong { font-size: 14px; }

/* ─── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
}
.pagination-info {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-2);
}

/* ─── Checkbox field (label beside checkbox) ─────────────── */
.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}
.check-field label { margin-bottom: 0; cursor: pointer; }

/* ─── Color preview ──────────────────────────────────────── */
.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.color-row input[type="text"] { width: 120px; font-family: inherit; }

/* ─── Logo preview ───────────────────────────────────────── */
.logo-preview {
  max-width: 180px;
  max-height: 80px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  background: var(--border-soft);
  margin-bottom: 12px;
}

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-2);
}
.empty-state p { margin: 0; }

/* ─── Login Page ─────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f0fdf4 0%, #f8f9fb 40%, #eff6ff 100%);
}
.login-card {
  width: 400px;
  padding: 36px 32px;
  text-align: center;
}
.login-logo {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.03em;
  margin-bottom: 4px;
}
.login-tagline {
  color: var(--text-2);
  font-size: 14px;
  margin-bottom: 28px;
}
.login-card form { text-align: left; }
.login-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-bottom: 16px;
  padding: 10px;
  background: var(--danger-bg);
  border-radius: var(--radius);
  font-weight: 500;
}

/* ─── HTMX Indicators ───────────────────────────────────── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request.htmx-indicator { display: inline-block; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar-toggle { display: block; }
  .sidebar-collapse-btn { display: none; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 250ms var(--ease);
    z-index: 40;
  }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 20px 16px; padding-top: 56px; }
  .grid, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .main { padding: 16px 12px; padding-top: 56px; }
  .grid, .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
  .topbar { flex-direction: column; gap: 12px; }
  .topbar .btns { width: 100%; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .modal-overlay > .card { min-width: auto; width: 100%; }
}

/* ─── Utilities ──────────────────────────────────────────── */
.mono { font-family: 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.hidden { display: none; }
.inline { display: inline; }
.text-muted { color: var(--text-2); }
.text-sm { font-size: 13px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-0 { gap: 0; }
.flex-end { justify-content: flex-end; }
.w-auto { width: auto; }

/* ─── Dark Mode ──────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --text: #e2e8f0;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --border: #2d3343;
  --border-soft: #232733;

  --primary-hover: color-mix(in srgb, var(--primary) 75%, white);
  --primary-bg: color-mix(in srgb, var(--primary) 15%, #1a1d27);
  --primary-ring: color-mix(in srgb, var(--primary) 25%, transparent);

  --success-bg: color-mix(in srgb, var(--success) 15%, #1a1d27);
  --warning-bg: color-mix(in srgb, var(--warning) 15%, #1a1d27);
  --danger-bg: color-mix(in srgb, var(--danger) 15%, #1a1d27);
  --info-bg: color-mix(in srgb, var(--info) 15%, #1a1d27);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .2);
  --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, .4);

  color-scheme: dark;
}
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] a { color: color-mix(in srgb, var(--primary) 80%, white); }
[data-theme="dark"] a:hover { color: var(--primary); }

/* Dark — forms */
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
[data-theme="dark"] label { color: var(--text-2); }

/* Dark — tables */
[data-theme="dark"] thead tr { background: var(--border-soft); }
[data-theme="dark"] th { color: var(--text-2); border-bottom-color: var(--border); }
[data-theme="dark"] td { border-bottom-color: var(--border-soft); }
[data-theme="dark"] tbody tr:hover { background: var(--border-soft); }

/* Dark — buttons */
[data-theme="dark"] .btn.secondary { background: var(--border-soft); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .btn.secondary:hover { background: var(--border); }

/* Dark — status badges text */
[data-theme="dark"] .status.ok  { color: #34d399; }
[data-theme="dark"] .status.warn { color: #fbbf24; }
[data-theme="dark"] .status.bad  { color: #f87171; }

/* Dark — messages */
[data-theme="dark"] .messages .success { color: #6ee7b7; }
[data-theme="dark"] .messages .error   { color: #fca5a5; }
[data-theme="dark"] .messages .warning { color: #fcd34d; }
[data-theme="dark"] .messages .info    { color: #93c5fd; }

/* Dark — modal */
[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, .7); }

/* Dark — receipt */
[data-theme="dark"] .receipt { background: linear-gradient(180deg, var(--surface), var(--border-soft)); }
[data-theme="dark"] .receipt-field { background: var(--bg); }

/* Dark — upload box */
[data-theme="dark"] .upload-box { background: var(--border-soft); border-color: var(--border); }
[data-theme="dark"] .upload-box:hover { background: var(--primary-bg); }

/* Dark — login */
[data-theme="dark"] .login-page { background: linear-gradient(135deg, #0a1628 0%, #0f1117 40%, #0f1628 100%); }
[data-theme="dark"] .login-error { background: var(--danger-bg); color: #fca5a5; }

/* Dark — config swatches */
[data-theme="dark"] .swatch.active { border-color: #e2e8f0; box-shadow: 0 0 0 2px var(--text-2); }
[data-theme="dark"] .color-dot { border-color: var(--border); }
[data-theme="dark"] .logo-preview { background: var(--border-soft); border-color: var(--border); }

/* Sidebar light nav when in dark mode */
[data-theme="dark"] .sidebar-dark-light { color: #374151; border-right: 1px solid var(--border); }
[data-theme="dark"] .sidebar-dark-light .brand { color: #111827; }
[data-theme="dark"] .sidebar-dark-light .brand-sub { color: #6b7280; }
[data-theme="dark"] .sidebar-dark-light .nav-section { color: #9ca3af; }
[data-theme="dark"] .sidebar-dark-light .nav a { color: #4b5563; }
[data-theme="dark"] .sidebar-dark-light .nav a svg { color: #6b7280; }
[data-theme="dark"] .sidebar-dark-light .nav a:hover { color: #111827; background: rgba(0, 0, 0, .05); }
[data-theme="dark"] .sidebar-dark-light .nav a:hover svg { color: #111827; }
[data-theme="dark"] .sidebar-dark-light .nav a.active { color: var(--primary); background: var(--primary-bg); border-left-color: var(--primary); }
[data-theme="dark"] .sidebar-dark-light .nav a.active svg { color: var(--primary); }
[data-theme="dark"] .sidebar-dark-light .sidebar-footer { border-top-color: rgba(0, 0, 0, .08); }
[data-theme="dark"] .sidebar-dark-light .sidebar-avatar { background: var(--primary-bg); }
[data-theme="dark"] .sidebar-dark-light .sidebar-user-email { color: #4b5563; }
[data-theme="dark"] .sidebar-dark-light .sidebar-logout { color: #9ca3af !important; }
[data-theme="dark"] .sidebar-dark-light .sidebar-logout:hover { color: #111827 !important; }
[data-theme="dark"] .sidebar-dark-light .sidebar-collapse-btn,
[data-theme="dark"] .sidebar-dark-light .theme-toggle { background: rgba(0, 0, 0, .04); border-color: rgba(0, 0, 0, .08); color: #9ca3af; }
[data-theme="dark"] .sidebar-dark-light .sidebar-collapse-btn:hover,
[data-theme="dark"] .sidebar-dark-light .theme-toggle:hover { background: rgba(0, 0, 0, .08); color: #374151; }

/* Also undo sidebar-light when in dark mode if dark nav is NOT light */
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) { color: #e2e8f0; border-right: 0; }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .brand { color: #fff; }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .brand-sub { color: color-mix(in srgb, var(--sidebar-bg) 30%, #94a3b8); }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .nav-section { color: #475569; }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .nav a { color: #94a3b8; }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .nav a svg { color: inherit; }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .nav a:hover { color: #e2e8f0; background: rgba(255, 255, 255, .06); }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .nav a.active { color: #fff; background: color-mix(in srgb, var(--primary) 10%, transparent); border-left-color: var(--primary); }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .nav a.active svg { color: var(--primary); }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .sidebar-footer { border-top-color: rgba(255, 255, 255, .08); }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .sidebar-avatar { background: rgba(255, 255, 255, .08); }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .sidebar-user-email { color: #94a3b8; }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .sidebar-logout { color: #64748b !important; }
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .sidebar-collapse-btn,
[data-theme="dark"] .sidebar-light:not(.sidebar-dark-light) .theme-toggle { background: rgba(255, 255, 255, .04); border-color: rgba(255, 255, 255, .06); color: #64748b; }

/* Dark mode toggle button */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: var(--radius);
  color: #64748b;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all var(--dur) var(--ease);
}
.theme-toggle:hover { background: rgba(255, 255, 255, .1); color: #e2e8f0; }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Light sidebar + dark mode overrides */
.sidebar-light .theme-toggle { background: rgba(0, 0, 0, .04); border-color: rgba(0, 0, 0, .08); color: #9ca3af; }
.sidebar-light .theme-toggle:hover { background: rgba(0, 0, 0, .08); color: #374151; }

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(.96) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
