/* ═══════════════════════════════════════════════════════════
   Ariba Track – Premium Design System
   ═══════════════════════════════════════════════════════════ */

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

  --accent-400: #a78bfa;
  --accent-500: #8b5cf6;
  --accent-600: #7c3aed;

  --success-400: #4ade80;
  --success-500: #22c55e;
  --success-600: #16a34a;

  --warning-400: #fbbf24;
  --warning-500: #f59e0b;
  --warning-600: #d97706;

  --danger-400: #f87171;
  --danger-500: #ef4444;
  --danger-600: #dc2626;

  --info-400: #38bdf8;
  --info-500: #0ea5e9;
  --info-600: #0284c7;

  /* Dark theme colors */
  --bg-base:       #0b0d14;
  --bg-surface:    #111318;
  --bg-elevated:   #181b23;
  --bg-hover:      #1f2330;
  --bg-active:     #262b3a;

  --border-subtle: #1e2231;
  --border-default:#2a2f3f;
  --border-strong: #3a3f52;

  --text-primary:   #f1f3f9;
  --text-secondary: #9ca3b8;
  --text-muted:     #6b7280;
  --text-inverse:   #0b0d14;

  /* Sizing */
  --sidebar-width: 260px;
  --header-height: 64px;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.4);
  --shadow-xl:  0 16px 48px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(99,102,241,0.15);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-base: 250ms var(--ease-out);
  --transition-slow: 400ms var(--ease-out);
}

/* ─── Light Theme ────────────────────────────────────────── */
[data-theme="light"] {
  --bg-base:       #f0f2f8;
  --bg-surface:    #ffffff;
  --bg-elevated:   #f5f7fc;
  --bg-hover:      #eaecf4;
  --bg-active:     #dde1f0;

  --border-subtle: #dde1ee;
  --border-default:#c8cedd;
  --border-strong: #a9b2cc;

  --text-primary:   #111827;
  --text-secondary: #4b5563;
  --text-muted:     #9ca3af;
  --text-inverse:   #ffffff;

  --shadow-sm:  0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.10);
  --shadow-xl:  0 16px 48px rgba(0,0,0,0.14);
  --shadow-glow: 0 0 20px rgba(99,102,241,0.10);
}

/* ─── Mixed Theme ────────────────────────────────────────── */
[data-theme="mixed"] .sidebar {
  --bg-base:       #0b0d14;
  --bg-surface:    #111318;
  --bg-elevated:   #181b23;
  --bg-hover:      #1f2330;
  --bg-active:     #262b3a;
  --border-subtle: #1e2231;
  --border-default:#2a2f3f;
  --border-strong: #3a3f52;
  --text-primary:   #f1f3f9;
  --text-secondary: #9ca3b8;
  --text-muted:     #6b7280;
  background: var(--bg-surface);
  border-right-color: var(--border-subtle);
}

[data-theme="mixed"] .main-content {
  --bg-base:       #f0f2f8;
  --bg-surface:    #ffffff;
  --bg-elevated:   #f5f7fc;
  --bg-hover:      #eaecf4;
  --bg-active:     #dde1f0;
  --border-subtle: #dde1ee;
  --border-default:#c8cedd;
  --border-strong: #a9b2cc;
  --text-primary:   #111827;
  --text-secondary: #4b5563;
  --text-muted:     #9ca3af;
  --text-inverse:   #ffffff;
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.10);
  --shadow-xl:  0 16px 48px rgba(0,0,0,0.14);
  color: #111827;
  background: #f0f2f8;
}


[data-theme="mixed"] body {
  background: #f0f2f8;
}

/* Modal también usa variables light en modo mixto */
[data-theme="mixed"] .modal-overlay .modal {
  --bg-surface:    #ffffff;
  --bg-elevated:   #f5f7fc;
  --bg-hover:      #eaecf4;
  --bg-active:     #dde1f0;
  --border-subtle: #dde1ee;
  --border-default:#c8cedd;
  --border-strong: #a9b2cc;
  --text-primary:   #111827;
  --text-secondary: #4b5563;
  --text-muted:     #9ca3af;
  --shadow-xl:  0 16px 48px rgba(0,0,0,0.14);
  background: var(--bg-surface);
  color: #111827;
}

