/* ============================================
   LOCKIN — Design System
   Dark-first. Charcoal/black surfaces. Purple accent.
   ============================================ */

:root {
  /* Surfaces */
  --bg-base: #0a0c10;
  --bg-surface: #0f1115;
  --bg-elevated: #161922;
  --bg-raised: #1e2230;
  --bg-input: #0d1017;
  --bg-hover: #242938;

  /* Borders */
  --border-subtle: #1f2330;
  --border-default: #2a2f3e;
  --border-strong: #3a4156;

  /* Text */
  --text-primary: #e5e7eb;
  --text-secondary: #b4b8c3;
  --text-muted: #7a8194;
  --text-faint: #525866;

  /* Accent (purple) */
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-active: #7c3aed;
  --accent-soft: rgba(139, 92, 246, 0.12);
  --accent-border: rgba(139, 92, 246, 0.35);

  /* Semantic */
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.12);

  /* Priority colors */
  --priority-critical: #f87171;
  --priority-high: #fbbf24;
  --priority-medium: #60a5fa;
  --priority-low: #34d399;

  /* Status colors */
  --status-not-started: #7a8194;
  --status-in-progress: #60a5fa;
  --status-paused: #fbbf24;
  --status-completed: #34d399;
  --status-cancelled: #f87171;

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radii */
  --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.4);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 0 1px rgba(139, 92, 246, 0.2), 0 8px 24px rgba(139, 92, 246, 0.15);

  /* Transitions */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);

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

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(139, 92, 246, 0.06), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(96, 165, 250, 0.04), transparent 60%),
    var(--bg-base);
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ============================================
   APP LAYOUT
   ============================================ */
.app {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-slow);
  z-index: 50;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-active));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  color: white;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
}

.brand-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
  color: var(--text-primary);
}

.brand-tagline {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.sidebar-close {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
}
.sidebar-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.nav {
  flex: 1;
  padding: var(--space-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13.5px;
  transition: all var(--transition-fast);
  position: relative;
  border: 1px solid transparent;
}

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

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-color: var(--accent-border);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: var(--radius-full);
}

.nav-item svg { flex-shrink: 0; opacity: 0.85; }

.nav-item-ai .nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--bg-raised);
  color: var(--text-muted);
  border: 1px solid var(--border-default);
}
.nav-item-ai .nav-badge.on {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.3);
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.sidebar-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-faint);
}
.sidebar-stat-value {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

/* ============================================
   MAIN
   ============================================ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

.topbar {
  height: var(--topbar-height);
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 30;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
}
.menu-toggle:hover { background: var(--bg-elevated); color: var(--text-primary); }

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-actions {
  display: flex;
  gap: var(--space-2);
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  scroll-behavior: smooth;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--bg-raised);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 13.5px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-active));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent));
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-default);
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-strong); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.3);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.18); }

.btn-success {
  background: var(--success-soft);
  color: var(--success);
  border-color: rgba(52, 211, 153, 0.3);
}
.btn-success:hover { background: rgba(52, 211, 153, 0.18); }

.btn-sm { padding: var(--space-2) var(--space-3); font-size: 12.5px; }
.btn-lg { padding: var(--space-4) var(--space-6); font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { padding: var(--space-2); }

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-default); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================
   STATS / KPI CARDS
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}
.stat-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}
.stat-card:hover::before { opacity: 1; }

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.stat-delta {
  font-size: 11.5px;
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-delta.positive { color: var(--success); }
.stat-delta.negative { color: var(--danger); }
.stat-delta.neutral { color: var(--text-muted); }

.stat-icon {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
  margin-bottom: var(--space-4);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-3);
  color: var(--text-primary);
  font-size: 13.5px;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg-surface);
}

.form-control::placeholder { color: var(--text-faint); }

textarea.form-control {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

select.form-control {
  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='%237a8194' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
  cursor: pointer;
}

.form-help {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: var(--space-2);
}

.form-error {
  font-size: 11.5px;
  color: var(--danger);
  margin-top: var(--space-2);
}

.form-control.error { border-color: var(--danger); }

/* Checkbox & radio */
.checkbox, .radio {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}
.checkbox input, .radio input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ============================================
   TABLES
   ============================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: var(--bg-surface);
}

th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: var(--bg-elevated); }
tbody tr:last-child td { border-bottom: none; }

td.amount, th.amount { font-family: var(--font-mono); text-align: right; font-weight: 500; }
td.amount.positive { color: var(--success); }
td.amount.negative { color: var(--danger); }

/* ============================================
   BADGES & PILLS
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-raised);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  white-space: nowrap;
}

.badge-success { background: var(--success-soft); color: var(--success); border-color: rgba(52, 211, 153, 0.25); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(251, 191, 36, 0.25); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(248, 113, 113, 0.25); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: rgba(96, 165, 250, 0.25); }
.badge-accent { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent-border); }

.badge-priority-critical { background: rgba(248, 113, 113, 0.14); color: var(--priority-critical); }
.badge-priority-high { background: rgba(251, 191, 36, 0.14); color: var(--priority-high); }
.badge-priority-medium { background: rgba(96, 165, 250, 0.14); color: var(--priority-medium); }
.badge-priority-low { background: rgba(52, 211, 153, 0.14); color: var(--priority-low); }

/* ============================================
   PROGRESS BARS
   ============================================ */
