/* ── Fonts ───────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=DM+Mono:wght@400;500&display=swap');

/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0d0f12;
  --bg2:         #13161b;
  --bg3:         #1a1e26;
  --border:      #252a35;
  --border2:     #2e3545;
  --text:        #e8eaf0;
  --text2:       #8b92a8;
  --text3:       #555e76;
  --accent:      #3d7fff;
  --accent-dim:  #1c3a7a;
  --accent-glow: rgba(61,127,255,.18);
  --success:     #22c55e;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --radius:      10px;
  --radius-lg:   16px;
  --font:        'DM Sans', sans-serif;
  --mono:        'DM Mono', monospace;
  --shadow:      0 4px 24px rgba(0,0,0,.45);
  --transition:  .18s cubic-bezier(.4,0,.2,1);
}

/* ── Light theme ───────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:          #f4f5f7;
  --bg2:         #ffffff;
  --bg3:         #ebedf0;
  --border:      #d1d5db;
  --border2:     #bbc0ca;
  --text:        #1a1d23;
  --text2:       #4b5563;
  --text3:       #9ca3af;
  --accent:      #2563eb;
  --accent-dim:  #bfdbfe;
  --accent-glow: rgba(37,99,235,.12);
  --success:     #16a34a;
  --warning:     #d97706;
  --danger:      #dc2626;
  --shadow:      0 4px 24px rgba(0,0,0,.08);
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ── Layout helpers ─────────────────────────────────────────────────────────── */
.container { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 16px; }
.gap-2 { gap: 8px; }
.w-full { width: 100%; }
.mt-auto { margin-top: auto; }

/* ── Card ────────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

/* ── Form elements ──────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-label { font-size: .82rem; font-weight: 500; color: var(--text2); letter-spacing: .04em; text-transform: uppercase; }
.form-input {
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  padding: 11px 14px;
  font-size: .95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder { color: var(--text3); }
.form-input.error { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .8rem; margin-top: 2px; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius);
  font-size: .92rem; font-weight: 500;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #2d6fe8; box-shadow: 0 0 20px var(--accent-glow); }
.btn-primary:disabled { background: var(--accent-dim); color: var(--text3); cursor: not-allowed; }
.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c73434; }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg3); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-xs { padding: 4px 10px; font-size: .78rem; }
.btn-full { width: 100%; }
.btn-loading { opacity: .7; pointer-events: none; }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 99px;
  font-size: .75rem; font-weight: 500; letter-spacing: .02em;
}
.badge-success { background: rgba(34,197,94,.12); color: var(--success); border: 1px solid rgba(34,197,94,.2); }
.badge-warning { background: rgba(245,158,11,.12); color: var(--warning); border: 1px solid rgba(245,158,11,.2); }
.badge-danger  { background: rgba(239,68,68,.12);  color: var(--danger);  border: 1px solid rgba(239,68,68,.2); }
.badge-muted   { background: var(--bg3); color: var(--text3); border: 1px solid var(--border); }

/* ── Toast notifications ─────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: .88rem;
  min-width: 260px; max-width: 380px;
  box-shadow: var(--shadow);
  animation: slideIn .22s ease;
  display: flex; align-items: flex-start; gap: 10px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slideIn { from { transform: translateX(30px); opacity:0; } to { transform: none; opacity:1; } }

/* ── Navigation ──────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex; align-items: center;
  position: sticky; top: 0; z-index: 100;
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.nav-brand { font-weight: 600; font-size: 1.05rem; color: var(--text); letter-spacing: -.01em; }
.nav-brand span { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link {
  padding: 7px 14px; border-radius: 8px;
  color: var(--text2); font-size: .88rem; font-weight: 500;
  transition: all var(--transition);
}
.nav-link:hover, .nav-link.active { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-link.active { color: var(--accent); }

/* ── Tables ──────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  background: var(--bg3);
  color: var(--text2);
  font-weight: 500; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase;
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg3); }

/* ── Search & filter bar ─────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search-input {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius); color: var(--text);
  padding: 9px 14px; font-size: .88rem; outline: none;
  min-width: 220px; transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--accent); }
.select-filter {
  background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius); color: var(--text);
  padding: 9px 12px; font-size: .88rem; outline: none;
  cursor: pointer;
}

/* ── Page sections ───────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 4px; }
.page-subtitle { color: var(--text2); font-size: .92rem; }
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: 14px; color: var(--text); }

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text3); }
.empty-state svg { margin-bottom: 14px; opacity: .4; }

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth pages ──────────────────────────────────────────────────────────────── */
.auth-wrapper {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 16px;
  background: radial-gradient(ellipse at 60% 20%, rgba(61,127,255,.07) 0%, transparent 60%);
}
.auth-card { width: 100%; max-width: 440px; }
.auth-logo { font-size: 1.3rem; font-weight: 700; margin-bottom: 32px; color: var(--text); }
.auth-logo span { color: var(--accent); }
.auth-title { font-size: 1.6rem; font-weight: 600; margin-bottom: 6px; }
.auth-subtitle { color: var(--text2); font-size: .92rem; margin-bottom: 28px; }
.auth-footer { margin-top: 20px; text-align: center; color: var(--text2); font-size: .88rem; }

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; background: var(--bg3); border-radius: var(--radius); padding: 4px; margin-bottom: 24px; }
.tab-btn {
  flex: 1; padding: 8px 16px;
  border: none; background: transparent;
  color: var(--text2); font-size: .88rem; font-weight: 500;
  border-radius: 8px; transition: all var(--transition);
}
.tab-btn.active { background: var(--bg2); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Upload zone ─────────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
}
.upload-zone input[type=file] { display: none; }
.upload-label { color: var(--text2); font-size: .9rem; margin-top: 10px; }
.upload-label strong { color: var(--accent); cursor: pointer; }

