:root {
  --bg: #070a12;
  --panel: rgba(16, 24, 39, 0.82);
  --panel-strong: #101827;
  --panel-soft: #162033;
  --border: rgba(148, 163, 184, 0.18);
  --text: #eef5ff;
  --muted: #8fa1ba;
  --accent: #7c3aed;
  --accent-2: #06b6d4;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.client-shell {
  background:
    radial-gradient(circle at top left, rgba(124, 58, 237, 0.36), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(6, 182, 212, 0.25), transparent 32rem),
    var(--bg);
}

.client-center { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.simple-card { width: min(100%, 720px); border: 1px solid var(--border); border-radius: 24px; background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(20px); }
.auth-card { display: grid; gap: 18px; max-width: 420px; padding: 30px; }
.client-app { display: grid; gap: 18px; padding: 22px; }
.brand-block { text-align: center; }
.brand-block .brand-mark { width: 130px; height: 130px; border-radius: 0; box-shadow: none; }
.brand-block h1, .admin-topbar h1 { margin: 8px 0; line-height: 1.05; }
.brand-block p, .admin-login-card p, .mode-editor p { color: var(--muted); }
.brand-mark { display: inline-block; width: 52px; height: 52px; border-radius: 18px; object-fit: cover; vertical-align: middle; box-shadow: 0 16px 36px rgba(6, 182, 212, 0.18); }
.brand-mark.admin { width: 44px; height: 44px; border-radius: 14px; }
.eyebrow { margin: 0; color: var(--accent-2); font-size: 12px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }

.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px; border-radius: 16px; background: rgba(148, 163, 184, 0.08); }
.user-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px; border: 1px solid var(--border); border-radius: 18px; background: rgba(7, 10, 18, 0.42); }
.tab-btn { border: 0; border-radius: 12px; padding: 11px; background: transparent; color: var(--muted); font-weight: 800; }
.tab-btn.active { background: linear-gradient(135deg, rgba(124, 58, 237, 0.94), rgba(6, 182, 212, 0.84)); color: white; }
.auth-form { display: grid; gap: 14px; }
.link-btn { color: var(--accent-2); font-weight: 800; text-decoration: none; }
.link-btn:hover { text-decoration: underline; }
.centered { text-align: center; }

label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 800; }
input, select { width: 100%; border: 1px solid var(--border); border-radius: 14px; outline: 0; padding: 12px 13px; background: rgba(7, 10, 18, 0.78); color: var(--text); }
input:focus, select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.16); }
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row input { width: auto; }