/* ─── Reset ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* ─── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* ─── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-base);
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon svg {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 2px 8px rgba(99,102,241,0.3));
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-400), var(--accent-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.08));
  color: var(--primary-400);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: linear-gradient(180deg, var(--primary-400), var(--accent-500));
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 8px 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-footer .sync-status {
  padding: 8px 16px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
  padding-top: 12px;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition-fast);
}

.sync-dot.syncing {
  background: var(--warning-400);
  animation: pulse-dot 1.5s infinite;
}

.sync-dot.synced {
  background: var(--success-400);
}

.sync-dot.error {
  background: var(--danger-400);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

/* ─── Mobile Header ───────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 16px;
  align-items: center;
  gap: 12px;
  z-index: 90;
  backdrop-filter: blur(12px);
}

.menu-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.menu-toggle:hover {
  background: var(--bg-hover);
}

.menu-toggle svg {
  width: 22px;
  height: 22px;
}

.mobile-title {
  font-size: 1.125rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-400), var(--accent-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Main Content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px 40px;
  min-height: 100vh;
}

/* ─── View System ─────────────────────────────────────────── */
.view {
  display: none;
  animation: fadeIn 0.3s var(--ease-out);
}

.view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}

.view-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.view-subtitle {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin-top: 4px;
}

.view-actions {
  display: flex;
  gap: 8px;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  color: white;
  box-shadow: 0 2px 12px rgba(99,102,241,0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: var(--danger-400);
}

.btn-danger:hover {
  background: rgba(239,68,68,0.2);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.btn-sync.syncing .spin-on-sync {
  animation: spin 1s linear infinite;
}

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

/* ─── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.stat-clickable {
  cursor: pointer;
  user-select: none;
}

.stat-clickable:active {
  transform: translateY(0) scale(0.98);
}

.stat-card:hover {
  border-color: var(--border-default);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card:hover::after {
  opacity: 1;
}

.stat-total::after   { background: linear-gradient(90deg, var(--primary-400), var(--accent-400)); }
.stat-open::after    { background: linear-gradient(90deg, var(--info-400), var(--primary-400)); }
.stat-urgent::after  { background: linear-gradient(90deg, var(--danger-400), var(--warning-400)); }
.stat-pending::after { background: linear-gradient(90deg, var(--warning-400), var(--warning-500)); }
.stat-progress::after{ background: linear-gradient(90deg, var(--info-400), var(--info-500)); }
.stat-submitted::after{ background: linear-gradient(90deg, var(--success-400), var(--success-500)); }

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-total .stat-icon   { background: rgba(99,102,241,0.12);  color: var(--primary-400); }
.stat-open .stat-icon     { background: rgba(56,189,248,0.12);  color: var(--info-400); }
.stat-urgent .stat-icon   { background: rgba(248,113,113,0.12); color: var(--danger-400); }
.stat-pending .stat-icon  { background: rgba(251,191,36,0.12);  color: var(--warning-400); }
.stat-progress .stat-icon { background: rgba(56,189,248,0.12);  color: var(--info-400); }
.stat-submitted .stat-icon{ background: rgba(74,222,128,0.12);  color: var(--success-400); }

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ─── Section Header ──────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.link-all {
  color: var(--primary-400);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.link-all:hover {
  color: var(--primary-300);
}

/* ─── Events List (Dashboard) ─────────────────────────────── */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.event-card:hover {
  border-color: var(--border-default);
  background: var(--bg-elevated);
  transform: translateX(4px);
}

.event-card-priority {
  width: 4px;
  height: 40px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.event-card-priority.normal  { background: var(--border-default); }
.event-card-priority.high    { background: var(--warning-400); }
.event-card-priority.urgent  { background: var(--danger-400); }

.event-card-content {
  flex: 1;
  min-width: 0;
}

.event-card-title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.event-card-meta svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.event-card-status {
  flex-shrink: 0;
}

/* ─── Status Badges ───────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  text-transform: capitalize;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-not_started  { background: rgba(251,191,36,0.12);  color: var(--warning-400); }
.badge-not_started .badge-dot { background: var(--warning-400); }

.badge-in_progress  { background: rgba(56,189,248,0.12);  color: var(--info-400); }
.badge-in_progress .badge-dot { background: var(--info-400); }

.badge-submitted    { background: rgba(74,222,128,0.12);  color: var(--success-400); }
.badge-submitted .badge-dot { background: var(--success-400); }

.badge-won          { background: rgba(74,222,128,0.12);  color: var(--success-400); }
.badge-won .badge-dot { background: var(--success-400); }

.badge-lost         { background: rgba(248,113,113,0.12); color: var(--danger-400); }
.badge-lost .badge-dot { background: var(--danger-400); }

.badge-skipped      { background: rgba(107,114,128,0.12); color: var(--text-muted); }
.badge-skipped .badge-dot { background: var(--text-muted); }

.badge-open         { background: rgba(56,189,248,0.12);  color: var(--info-400); }
.badge-open .badge-dot { background: var(--info-400); }

.badge-closed       { background: rgba(107,114,128,0.12); color: var(--text-muted); }
.badge-closed .badge-dot { background: var(--text-muted); }

/* ─── Filters Bar ─────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 42px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: all var(--transition-fast);
}

.search-input:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.chip.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.1));
  border-color: var(--primary-500);
  color: var(--primary-400);
}

/* ─── Events Table ────────────────────────────────────────── */
.events-table-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.events-table {
  width: 100%;
  border-collapse: collapse;
}

.events-table thead {
  background: var(--bg-elevated);
}

.events-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.events-table th:hover {
  color: var(--text-secondary);
}

.events-table th.sort-active {
  color: var(--accent);
}

.events-table th .sort-icon {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
  font-size: 0.7rem;
}

.events-table th.sort-active .sort-icon {
  opacity: 1;
}

.events-table td {
  padding: 14px 16px;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.events-table tbody tr {
  transition: background var(--transition-fast);
  cursor: pointer;
}

.events-table tbody tr:hover {
  background: var(--bg-hover);
}

.events-table tbody tr:last-child td {
  border-bottom: none;
}

.td-title {
  font-weight: 600;
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-buyer {
  color: var(--text-secondary);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.td-date {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.td-date.overdue {
  color: var(--danger-400);
  font-weight: 600;
}

.td-date.soon {
  color: var(--warning-400);
  font-weight: 600;
}

.td-actions {
  display: flex;
  gap: 4px;
}

.td-actions .btn-sm {
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.events-table tbody tr:hover .td-actions .btn-sm {
  opacity: 1;
}

/* Status select in table */
.status-select {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.8125rem;
  outline: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.status-select:focus {
  border-color: var(--primary-500);
}

/* ─── Empty State ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state.small {
  padding: 30px 20px;
}

.empty-icon {
  width: 56px;
  height: 56px;
  color: var(--text-muted);
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.empty-state span {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ─── Settings ────────────────────────────────────────────── */
.settings-section {
  margin-bottom: 24px;
}

.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.settings-card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-card-icon {
  width: 24px;
  height: 24px;
  color: var(--primary-400);
  flex-shrink: 0;
  margin-top: 2px;
}

.settings-card-header h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.settings-card-header p {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ─── Theme Toggle ────────────────────────────────────────── */
.theme-options {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
}

.theme-option {
  flex: 1;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  background: var(--bg-elevated);
  transition: border-color var(--transition-fast), background var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.theme-option:hover {
  border-color: var(--border-strong);
}

.theme-option.active {
  border-color: var(--accent);
  background: var(--bg-active);
}

.theme-preview {
  width: 100%;
  height: 60px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  display: flex;
}

.theme-preview-sidebar {
  width: 28%;
  height: 100%;
}

.theme-preview-content {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
}

.theme-preview-bar {
  border-radius: 3px;
  height: 8px;
}

.theme-preview-bar:last-child {
  width: 60%;
}

/* Dark preview colors */
.theme-preview-dark .theme-preview-sidebar { background: #111318; }
.theme-preview-dark .theme-preview-content { background: #0b0d14; }
.theme-preview-dark .theme-preview-bar { background: #1f2330; }

/* Light preview colors */
.theme-preview-light .theme-preview-sidebar { background: #ffffff; }
.theme-preview-light .theme-preview-content { background: #f0f2f8; }
.theme-preview-light .theme-preview-bar { background: #dde1ee; }

/* Mixed preview colors */
.theme-preview-mixed .theme-preview-sidebar { background: #111318; }
.theme-preview-mixed .theme-preview-content { background: #f0f2f8; }
.theme-preview-mixed .theme-preview-bar { background: #dde1ee; }

.theme-option-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.theme-option-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.theme-option.active .theme-option-check {
  border-color: var(--accent);
  background: var(--accent);
}

.settings-form {
  padding: 24px;
}

.form-group {
  margin-bottom: 18px;
}

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

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.password-input-wrapper {
  position: relative;
}

.password-input-wrapper input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.password-toggle:hover {
  color: var(--text-primary);
}

.password-toggle .eye-icon {
  width: 18px;
  height: 18px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

/* Saved credentials list */
.saved-credentials {
  padding: 0 24px 24px;
}

.credential-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.credential-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.credential-info .cred-icon {
  width: 36px;
  height: 36px;
  background: rgba(99,102,241,0.12);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-400);
}

.credential-info .cred-icon svg {
  width: 18px;
  height: 18px;
}

.cred-username {
  font-weight: 600;
  font-size: 0.9375rem;
}

.cred-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.cred-active {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--success-400);
  background: rgba(74,222,128,0.12);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-left: 8px;
}

/* Sync history */
.sync-history {
  padding: 16px 24px;
}

.sync-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.875rem;
}

.sync-history-item:last-child {
  border-bottom: none;
}

.sync-history-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sync-history-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.sync-history-status .dot.completed { background: var(--success-400); }
.sync-history-status .dot.failed    { background: var(--danger-400); }
.sync-history-status .dot.started   { background: var(--warning-400); }

.sync-history-stats {
  color: var(--text-secondary);
  font-size: 0.8125rem;
}

.sync-history-date {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

/* ─── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  align-items: flex-start;
  animation: fadeIn 0.2s var(--ease-out);
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 80%;
  min-width: 1000px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s var(--ease-spring);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

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

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Modal Tabs ─────────────────────────────────────────── */
.modal-tabs {
  display: flex;
  gap: 2px;
  padding: 12px 24px 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.modal-tab {
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: -1px;
}

.modal-tab:hover { color: var(--text-primary); }

.modal-tab.active {
  color: var(--primary-400);
  border-bottom-color: var(--primary-400);
}

.tab-badge {
  background: var(--primary-400);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  line-height: 1.4;
}

.modal-tab-panel {
  display: none;
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-tab-panel.active { display: block; }

/* Modal detail fields */
.detail-grid {
  display: grid;
  gap: 16px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.detail-value {
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.detail-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-separator {
  height: 1px;
  background: var(--border-subtle);
  margin: 8px 0;
}

.detail-notes textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: all var(--transition-fast);
}

.detail-notes textarea:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

/* ─── Toast ───────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 420px;
  animation: toastIn 0.4s var(--ease-spring);
  font-size: 0.875rem;
}

.toast.removing {
  animation: toastOut 0.3s var(--ease-out) forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(20px); }
}

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast-success { border-left: 3px solid var(--success-400); }
.toast-success .toast-icon { color: var(--success-400); }

.toast-error { border-left: 3px solid var(--danger-400); }
.toast-error .toast-icon { color: var(--danger-400); }

.toast-info { border-left: 3px solid var(--info-400); }
.toast-info .toast-icon { color: var(--info-400); }

.toast-warning { border-left: 3px solid var(--warning-400); }
.toast-warning .toast-icon { color: var(--warning-400); }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: 80px 16px 32px;
  }

  .view-header {
    flex-direction: column;
    gap: 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    max-width: none;
  }

  .filter-chips {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .detail-row {
    grid-template-columns: 1fr;
  }

  /* Show actions always on mobile */
  .td-actions .btn-sm {
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ─── Overlay for mobile sidebar ──────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  display: none;
}

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

/* ─── Event Detail – structured sections ──────────────────── */
.detail-info-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 16px 20px;
}

.detail-section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary-500, #6366f1);
  margin: 0 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.detail-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0;
}

.detail-value.mono {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.8125rem;
}

/* Items table */
.detail-items-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.detail-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.detail-items-table thead tr {
  background: var(--bg-hover);
}

.detail-items-table th {
  text-align: left;
  padding: 8px 12px;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-subtle);
}

.detail-items-table td {
  padding: 8px 12px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

.detail-items-table tbody tr:last-child td {
  border-bottom: none;
}

.detail-items-table tbody tr:hover {
  background: var(--bg-active);
}

.items-num   { white-space: nowrap; font-weight: 600; color: var(--text-secondary); width: 36px; }
.items-desc  { min-width: 200px; }
.items-qty   { white-space: nowrap; text-align: right; }
.items-unit  { white-space: nowrap; color: var(--text-secondary); }
.items-price { white-space: nowrap; text-align: right; }
.items-notes { font-size: 0.75rem; color: var(--text-muted); }
.items-matcode {
  display: block;
  font-family: monospace;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

/* ─── Login Overlay ───────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.login-overlay.visible {
  opacity: 1;
  pointer-events: all;
}
.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.login-logo svg {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.login-logo span {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}
.login-title {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.25rem;
}
.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 1.75rem;
}
.login-field {
  margin-bottom: 1rem;
}
.login-field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}
.login-field input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.login-field input:focus {
  border-color: var(--accent);
}
.login-error {
  min-height: 1.25rem;
  font-size: 0.8125rem;
  color: #ef4444;
  margin-bottom: 0.75rem;
}
.login-btn {
  width: 100%;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  font-size: 0.9375rem;
  margin-top: 0.25rem;
}
.login-spinner {
  width: 16px;
  height: 16px;
  animation: spin 0.8s linear infinite;
}
.hidden { display: none !important; }

/* ─── Sidebar user / logout ──────────────────────────────── */
.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}
.sidebar-user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-logout {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.btn-logout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}
.btn-logout svg {
  width: 16px;
  height: 16px;
}
