/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --bg:        #0a0c0f;
  --bg-1:      #111418;
  --bg-2:      #181c22;
  --bg-3:      #1f242c;
  --border:    #252b35;
  --border-2:  #2e3540;
  --text:      #e2e8f0;
  --text-2:    #94a3b8;
  --text-3:    #64748b;
  --accent:    #3b82f6;
  --accent-2:  #1d4ed8;
  --green:     #22c55e;
  --amber:     #f59e0b;
  --red:       #ef4444;
  --mono:      'IBM Plex Mono', monospace;
  --sans:      'IBM Plex Sans', sans-serif;
  --radius:    6px;
  --radius-lg: 10px;
}

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

/* ── Nav ───────────────────────────────────────────────────────────────── */
.nav {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  height: 56px;
}
.nav-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  height: 100%; display: flex; align-items: center; gap: 32px;
}
.nav-logo {
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.logo-mark {
  width: 32px; height: 32px;
  background: var(--accent); color: #fff;
  border-radius: 6px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: -0.5px;
}
.logo-text {
  font-size: 15px; font-weight: 500; color: var(--text);
}
.logo-text em { font-style: normal; color: var(--text-2); font-weight: 300; }
.nav-links {
  flex: 1; align-items: center; gap: 4px;
  display: flex;
}
.nav-link {
  padding: 6px 12px; border-radius: var(--radius);
  color: var(--text-2); font-size: 14px;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-2); }
.nav-user {
  display: flex; align-items: center; gap: 12px; margin-left: auto;
}
.nav-user-name { font-size: 13px; color: var(--text-3); }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
  border: none; cursor: pointer;
  transition: opacity .15s, background .15s;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border-2); }
.btn-outline:hover:not(:disabled) { background: var(--bg-2); }
.btn-ghost    { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-2); color: var(--text); }
.btn-danger   { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Main layout ───────────────────────────────────────────────────────── */
.main { max-width: 1200px; margin: 0 auto; padding: 32px 24px; }
.page-header { margin-bottom: 32px; }
.page-title { font-size: 22px; font-weight: 600; }
.page-sub { color: var(--text-2); font-size: 14px; margin-top: 4px; }

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

/* ── Form ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 9px 12px;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
  transition: border-color .15s;
}
.form-input:focus { outline: none; border-color: var(--accent); }
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }

/* ── Study grid ─────────────────────────────────────────────────────────── */
.study-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.study-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
  position: relative;
}
.study-card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.study-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.study-modality {
  font-family: var(--mono); font-size: 11px;
  background: var(--bg-3); color: var(--text-2);
  padding: 2px 8px; border-radius: 4px;
}
.study-report-badge {
  font-size: 11px; font-weight: 600;
  background: #14532d; color: var(--green);
  padding: 2px 8px; border-radius: 4px;
}
.study-patient { font-size: 15px; font-weight: 500; margin: 10px 0 4px; }
.study-meta { font-size: 12px; color: var(--text-3); }
.study-footer {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.study-count { font-size: 12px; color: var(--text-3); font-family: var(--mono); }
.study-status {
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 4px;
}
.status-ready     { background: #1e3a5f; color: #60a5fa; }
.status-reported  { background: #14532d; color: var(--green); }
.status-processing{ background: var(--bg-3); color: var(--text-3); }
.source-badge {
  font-size: 10px; font-weight: 600; font-family: var(--mono);
  padding: 2px 6px; border-radius: 3px; margin-left: 6px;
  vertical-align: middle;
}
.source-dicom { background: #431407; color: #fb923c; }
.source-web   { background: var(--bg-3); color: var(--text-3); }

/* ── Upload ─────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent); background: rgba(59,130,246,.04);
}
.drop-icon { font-size: 40px; margin-bottom: 12px; }
.drop-label { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.drop-hint { font-size: 13px; color: var(--text-3); }
.file-list { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-2); border-radius: var(--radius);
  padding: 8px 12px; font-size: 13px;
}
.file-item-name { color: var(--text-2); font-family: var(--mono); }
.file-item-size { color: var(--text-3); }
.progress-bar {
  height: 4px; background: var(--bg-3); border-radius: 2px;
  overflow: hidden; margin-top: 16px;
}
.progress-fill {
  height: 100%; background: var(--accent);
  border-radius: 2px; transition: width .3s;
  width: 0%;
}
.upload-status { font-size: 13px; color: var(--text-2); margin-top: 10px; }

/* ── Alert ──────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 14px; margin-bottom: 16px;
}
.alert-error { background: #450a0a; border: 1px solid #7f1d1d; color: #fca5a5; }
.alert-success { background: #052e16; border: 1px solid #14532d; color: #86efac; }
.alert-info { background: #0c1a2e; border: 1px solid #1e3a5f; color: #93c5fd; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 10px 14px;
  color: var(--text-3); font-weight: 500;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-2); }

/* ── Auth page ──────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: calc(100vh - 56px);
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 36px;
}
.auth-title { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.auth-sub { font-size: 13px; color: var(--text-3); margin-bottom: 28px; }
.auth-tabs { display: flex; gap: 2px; margin-bottom: 24px; background: var(--bg-2); border-radius: var(--radius); padding: 3px; }
.auth-tab {
  flex: 1; text-align: center; padding: 7px;
  border-radius: 4px; font-size: 13px; font-weight: 500;
  cursor: pointer; color: var(--text-3); border: none; background: none;
  transition: all .15s;
}
.auth-tab.active { background: var(--bg-3); color: var(--text); }

/* ── Utility ────────────────────────────────────────────────────────────── */
.mono { font-family: var(--mono); }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }
.empty-state {
  text-align: center; padding: 64px 32px;
  color: var(--text-3); font-size: 14px;
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
