@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap");
:root {
  /* Colors */
  --color-bg-body: #0f172a;
  --color-bg-surface: #1e293b;
  --color-bg-surface-glass: rgba(30, 41, 59, 0.7);
  --color-bg-surface-alt: #1e293b;
  --color-text-primary: #f8fafc;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;
  --color-primary: #6366f1; /* Indigo 500 */
  --color-primary-hover: #4f46e5; /* Indigo 600 */
  --color-primary-glow: rgba(99, 102, 241, 0.5);
  --color-accent: #8b5cf6; /* Violet 500 */
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  /* Overlays & interactive */
  --color-hover-overlay: rgba(255, 255, 255, 0.05);
  --color-stripe-overlay: rgba(255, 255, 255, 0.02);
  --color-separator: rgba(255, 255, 255, 0.05);
  --color-glass-border: rgba(255, 255, 255, 0.1);
  --color-btn-hover-bg: #334155;
  --color-btn-hover-border: #475569;
  --color-auth-gradient: #1e1b4b;
  /* Borders */
  --border-color: #334155;
  --border-radius-sm: 0.375rem;
  --border-radius-md: 0.5rem;
  --border-radius-lg: 1rem;
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 15px var(--color-primary-glow);
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 300ms ease;
}

/* Light theme overrides */
[data-theme=light] {
  --color-bg-body: #f8fafc;
  --color-bg-surface: #ffffff;
  --color-bg-surface-glass: rgba(255, 255, 255, 0.7);
  --color-bg-surface-alt: #f1f5f9;
  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #94a3b8;
  --color-primary-glow: rgba(99, 102, 241, 0.3);
  --color-hover-overlay: rgba(0, 0, 0, 0.04);
  --color-stripe-overlay: rgba(0, 0, 0, 0.02);
  --color-separator: rgba(0, 0, 0, 0.06);
  --color-glass-border: rgba(0, 0, 0, 0.1);
  --color-btn-hover-bg: #e2e8f0;
  --color-btn-hover-border: #cbd5e1;
  --color-auth-gradient: #e0e7ff;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: "Inter", sans-serif;
  background-color: var(--color-bg-body);
  color: var(--color-text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  color: var(--color-text-primary);
  line-height: 1.2;
}

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background-color: var(--color-bg-surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: var(--space-8);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.sidebar .brand i {
  color: var(--color-accent);
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.sidebar nav a {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--border-radius-md);
  color: var(--color-text-secondary);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: all var(--transition-fast);
}
.sidebar nav a:hover {
  background-color: var(--color-hover-overlay);
  color: var(--color-text-primary);
}
.sidebar nav a.active {
  background-color: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-glow);
}
.sidebar .user-profile {
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-primary);
}
.sidebar .user-profile .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.main-content {
  flex: 1;
  padding: var(--space-8);
  overflow-y: auto;
}

/* Auth Layout */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, var(--color-auth-gradient), var(--color-bg-body));
}

/* Cards */
.card {
  background-color: var(--color-bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--space-6);
}
.card.card-glass {
  background-color: var(--color-bg-surface-glass);
  backdrop-filter: blur(12px);
  border: 1px solid var(--color-glass-border);
}

/* Typography Helpers */
.page-header {
  margin-bottom: var(--space-6);
}
.page-header h1 {
  font-size: 2rem;
  margin-bottom: var(--space-2);
}
.page-header p {
  color: var(--color-text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  background-color: var(--color-bg-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition-fast);
  font-family: inherit;
  font-size: 0.95rem;
}
.btn:hover {
  background-color: var(--color-btn-hover-bg);
  border-color: var(--color-btn-hover-border);
}
.btn.btn-primary {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}
.btn.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: var(--shadow-glow);
}
.btn.btn-danger {
  background-color: transparent;
  border-color: var(--color-danger);
  color: var(--color-danger);
}
.btn.btn-danger:hover {
  background-color: var(--color-danger);
  color: white;
}

