@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --bg:         #0d0d0d;
  --surface:    #161616;
  --card:       #1e1e1e;
  --border:     #2a2a2a;
  --text:       #e8e8e8;
  --muted:      #7a7a7a;
  --accent:     #F39131;
  --accent-dim: rgba(243,145,49,.12);
  --accent-hi:  rgba(243,145,49,.25);
  --green:      #4ade80;
  --green-dim:  rgba(74,222,128,.12);
  --red:        #f87171;
  --red-dim:    rgba(248,113,113,.12);
  --blue:       #60a5fa;
  --blue-dim:   rgba(96,165,250,.12);
  --yellow:     #fbbf24;
  --yellow-dim: rgba(251,191,36,.12);
  --sidebar-w:  220px;
  --radius:     8px;
  --font:       'Inter', system-ui, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ── Layout ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page-header {
  padding: 24px 32px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.page-header h1 {
  font-size: 20px;
  font-weight: 600;
}
.page-body { padding: 24px 32px; flex: 1; }

/* ── Sidebar content ─────────────────────────────────────── */
.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-mark {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.3px;
}
.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}
.nav-section {
  padding: 8px 18px 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  font-size: 13px;
  color: var(--muted);
  border-radius: 0;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav-item.active { color: var(--accent); background: var(--accent-dim); border-left-color: var(--accent); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-user strong { color: var(--text); display: block; font-size: 13px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-primary:hover { background: #d97f22; text-decoration: none; }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #2a2a2a; text-decoration: none; }
.btn-danger    { background: var(--red-dim); color: var(--red); border-color: rgba(248,113,113,.3); }
.btn-danger:hover { background: rgba(248,113,113,.2); text-decoration: none; }
.btn-ghost     { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { color: var(--text); background: var(--card); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn:disabled, .btn[disabled] { opacity: .4; pointer-events: none; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}
.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.card-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Stats grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card { padding: 16px; }
.stat-card .card-value { font-size: 32px; color: var(--accent); }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 11px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.td-mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid currentColor;
}
.badge-muted  { color: var(--muted); background: transparent; }
.badge-green  { color: var(--green); background: var(--green-dim); }
.badge-red    { color: var(--red); background: var(--red-dim); }
.badge-blue   { color: var(--blue); background: var(--blue-dim); }
.badge-yellow { color: var(--yellow); background: var(--yellow-dim); }
.badge-orange { color: var(--accent); background: var(--accent-dim); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.form-label .req { color: var(--red); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-control::placeholder { color: var(--muted); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 640px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: var(--green-dim); border: 1px solid rgba(74,222,128,.3); color: var(--green); }
.alert-error   { background: var(--red-dim); border: 1px solid rgba(248,113,113,.3); color: var(--red); }
.alert-info    { background: var(--blue-dim); border: 1px solid rgba(96,165,250,.3); color: var(--blue); }
.alert-warning { background: var(--yellow-dim); border: 1px solid rgba(251,191,36,.3); color: var(--yellow); }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 24px; gap: 0; }
.tab-btn {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Doc upload grid ─────────────────────────────────────── */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.doc-card {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color .2s;
  position: relative;
}
.doc-card.uploaded  { border-color: var(--green); border-style: solid; }
.doc-card.uploading { border-color: var(--accent); }
.doc-icon   { font-size: 24px; margin-bottom: 8px; }
.doc-label  { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.doc-desc   { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.doc-status { font-size: 11px; }
.doc-status.ok     { color: var(--green); }
.doc-status.missing { color: var(--muted); }
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  transition: border-color .2s, background .2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}
.doc-file-name {
  font-size: 11px;
  color: var(--green);
  margin-top: 6px;
  word-break: break-all;
}

/* ── Gate banner ─────────────────────────────────────────── */
.gate-banner {
  background: var(--red-dim);
  border: 1px solid rgba(248,113,113,.3);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--red);
}
.gate-banner strong { display: block; margin-bottom: 4px; font-size: 14px; }
.gate-banner ul { margin: 6px 0 0 18px; }
.gate-banner li { margin-bottom: 2px; }

/* ── AI stream output ─────────────────────────────────────── */
.ai-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 200px;
  font-size: 13px;
  line-height: 1.7;
}
.ai-output.streaming { border-color: var(--accent); }
.ai-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  animation: blink .7s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 1px;
}
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0; } }
.ai-placeholder {
  color: var(--muted);
  text-align: center;
  padding: 40px 20px;
}
.ai-placeholder .placeholder-icon { font-size: 40px; margin-bottom: 10px; }

/* ── Video section ───────────────────────────────────────── */
.video-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}
.video-box video {
  max-width: 100%;
  border-radius: 6px;
  margin-bottom: 12px;
}
.progress-ring { margin: 20px auto; }
.model-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 16px 0;
}
.model-opt {
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.model-opt.selected, .model-opt:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Quote header ────────────────────────────────────────── */
.quote-hdr {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}
.quote-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.quote-title { font-size: 22px; font-weight: 700; margin: 4px 0; }
.quote-meta  { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 12px; }
.quote-meta span::before { content: '• '; }
.quote-meta span:first-child::before { content: ''; }
.quote-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px 32px;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo .brand { font-size: 24px; font-weight: 700; color: var(--accent); }
.login-logo .sub   { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Misc utils ──────────────────────────────────────────── */
.text-muted  { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(243,145,49,.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap; }
  .main { margin-left: 0; }
  .page-body { padding: 16px; }
  .page-header { padding: 16px; }
  body { flex-direction: column; }
}