.progress {
  height: 6px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
  position: relative;
}
.progress-bar.success { background: linear-gradient(90deg, var(--success), #6ee7b7); }
.progress-bar.warning { background: linear-gradient(90deg, var(--warning), #fcd34d); }
.progress-bar.danger { background: linear-gradient(90deg, var(--danger), #fca5a5); }

.progress-lg { height: 10px; }
.progress-sm { height: 4px; }

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-family: var(--font-mono);
}

/* ============================================
   SECTION HEADERS
   ============================================ */
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.section-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ============================================
   GRID UTILITIES
   ============================================ */
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-auto-lg { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; min-width: 0; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent-hover); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }
.text-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
}
.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}
.empty-state-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 360px;
  margin: 0 auto var(--space-4);
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-4);
}
.modal-overlay.active { display: flex; animation: fadeIn var(--transition); }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn var(--transition-slow);
}
.modal.modal-lg { max-width: 800px; }
.modal.modal-xl { max-width: 1100px; }
.modal.modal-sm { max-width: 420px; }

.modal-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 360px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-left-width: 3px;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  box-shadow: var(--shadow-md);
  animation: toastIn var(--transition-slow);
  font-size: 13px;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.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-content { flex: 1; }
.toast-title { font-weight: 600; color: var(--text-primary); }
.toast-message { color: var(--text-secondary); font-size: 12.5px; margin-top: 2px; }

.toast.removing { animation: toastOut var(--transition) forwards; }

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

/* ============================================
   LISTS
   ============================================ */
.list { display: flex; flex-direction: column; gap: var(--space-2); }
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}
.list-item:hover { background: var(--bg-elevated); border-color: var(--border-default); }

/* ============================================
   TABS
   ============================================ */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-5);
}
.tab {
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-hover); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn var(--transition); }

/* ============================================
   INPUT GROUPS / SEARCH
   ============================================ */
.search-bar {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-bar svg {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
}
.search-bar input {
  width: 100%;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-8);
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  transition: all var(--transition-fast);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .form-control { border-radius: 0; }
.input-group .form-control:first-child { border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md); }
.input-group-addon {
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-left: none;
  color: var(--text-muted);
  font-size: 13px;
  font-family: var(--font-mono);
}
.input-group-addon:first-child { border-left: 1px solid var(--border-default); border-right: none; border-top-left-radius: var(--radius-md); border-bottom-left-radius: var(--radius-md); }
.input-group .form-control:last-child { border-top-right-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }
.input-group-addon:last-child { border-top-right-radius: var(--radius-md); border-bottom-right-radius: var(--radius-md); }

/* ============================================
   MILESTONE LISTS
   ============================================ */
.milestone-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.milestone {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
}
.milestone:hover { border-color: var(--border-default); }
.milestone.completed { border-color: rgba(52, 211, 153, 0.25); background: var(--success-soft); }

.milestone-check {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  transition: all var(--transition-fast);
}
.milestone-check:hover { border-color: var(--accent); }
.milestone.completed .milestone-check {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.milestone-content { flex: 1; min-width: 0; }
.milestone-title { font-size: 13.5px; font-weight: 500; color: var(--text-primary); }
.milestone.completed .milestone-title { text-decoration: line-through; color: var(--text-muted); }
.milestone-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* ============================================
   AI ADVISOR
   ============================================ */
.ai-notice {
  background: var(--info-soft);
  border: 1px solid rgba(96, 165, 250, 0.25);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.ai-notice-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--info-soft);
  color: var(--info);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-plan {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ai-plan-section {
  padding: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}
.ai-plan-section:last-child { border-bottom: none; }
.ai-plan-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--accent-hover);
  margin-bottom: var(--space-3);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.ai-plan-section p { color: var(--text-secondary); font-size: 13.5px; line-height: 1.7; }
.ai-plan-section ul { margin-left: var(--space-5); color: var(--text-secondary); font-size: 13.5px; }
.ai-plan-section li { margin-bottom: var(--space-2); line-height: 1.6; }
.ai-plan-section ol { margin-left: var(--space-5); color: var(--text-secondary); font-size: 13.5px; }
.ai-plan-section ol li { margin-bottom: var(--space-2); }

.disclaimer {
  font-size: 11.5px;
  color: var(--text-muted);
  padding: var(--space-3);
  background: var(--warning-soft);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: var(--radius-md);
  margin-top: var(--space-4);
}

/* ============================================
   LOADING / SPINNER
   ============================================ */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-lg { width: 28px; height: 28px; border-width: 3px; }

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

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 21, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-3);
  z-index: 10;
  border-radius: inherit;
}

/* ============================================
   TIMELINE
   ============================================ */
.timeline {
  position: relative;
  padding-left: var(--space-6);
}
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--border-default);
}
.timeline-item {
  position: relative;
  padding-bottom: var(--space-5);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -22px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-base);
  box-shadow: 0 0 0 1px var(--accent-border);
}
.timeline-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.timeline-date {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-2);
}

/* ============================================
   CHART CONTAINERS
   ============================================ */
.chart-container {
  position: relative;
  height: 240px;
}
.chart-container.chart-sm { height: 180px; }
.chart-container.chart-lg { height: 320px; }
.chart-container canvas { max-width: 100%; }

/* ============================================
   DIVIDER & MISC
   ============================================ */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-4) 0;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-secondary);
}

.clickable { cursor: pointer; }

/* ============================================
   OVERLAY (mobile sidebar)
   ============================================ */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
  backdrop-filter: blur(2px);
}
.overlay.active { display: block; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .menu-toggle { display: flex; }
  .content { padding: var(--space-4); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .section-header { flex-direction: column; align-items: stretch; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-3); }
  .stat-value { font-size: 22px; }
  .topbar { padding: 0 var(--space-4); }
  .topbar-actions .btn span { display: none; }
  .modal { max-width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 18px; }
  .section-title { font-size: 18px; }
}

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

/* Selection */
::selection { background: var(--accent-soft); color: var(--accent-hover); }

/* Focus visible */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Hidden helper */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