/* Forms */
.form-group {
  margin-bottom: var(--space-4);
}
.form-group label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  color: var(--color-text-secondary);
}
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: var(--space-3);
  background-color: var(--color-bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: 1rem;
  transition: all var(--transition-fast);
}
.form-group input[type=text]:focus,
.form-group input[type=email]:focus,
.form-group input[type=password]:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}
.stats-grid .stat-card {
  background: linear-gradient(135deg, var(--color-bg-surface), var(--color-bg-surface-alt));
  padding: var(--space-6);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  display: block;
  color: inherit;
  text-decoration: none;
}
.stats-grid .stat-card h3 {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}
.stats-grid .stat-card .value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-primary);
}
.stats-grid a.stat-card {
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.stats-grid a.stat-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--color-primary-glow);
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  margin-bottom: var(--space-6);
}

.table {
  width: 100%;
  border-collapse: collapse;
  color: var(--color-text-primary);
}
.table th {
  text-align: left;
  padding: var(--space-4);
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--border-color);
}
.table tbody tr {
  transition: background-color var(--transition-fast);
  /* Zebra striping */
}
.table tbody tr:nth-child(even) {
  background-color: var(--color-stripe-overlay);
}
.table tbody tr:hover {
  background-color: var(--color-hover-overlay);
}
.table {
  /* Cell separation */
}
.table td {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-separator);
  border-right: 1px solid var(--color-separator);
  /* Vertical separator */
  vertical-align: middle;
}
.table td:last-child {
  border-right: none;
}

/* Badge helpers for status/types */
.badge {
  display: inline-block;
  padding: 0.25em 0.6em;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: var(--border-radius-sm);
  background-color: var(--color-bg-surface);
  color: var(--color-text-secondary);
  border: 1px solid var(--border-color);
}
.badge.badge-primary {
  background-color: rgba(99, 102, 241, 0.1);
  color: var(--color-primary);
  border-color: rgba(99, 102, 241, 0.2);
}

/* Markdown Body */
.markdown-body {
  font-family: inherit;
  line-height: 1.6;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 600;
  line-height: 1.25;
}
.markdown-body p {
  margin-bottom: 1em;
}
.markdown-body ul,
.markdown-body ol {
  margin-bottom: 1em;
  padding-left: 2em;
}
.markdown-body code {
  padding: 0.2em 0.4em;
  margin: 0;
  font-size: 85%;
  background-color: rgba(175, 184, 193, 0.2);
  border-radius: 6px;
}
.markdown-body pre code {
  display: block;
  padding: 1em;
  overflow-x: auto;
}
.markdown-body blockquote {
  margin: 1em 0;
  padding-left: 1em;
  color: #64748b;
  border-left: 0.25em solid #cbd5e1;
}

/* Reports Tabs */
.reports-tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0;
}
.reports-tabs .reports-tab {
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-muted);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
}
.reports-tabs .reports-tab:hover {
  color: var(--color-text-primary);
}
.reports-tabs .reports-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Chart Container */
.chart-container {
  position: relative;
  height: 300px;
}

/* Date Range Picker */
.date-range-picker {
  margin-bottom: var(--space-6);
}
.date-range-picker .date-range-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.date-range-picker .date-range-presets {
  display: flex;
  gap: var(--space-2);
}
.date-range-picker .date-range-inputs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.date-range-picker .date-range-inputs input[type=date] {
  padding: var(--space-2) var(--space-3);
  background-color: var(--color-bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: 0.875rem;
}
.date-range-picker .date-range-inputs input[type=date]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

/* Reports 2-Column Grid */
.reports-grid-2col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
}
@media (max-width: 900px) {
  .reports-grid-2col {
    grid-template-columns: 1fr;
  }
}

/* Accuracy Badge Variants */
.badge-success {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  border-color: rgba(16, 185, 129, 0.2);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--color-warning);
  border-color: rgba(245, 158, 11, 0.2);
}

.badge-danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Conflict Resolution */
.conflict-card {
  border-left: 4px solid var(--color-warning);
}

.conflict-diff-row .conflict-value-local {
  background: rgba(99, 102, 241, 0.05);
}
.conflict-diff-row .conflict-value-incoming {
  background: rgba(245, 158, 11, 0.05);
}