.btn { border: 1px solid transparent; border-radius: 14px; padding: 11px 16px; color: var(--text); font-weight: 900; transition: 0.2s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: wait; opacity: 0.6; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: white; }
.btn.secondary { border-color: var(--border); background: rgba(148, 163, 184, 0.1); }
.btn.ghost { border-color: var(--border); background: transparent; color: var(--muted); }
.btn.danger, .danger { background: rgba(239, 68, 68, 0.12); border-color: rgba(239, 68, 68, 0.4); color: #fecaca; }
.btn.wide { width: 100%; padding: 15px 18px; }

.app-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand-inline { display: flex; align-items: center; gap: 12px; }
.brand-inline h1 { margin: 0; font-size: 24px; }
.brand-inline p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.brand-mark.small { width: 40px; height: 40px; border-radius: 14px; }
.report-form { display: grid; gap: 16px; }
.dropzone { display: grid; gap: 8px; place-items: center; min-height: 190px; padding: 24px; border: 2px dashed rgba(6, 182, 212, 0.42); border-radius: 20px; background: rgba(6, 182, 212, 0.06); text-align: center; }
.dropzone:hover, .dropzone.dropzone-active { border-color: var(--accent-2); background: rgba(6, 182, 212, 0.12); }
.dropzone strong { font-size: clamp(22px, 5vw, 34px); }
.dropzone span, .empty { margin: 0; color: var(--muted); }
.settings-row, .filters-grid, .inline-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.filters-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.file-list { display: grid; gap: 10px; }
.file-chip { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 16px; background: rgba(7, 10, 18, 0.48); }
.file-chip-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.file-chip-size { color: var(--muted); font-size: 12px; }
.file-chip-remove { border: 0; border-radius: 10px; padding: 5px 9px; background: rgba(239, 68, 68, 0.14); color: #fecaca; }

.user-screen { display: grid; gap: 18px; }
.timeline-card, .report-preview { border-top: 1px solid var(--border); padding-top: 18px; }
.timeline-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.card-head h2, .card-head h3 { margin: 0; }
.timeline-percent { font-size: 28px; font-weight: 950; color: var(--accent-2); }
.timeline-track { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.timeline-step { position: relative; display: grid; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: 18px; background: rgba(7, 10, 18, 0.45); color: var(--muted); }
.timeline-step span { width: 16px; height: 16px; border-radius: 999px; background: var(--border); }
.timeline-step.active { color: var(--text); border-color: rgba(6, 182, 212, 0.55); box-shadow: 0 0 0 1px rgba(6, 182, 212, 0.1); }
.timeline-step.active span { background: var(--accent-2); box-shadow: 0 0 20px rgba(6, 182, 212, 0.85); }
.timeline-step.done { color: var(--text); border-color: rgba(34, 197, 94, 0.45); }
.timeline-step.done span { background: var(--success); }

.summary-actions, .history-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.summary-actions.elevated, .history-actions.elevated { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.summary-actions.elevated .btn, .history-actions.elevated .btn { min-height: 52px; box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22); }
.btn.preview { border-color: rgba(34, 197, 94, 0.5); background: rgba(34, 197, 94, 0.16); color: #bbf7d0; }
.btn.pdf-action.primary { background: linear-gradient(135deg, #f97316, #ef4444); }
.btn.pdf-action.secondary { border-color: rgba(6, 182, 212, 0.48); background: rgba(6, 182, 212, 0.14); color: #cffafe; }
.summary-grid, .metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.summary-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.summary-grid div, .metric-card { padding: 16px; border: 1px solid var(--border); border-radius: 18px; background: rgba(7, 10, 18, 0.42); }
.summary-grid span, .metric-card span, .metric-card small { display: block; color: var(--muted); font-size: 12px; }
.summary-grid strong, .metric-card strong { display: block; margin-top: 6px; font-size: 24px; }
.executive-summary, .topic-card, .decision-card { margin-top: 14px; padding: 18px; border-radius: 18px; background: rgba(124, 58, 237, 0.1); color: #dbeafe; line-height: 1.65; }
.topic-title, .decision-text { font-weight: 900; }
.ready-card { padding: 18px; border: 1px solid rgba(34, 197, 94, 0.35); border-radius: 20px; background: linear-gradient(135deg, rgba(34, 197, 94, 0.14), rgba(6, 182, 212, 0.08)); }
.ready-card h2 { margin: 10px 0 8px; }
.ready-card p, .card-head p { margin: 0; color: var(--muted); line-height: 1.5; }
.report-details { margin-top: 8px; }
.preview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.preview-head h3 { margin: 4px 0 0; }
.user-history-card { border-color: rgba(6, 182, 212, 0.22); background: rgba(7, 10, 18, 0.58); }

.status-line { min-height: 20px; color: var(--muted); font-size: 13px; font-weight: 750; }
.status-line[data-type="error"] { color: #fecaca; }
.status-line[data-type="success"] { color: #bbf7d0; }

.admin-shell { background: #0b0f14; color: #d8dee9; }
.admin-login { display: grid; min-height: 100vh; place-items: center; padding: 20px; background: radial-gradient(circle at top, rgba(255, 120, 0, 0.14), transparent 34rem), #0b0f14; }
.admin-login-card { display: grid; gap: 14px; width: min(100%, 420px); padding: 32px; border: 1px solid #2b333d; border-radius: 10px; background: #111821; box-shadow: var(--shadow); }
.admin-login-card h1 { margin: 0; }
.admin-layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.admin-sidebar { display: flex; position: sticky; top: 0; height: 100vh; flex-direction: column; gap: 24px; padding: 20px; border-right: 1px solid #242b33; background: #0f141b; }
.admin-sidebar h2 { margin: 12px 0 0; }
.admin-sidebar p { margin: 4px 0 0; color: #8b949e; }
.admin-sidebar nav { display: grid; gap: 8px; }
.admin-nav { border: 1px solid transparent; border-radius: 6px; padding: 10px 12px; background: transparent; color: #b7c0cc; text-align: left; font-weight: 800; }
.admin-nav:hover, .admin-nav.active { border-color: #38424f; background: #1a222d; color: white; }
.admin-main { min-width: 0; padding: 22px; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; padding: 18px 20px; border: 1px solid #242b33; border-radius: 10px; background: #111821; }
.admin-user { display: grid; justify-items: end; color: #8b949e; font-size: 12px; }
.admin-user span:first-child { color: white; font-weight: 900; }
.admin-panel { display: grid; gap: 16px; }
.admin-card { padding: 18px; border: 1px solid #242b33; border-radius: 10px; background: #111821; }
.table-list, .report-list, .logs-list, .mode-list { display: grid; gap: 10px; margin-top: 14px; }
.user-card, .history-row, .log-entry, .mode-card { padding: 14px; border: 1px solid #242b33; border-radius: 8px; background: #0f141b; }
.history-row-head, .log-head, .mode-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.history-title, .log-title { font-weight: 900; }
.history-meta, .metric-row, .log-meta, .mode-card span { color: #8b949e; font-size: 12px; }
.status-pill, .role-pill, .log-event { display: inline-flex; margin: 4px 6px 0 0; padding: 4px 8px; border-radius: 999px; background: #1f2937; color: #dbeafe; font-size: 11px; font-weight: 900; }
.status-pill.deleted { background: rgba(245, 158, 11, 0.18); color: #fde68a; }
.log-level-error { border-color: rgba(239, 68, 68, 0.5); }
.log-error { margin-top: 10px; color: #fecaca; }
.mode-editor { max-width: 760px; }
.mode-card strong { display: block; color: white; }

.toast-root { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: grid; gap: 10px; }
.toast { padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel-strong); box-shadow: var(--shadow); }

@media (max-width: 820px) {
  .client-center { min-height: 100svh; padding: 12px; }
  .simple-card { border-radius: 20px; }
  .auth-card, .client-app { padding: 18px; }
  .card-head, .admin-topbar { align-items: stretch; flex-direction: column; }
  .app-top { align-items: stretch; flex-direction: column; }
  .settings-row, .filters-grid, .inline-form, .summary-grid, .metrics-grid, .timeline-track { grid-template-columns: 1fr; }
  .summary-grid.compact, .summary-actions.elevated, .history-actions.elevated { grid-template-columns: 1fr; }
  .dropzone { min-height: 170px; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; }
  .admin-sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-main { padding: 12px; }
  .history-row-head, .log-head, .mode-card { align-items: flex-start; flex-direction: column; }
  .preview-head { flex-direction: column; }
}

@media (max-width: 480px) {
  .auth-card { padding: 18px; }
  .brand-block h1 { font-size: 28px; }
  .admin-sidebar nav { grid-template-columns: 1fr; }
  .summary-actions, .history-actions { display: grid; }
  .btn { width: 100%; }
}