/* ── Light theme overrides (main) ──────────────────────────────────────────── */
[data-theme="light"] .auth-wrapper { background: radial-gradient(ellipse at 60% 20%, rgba(37,99,235,.06) 0%, transparent 60%); }
[data-theme="light"] .toast { box-shadow: 0 4px 16px rgba(0,0,0,.08); }
[data-theme="light"] .tab-btn.active { box-shadow: 0 1px 4px rgba(0,0,0,.1); }

/* ── Theme toggle ──────────────────────────────────────────────────────────── */
.theme-toggle {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: .95rem;
  transition: all .18s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .card { padding: 20px; }
  .container { padding: 0 14px; }
  .nav-links { gap: 0; }
  .nav-link { padding: 7px 10px; font-size: .82rem; }
}

/* Disclaimer Main Container */
.legal-disclaimer-container {
    margin: 20px auto;
    padding: 14px;
    border-radius: 8px;
    max-width: 420px;
    /* Very subtle light red tint for background, border stands out cleanly */
    background-color: rgba(217, 56, 56, 0.03); 
    border: 1px solid rgba(217, 56, 56, 0.25);
}

/* Header Title - Crisp warning red for light mode */
.legal-disclaimer-container h4 {
    color: #b31414; /* Deep, strong alert red */
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

/* Dark theme title override */
[data-theme="dark"] .legal-disclaimer-container h4 {
    color: #ff4d4d; /* Bright red to stand out on dark background */
}

/* Scrollable Text Box (Left-to-Right layout) */
.legal-scroll-box {
    max-height: 120px;
    overflow-y: auto;
    padding-right: 6px;
    text-align: left;
    margin-bottom: 12px;
}

/* LIGHT MODE BODY TEXT: Dark red very near to black */
.legal-scroll-box p {
    color: #2b0b0b; /* Deep crimson-black for maximum contrast and legibility */
    font-size: 0.75rem;
    line-height: 1.4;
    margin: 0 0 8px 0;
}

/* DARK MODE BODY TEXT: Dynamic switch back to readable soft red */
[data-theme="dark"] .legal-scroll-box p {
    color: #ffcccc; 
    opacity: 0.85;
}

.legal-scroll-box p:last-child {
    margin-bottom: 0;
}

/* Sleek Scrollbar styling */
.legal-scroll-box::-webkit-scrollbar {
    width: 4px;
}
.legal-scroll-box::-webkit-scrollbar-thumb {
    background: rgba(217, 56, 56, 0.3);
    border-radius: 4px;
}

/* Checkbox Alignment Row */
.disclaimer-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    text-align: left;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(217, 56, 56, 0.15);
}

.disclaimer-checkbox-label input[type="checkbox"] {
    margin-top: 2px;
    accent-color: #b31414; /* Checkbox color matches the deep red in light mode */
    cursor: pointer;
}

[data-theme="dark"] .disclaimer-checkbox-label input[type="checkbox"] {
    accent-color: #ff4d4d; /* Checkbox color switches to bright red in dark mode */
}

/* Checkbox label text color toggle */
.disclaimer-checkbox-label span {
    color: #1a1a1a; /* Clean charcoal black for light mode */
    font-size: 0.8rem;
    user-select: none;
    font-weight: 500;
}

[data-theme="dark"] .disclaimer-checkbox-label span {
    color: #ffffff; /* Crisp white for dark mode */
}

/* Style for the button when it is disabled */
.btn:disabled, 
.btn.btn-disabled:hover {
    background-color: #4a4a52 !important; 
    background-image: none !important;      /* Clears out any gradient styling overlays */
    color: #8a8a93 !important;            
    border-color: #3a3a42 !important;
    cursor: not-allowed !important;       
    opacity: 0.5 !important;                         
    transform: none !important;           
    box-shadow: none !important;
}

/* Optional adjustment for dark mode disabled state if needed */
[data-theme="dark"] .btn:disabled {
    background-color: #2d2d34 !important;
    color: #666666 !important;
    border-color: #222226 !important;
}