/* Mobile Phone Preview Frame */
.phone-preview-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.phone-frame {
  width: 320px;
  background: #1a1a1a;
  border-radius: 44px;
  padding: 12px;
  box-shadow: 0 0 0 2px #3a3a3a, 0 20px 60px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  position: relative;
  flex-shrink: 0;
}
.phone-frame::before {
  content: "";
  display: block;
  width: 90px;
  height: 24px;
  background: #1a1a1a;
  border-radius: 0 0 16px 16px;
  margin: 0 auto 4px;
  position: relative;
  z-index: 1;
}
.phone-frame::after {
  content: "";
  display: block;
  width: 100px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin: 8px auto 0;
}

.phone-screen {
  background: #ffffff;
  border-radius: 32px;
  overflow: hidden;
  height: 580px;
  position: relative;
}

.phone-screen-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  color: #1e293b;
  font-size: 14px;
  line-height: 1.5;
}
.phone-screen-scroll * {
  color: inherit;
}
.phone-screen-scroll::-webkit-scrollbar {
  width: 3px;
}
.phone-screen-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

.phone-visual {
  text-align: center;
  margin-bottom: 12px;
}
.phone-visual img {
  max-width: 100%;
  border-radius: 8px;
}

.phone-visual-title {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.phone-question-text {
  font-size: 14px;
  line-height: 1.6;
  color: #1e293b;
  margin-bottom: 20px;
}
.phone-question-text p {
  margin-bottom: 0.75em;
}
.phone-question-text strong {
  font-weight: 600;
}
.phone-question-text em {
  font-style: italic;
}

.phone-divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 16px 0;
}

.phone-answers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.phone-answer-btn {
  width: 100%;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  text-align: left;
  font-size: 13px;
  font-family: inherit;
  color: #1e293b;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: all 150ms ease;
  line-height: 1.4;
}
.phone-answer-btn:hover {
  border-color: #6366f1;
  background: #f5f3ff;
}
.phone-answer-btn.is-correct {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
  color: #065f46;
}
.phone-answer-btn.is-correct .answer-letter {
  background: #10b981;
  color: white;
}
.phone-answer-btn.is-wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.06);
  color: #991b1b;
}
.phone-answer-btn.is-wrong .answer-letter {
  background: #ef4444;
  color: white;
}
.phone-answer-btn.is-disabled {
  cursor: default;
  opacity: 0.75;
}
.phone-answer-btn.is-disabled:hover {
  border-color: inherit;
  background: inherit;
}
.phone-answer-btn .answer-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  background: #e2e8f0;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
}

.phone-rationale {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #166534;
  margin-top: 8px;
}
.phone-rationale[hidden] {
  display: none;
}
.phone-rationale .rationale-label {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  color: #15803d;
}

/* Mobile preview details toggle (show page) */
details.mobile-preview-details {
  margin-top: var(--space-6);
}
details.mobile-preview-details summary {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
}
details.mobile-preview-details summary::-webkit-details-marker {
  display: none;
}

/* Markdown Visual Content */
.visual-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
  font-size: 0.875rem;
}
.visual-markdown th, .visual-markdown td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  text-align: left;
}
.visual-markdown th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
}
.visual-markdown tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}
.visual-markdown p {
  margin: 0.5rem 0;
}
.visual-markdown img {
  max-width: 100%;
  border-radius: var(--border-radius-sm);
}

/* Spacing */
.mb-1 {
  margin-bottom: var(--space-2);
}

.mb-2 {
  margin-bottom: var(--space-4);
}

.mb-3 {
  margin-bottom: var(--space-6);
}

.mb-4 {
  margin-bottom: var(--space-8);
}

.mt-1 {
  margin-top: var(--space-2);
}

.mt-2 {
  margin-top: var(--space-4);
}

.mt-3 {
  margin-top: var(--space-6);
}

.mt-4 {
  margin-top: var(--space-8);
}

.gap-1 {
  gap: var(--space-2);
}

.gap-2 {
  gap: var(--space-4);
}

/* Flexbox */
.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.flex-column {
  flex-direction: column;
}

/* Text */
.text-center {
  text-align: center;
}

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

.text-danger {
  color: var(--color-danger);
}

.fw-bold {
  font-weight: 700;
}

/* Alerts */
.alert {
  padding: var(--space-4);
  border-radius: var(--border-radius-md);
  margin-bottom: var(--space-4);
}
.alert.alert-error {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}
.alert.alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  border: 1px solid var(--color-success);
}
