/* ── Design tokens (same palette as preview.html) ─────────────────────────── */
:root {
  --bg:          #020617;
  --bg-soft:     #0f172a;
  --card:        rgba(255,255,255,.07);
  --text:        #ffffff;
  --muted:       #cbd5e1;
  --muted-dark:  #475569;
  --white:       #ffffff;
  --ink:         #0f172a;
  --indigo:      #4f46e5;
  --indigo-soft: #818cf8;
  --border:      rgba(255,255,255,.12);
  --shadow:      0 24px 80px rgba(0,0,0,.28);
  --radius:      28px;
  --green:       #22c55e;
  --red:         #ef4444;
  --amber:       #f59e0b;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
.container { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.section { padding: 96px 0; }
.section-light { background: #ffffff; color: var(--ink); }
.section-soft  { background: #f1f5f9; color: var(--ink); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 10px; border: 0; border-radius: 999px; padding: 14px 22px;
  font-weight: 800; font-size: 14px; cursor: pointer;
  transition: transform .18s ease, opacity .18s ease, background .18s ease;
  white-space: nowrap; text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary  { background: #fff; color: var(--ink); }
.btn-dark     { background: var(--ink); color: #fff; }
.btn-indigo   { background: var(--indigo); color: #fff; }
.btn-outline  { border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: #fff; }
.btn-outline-dark { border: 1px solid #cbd5e1; background: #fff; color: var(--ink); }
.btn-ghost    { background: transparent; color: #94a3b8; }
.btn-ghost:hover { color: #fff; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fecaca; }

/* ── Header / Nav ─────────────────────────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(2,6,23,.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
}
.nav {
  height: 74px; display: flex; align-items: center;
  justify-content: space-between; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -.02em; }
.brand-icon {
  width: 42px; height: 42px; border-radius: 16px;
  background: #fff; color: var(--ink);
  display: grid; place-items: center; font-size: 21px;
  box-shadow: var(--shadow);
}
.brand small { display: block; color: #94a3b8; font-size: 12px; font-weight: 500; letter-spacing: 0; }
.nav-links { display: flex; gap: 28px; color: #cbd5e1; font-size: 14px; }
.nav-links a:hover { color: #fff; }
.nav-user { display: flex; align-items: center; gap: 16px; }
.nav-user-name { color: #cbd5e1; font-size: 14px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 14px; font-weight: 600; color: #cbd5e1; margin-bottom: 8px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 16px; border-radius: 14px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.07); color: #fff;
  font-family: inherit; font-size: 15px; transition: border-color .2s;
  outline: none;
}
.form-input::placeholder, .form-textarea::placeholder { color: #64748b; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--indigo-soft);
  background: rgba(255,255,255,.1);
}
.form-select { appearance: none; cursor: pointer; }
.form-select option { background: #1e293b; color: #fff; }
.form-textarea { min-height: 140px; resize: vertical; line-height: 1.6; }
.form-hint { font-size: 12px; color: #64748b; margin-top: 6px; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 14px 18px; border-radius: 14px; font-size: 14px;
  font-weight: 600; margin-bottom: 20px; display: none;
}
.alert.show { display: block; }
.alert-error   { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.35); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.15);  border: 1px solid rgba(34,197,94,.35);  color: #86efac; }

/* ── Auth pages ───────────────────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; flex-direction: column; }
.auth-main  { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card  {
  width: 100%; max-width: 460px;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px;
  box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 28px; margin: 0 0 6px; letter-spacing: -.03em; }
.auth-card .sub { color: #94a3b8; font-size: 15px; margin: 0 0 32px; }
.auth-footer { text-align: center; margin-top: 22px; color: #94a3b8; font-size: 14px; }
.auth-footer a { color: var(--indigo-soft); font-weight: 600; }

/* ── Dashboard ────────────────────────────────────────────────────────────── */
.app-page { min-height: 100vh; display: flex; flex-direction: column; }
.app-main  { flex: 1; padding: 48px 0 80px; }

.page-header { margin-bottom: 36px; }
.page-header h1 { font-size: 36px; font-weight: 800; letter-spacing: -.04em; margin: 0 0 8px; }
.page-header p  { color: #94a3b8; margin: 0; }

.quota-bar {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  border-radius: 18px; padding: 18px 22px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-bottom: 32px;
}
.quota-text { font-size: 14px; color: #cbd5e1; }
.quota-text strong { color: #fff; font-size: 18px; }
.quota-track {
  flex: 1; height: 8px; background: rgba(255,255,255,.1);
  border-radius: 99px; overflow: hidden; max-width: 200px;
}
.quota-fill {
  height: 100%; background: var(--indigo); border-radius: 99px;
  transition: width .4s ease;
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.report-card {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  transition: border-color .2s, transform .2s;
  cursor: pointer; text-decoration: none; color: inherit;
  display: block;
}
.report-card:hover { border-color: rgba(255,255,255,.25); transform: translateY(-2px); }
.report-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.report-card-title { font-size: 16px; font-weight: 700; margin: 0; line-height: 1.3; }
.report-card-meta  { color: #64748b; font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; }

.badge-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 700;
  white-space: nowrap;
}
.badge-done       { background: rgba(34,197,94,.15);  color: #86efac; }
.badge-generating { background: rgba(79,70,229,.2);   color: var(--indigo-soft); }
.badge-error      { background: rgba(239,68,68,.15);  color: #fca5a5; }

.empty-state {
  text-align: center; padding: 72px 24px;
  border: 2px dashed rgba(255,255,255,.12);
  border-radius: var(--radius);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 22px; margin: 0 0 8px; }
.empty-state p  { color: #64748b; margin: 0 0 24px; }

/* ── New report form ──────────────────────────────────────────────────────── */
.form-page { max-width: 780px; }
.form-card {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 36px;
}
.form-section { margin-bottom: 32px; }
.form-section-title {
  font-size: 11px; font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--indigo-soft);
  margin: 0 0 16px;
}
.select-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.area-chips  { display: flex; flex-wrap: wrap; gap: 10px; }
.area-chip {
  padding: 8px 16px; border-radius: 99px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.06); color: #cbd5e1;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s ease;
}
.area-chip:hover, .area-chip.active {
  border-color: var(--indigo-soft); background: rgba(79,70,229,.2); color: #fff;
}

/* ── Report view ──────────────────────────────────────────────────────────── */
.report-page { max-width: 900px; }

.report-meta-bar {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 20px 24px;
  display: flex; align-items: center; gap: 20px;
  flex-wrap: wrap; margin-bottom: 24px;
}
.report-meta-item { display: flex; flex-direction: column; gap: 2px; }
.report-meta-label { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.report-meta-value { font-size: 14px; font-weight: 600; color: #e2e8f0; }

.verify-summary {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-bottom: 28px;
}
.verify-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 700;
}
.verify-badge-ok      { background: rgba(34,197,94,.12);  border: 1px solid rgba(34,197,94,.3);  color: #86efac; }
.verify-badge-fail    { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.verify-badge-unknown { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }

/* ── Loading state ────────────────────────────────────────────────────────── */
.loading-card {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 52px;
  text-align: center;
}
.spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.1);
  border-top-color: var(--indigo-soft);
  animation: spin .8s linear infinite;
  margin: 0 auto 24px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-steps { display: flex; flex-direction: column; gap: 8px; margin-top: 24px; max-width: 380px; margin-inline: auto; }
.loading-step {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: #64748b; padding: 10px 16px;
  border-radius: 12px; background: rgba(255,255,255,.04);
}
.loading-step.active { color: #cbd5e1; background: rgba(79,70,229,.12); }
.loading-step.done   { color: #86efac; }

/* ── Report rendered content ──────────────────────────────────────────────── */
.report-body {
  background: #ffffff; color: var(--ink);
  border-radius: var(--radius); padding: 48px;
  box-shadow: var(--shadow);
}
.report-body h2 {
  font-size: 19px; font-weight: 800; color: var(--ink);
  margin: 36px 0 16px; padding-bottom: 10px;
  border-bottom: 2px solid #e2e8f0; letter-spacing: -.02em;
}
.report-body h2:first-child { margin-top: 0; }
.report-body h3 { font-size: 15px; font-weight: 700; color: #334155; margin: 24px 0 10px; }
.report-body p  { margin: 0 0 14px; color: #334155; line-height: 1.75; }
.report-body blockquote {
  margin: 16px 0; padding: 14px 20px;
  border-left: 4px solid var(--indigo);
  background: #f8fafc; border-radius: 0 12px 12px 0;
  color: #64748b; font-size: 14px;
}
.report-body table {
  width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px;
  border-radius: 12px; overflow: hidden;
}
.report-body th {
  background: #1e293b; color: #fff; padding: 12px 16px;
  text-align: left; font-weight: 700; font-size: 13px;
}
.report-body td {
  padding: 12px 16px; border-bottom: 1px solid #e2e8f0; vertical-align: top;
  color: #334155; line-height: 1.6;
}
.report-body tr:last-child td { border-bottom: none; }
.report-body tr:nth-child(even) td { background: #f8fafc; }
.report-body strong { font-weight: 700; color: var(--ink); }
.report-body ul, .report-body ol { margin: 0 0 14px; padding-left: 24px; color: #334155; }
.report-body li { margin-bottom: 6px; }

/* ── Citation badges ──────────────────────────────────────────────────────── */
.cite {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600;
  text-decoration: none; vertical-align: middle; cursor: default;
  word-break: break-word; max-width: 100%;
  border-left: 3px solid transparent;
  transition: opacity .15s;
}
a.cite { cursor: pointer; }
a.cite:hover { opacity: .85; text-decoration: underline; }

.cite-norm { background: #ede9fe; color: #5b21b6; }
.cite-sent { background: #dbeafe; color: #1e40af; }

.cite-verified  { border-left-color: var(--green); }
.cite-notfound  { border-left-color: var(--red); opacity: .8; }
.cite-unknown   { border-left-color: var(--amber); }

.cite-verified.cite-norm  { background: #dcfce7; color: #166534; }
.cite-verified.cite-sent  { background: #dcfce7; color: #166534; }
.cite-notfound.cite-norm  { background: #fee2e2; color: #991b1b; }
.cite-notfound.cite-sent  { background: #fee2e2; color: #991b1b; }
.cite-unknown.cite-norm   { background: #fef3c7; color: #92400e; }
.cite-unknown.cite-sent   { background: #fef3c7; color: #92400e; }

.cite-icon { font-size: 10px; font-weight: 900; }
.cite-kind {
  font-size: 10px; opacity: .7; text-transform: uppercase;
  letter-spacing: .05em; white-space: nowrap;
}
.cite-text { line-height: 1.3; }

/* ── Citations panel ──────────────────────────────────────────────────────── */
.citations-panel {
  margin-top: 32px;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px;
}
.citations-panel h3 { margin: 0 0 20px; font-size: 18px; }
.citations-list { display: grid; gap: 10px; }
.citation-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-radius: 14px;
  background: rgba(255,255,255,.05); font-size: 13px;
}
.citation-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 4px;
}
.citation-dot-ok      { background: var(--green); }
.citation-dot-fail    { background: var(--red); }
.citation-dot-unknown { background: var(--amber); }
.citation-ref { color: #e2e8f0; font-weight: 600; flex: 1; }
.citation-status { font-size: 12px; color: #64748b; }
a.citation-ref { color: #818cf8; }
a.citation-ref:hover { text-decoration: underline; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 36px; color: #94a3b8; font-size: 13px;
}
.footer-row { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.legal-note {
  margin-top: 18px; padding: 14px 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  border-radius: 14px; font-size: 11px; line-height: 1.7; color: #64748b;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 920px) {
  .nav-links { display: none; }
  .select-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .container { width: calc(100% - 28px); }
  .auth-card { padding: 28px 22px; }
  .report-body { padding: 28px 20px; }
  .form-card { padding: 24px 18px; }
  .brand small { display: none; }
  .nav .btn { display: none; }
}
