/* FormFQA Design System */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #1b2a4a;
  --navy-light: #253660;
  --blue: #3d7fff;
  --blue-hover: #2d6fee;
  --page-bg: #f4f5f7;
  --card-bg: #ffffff;
  --border: #e2e5eb;
  --border-strong: #c8cdd7;
  --text-primary: #1b2a4a;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --green: #15803d;
  --green-bg: #dcfce7;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: var(--page-bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* Nav */
header {
  background: var(--navy);
  padding: 0 2rem;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-mark {
  width: 30px;
  height: 30px;
  background: var(--blue);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
}

.logo-text {
  font-size: 15px;
  font-weight: 600;
  color: white;
}

nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

nav a {
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 6px;
  transition: all 0.15s;
}

nav a:hover { color: white; background: rgba(255,255,255,0.08); }
nav a.active { color: white; background: rgba(255,255,255,0.12); }

.org-pill {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  padding: 4px 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
  border: 0.5px solid rgba(255,255,255,0.15);
}

/* Layout */
.wrap { max-width: 860px; margin: 2.5rem auto; padding: 0 1.5rem; }
.wrap-wide { max-width: 1100px; margin: 2.5rem auto; padding: 0 1.5rem; }
.wrap-narrow { max-width: 580px; margin: 2.5rem auto; padding: 0 1.5rem; }

/* Cards */
.card {
  background: var(--card-bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.card + .card { margin-top: 1.25rem; }

/* Typography */
.page-title { font-size: 22px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.page-sub { font-size: 14px; color: var(--text-secondary); margin-bottom: 2rem; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 1rem; }
.section-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-primary:disabled { background: #9ca3af; cursor: not-allowed; }

.btn-dark { background: var(--navy); color: white; }
.btn-dark:hover { background: var(--navy-light); }

.btn-outline { background: white; color: var(--text-primary); border: 0.5px solid var(--border-strong); }
.btn-outline:hover { background: var(--page-bg); }

.btn-ghost { background: transparent; color: var(--text-secondary); border: none; }
.btn-ghost:hover { color: var(--text-primary); background: var(--page-bg); }

.btn-full { width: 100%; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger { background: var(--red-bg); color: var(--red); border: 0.5px solid #fca5a5; }
.btn-danger:hover { background: #fee2e2; }

/* CTA block */
.cta-block {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--blue);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  text-decoration: none;
  transition: background 0.15s;
  margin-bottom: 1.5rem;
}
.cta-block:hover { background: var(--blue-hover); }
.cta-icon { width: 40px; height: 40px; background: rgba(255,255,255,0.15); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 20px; color: white; }
.cta-text strong { display: block; font-size: 15px; font-weight: 600; color: white; margin-bottom: 2px; }
.cta-text span { font-size: 13px; color: rgba(255,255,255,0.65); }
.cta-arrow { margin-left: auto; font-size: 18px; color: rgba(255,255,255,0.4); }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 1.5rem; }
.stat-card { background: white; border: 0.5px solid var(--border); border-radius: 10px; padding: 1rem 1.25rem; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.stat-val { font-size: 26px; font-weight: 600; color: var(--text-primary); }
.stat-val.ok { color: var(--green); }
.stat-val.low { color: var(--red); }

/* Table */
.table-panel { background: white; border: 0.5px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.table-header { padding: 12px 16px; border-bottom: 0.5px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.table-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.table-link { font-size: 12px; color: var(--blue); text-decoration: none; }
.table-link:hover { text-decoration: underline; }
table { width: 100%; border-collapse: collapse; }
th { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; padding: 9px 16px; text-align: left; border-bottom: 0.5px solid var(--border); background: #fafbfc; }
td { padding: 11px 16px; font-size: 13px; border-bottom: 0.5px solid #f0f1f3; color: var(--text-primary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* Badges */
.badge { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 20px; font-weight: 500; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-grey { background: #f0f0ec; color: var(--text-secondary); }
.badge-blue { background: #dbeafe; color: #1d4ed8; }

/* RAG dot */
.rag-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.rag-dot.green { background: #16a34a; }
.rag-dot.amber { background: #d97706; }
.rag-dot.red { background: #dc2626; }

/* RAG banner */
.rag-banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 1.25rem; border: 0.5px solid; }
.rag-banner.green { background: var(--green-bg); border-color: #86efac; }
.rag-banner.amber { background: var(--amber-bg); border-color: #fcd34d; }
.rag-banner.red { background: var(--red-bg); border-color: #fca5a5; }
.rag-label { font-size: 13px; font-weight: 600; }
.rag-label.green { color: var(--green); }
.rag-label.amber { color: var(--amber); }
.rag-label.red { color: var(--red); }

/* Forms */
label { font-size: 13px; font-weight: 500; color: var(--text-primary); display: block; margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: white;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(61,127,255,0.1); }
textarea { resize: vertical; min-height: 120px; }
.field { margin-bottom: 1rem; }
.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Drop zone */
.drop-zone { border: 2px dashed var(--border-strong); border-radius: 10px; padding: 2.5rem; text-align: center; cursor: pointer; transition: border-color 0.2s; }
.drop-zone:hover, .drop-zone.over { border-color: var(--blue); }
.drop-zone input { display: none; }
.drop-zone strong { display: block; font-size: 15px; font-weight: 500; color: var(--text-primary); margin-bottom: 4px; }
.drop-zone p { font-size: 13px; color: var(--text-muted); }

/* Info boxes */
.info-box { background: #eff6ff; border: 0.5px solid #bfdbfe; border-radius: var(--radius); padding: 12px 14px; font-size: 13px; color: #1d4ed8; line-height: 1.6; margin-bottom: 1rem; }
.warn-box { background: var(--amber-bg); border: 0.5px solid #fcd34d; border-radius: var(--radius); padding: 12px 14px; font-size: 13px; color: var(--amber); line-height: 1.6; margin-bottom: 1rem; }
.confirm-box { background: var(--amber-bg); border: 0.5px solid #fcd34d; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 1rem; }
.confirm-box label { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; color: var(--amber); cursor: pointer; line-height: 1.5; font-weight: 400; }
.confirm-box input[type=checkbox] { margin-top: 2px; flex-shrink: 0; width: 16px; height: 16px; accent-color: var(--blue); }
.err-box { background: var(--red-bg); border: 0.5px solid #fca5a5; border-radius: var(--radius); padding: 12px 14px; font-size: 13px; color: var(--red); }

/* Toggle */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: #fafbfc; border: 0.5px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; cursor: pointer; }
.toggle-label { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.toggle-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.toggle-switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #d1d5db; border-radius: 20px; transition: .2s; }
.toggle-slider:before { position: absolute; content: ""; height: 14px; width: 14px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .2s; }
input:checked + .toggle-slider { background: var(--blue); }
input:checked + .toggle-slider:before { transform: translateX(16px); }

/* Token bar */
.token-bar { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 1.5rem; padding: 10px 14px; background: white; border: 0.5px solid var(--border); border-radius: var(--radius); }
.token-count { font-size: 18px; font-weight: 600; }
.token-count.ok { color: var(--green); }
.token-count.low { color: var(--red); }

/* Spinner */
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.35); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-dark { width: 20px; height: 20px; border: 2px solid rgba(0,0,0,0.1); border-top-color: var(--navy); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); }
.login-card { background: white; border-radius: 14px; padding: 2.5rem 2rem; width: 100%; max-width: 380px; }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 1.5rem; }
.login-org { font-size: 20px; font-weight: 600; color: var(--text-primary); }
.login-sub { font-size: 14px; color: var(--text-secondary); margin-bottom: 2rem; }
.login-footer { margin-top: 1.5rem; font-size: 12px; color: var(--text-muted); text-align: center; }

/* Admin */
.admin-badge { display: inline-block; font-size: 11px; padding: 2px 8px; background: #eff6ff; color: #1d4ed8; border-radius: 20px; margin-bottom: 1rem; }

/* Divider */
hr { border: none; border-top: 0.5px solid var(--border); margin: 1.25rem 0; }

/* Sidebar grid */
.sidebar-grid { display: grid; grid-template-columns: 240px 1fr; gap: 1.5rem; }

/* Section queue */
.sq-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0.5px solid var(--border); border-radius: var(--radius); background: white; cursor: pointer; transition: all 0.15s; margin-bottom: 6px; }
.sq-item:hover { border-color: var(--border-strong); }
.sq-item.active { border-color: var(--blue); background: #eff6ff; }
.sq-item.done-green { border-color: #86efac; background: var(--green-bg); }
.sq-item.done-amber { border-color: #fcd34d; background: var(--amber-bg); }
.sq-item.done-red { border-color: #fca5a5; background: var(--red-bg); }
.sq-name { font-size: 12px; flex: 1; line-height: 1.4; color: var(--text-primary); }
.sq-score { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* Feedback blocks */
.fb-block { margin-bottom: 1.25rem; }
.fb-title { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.fb-item { font-size: 13px; color: var(--text-primary); padding: 6px 0; border-bottom: 0.5px solid #f0f1f3; line-height: 1.5; display: flex; gap: 8px; }
.fb-item:last-child { border-bottom: none; }
.fb-bar { width: 3px; flex-shrink: 0; border-radius: 2px; margin-top: 3px; align-self: stretch; }
.fb-bar.green { background: #16a34a; }
.fb-bar.red { background: #dc2626; }
.fb-bar.blue { background: var(--blue); }
.reg-tag { display: inline-block; font-size: 11px; padding: 2px 8px; background: #f4f5f7; border: 0.5px solid var(--border); border-radius: 20px; color: var(--text-secondary); margin: 2px; }

/* Save bar */
.save-bar { background: white; border: 0.5px solid var(--border); border-radius: var(--radius-lg); padding: 1rem 1.5rem; margin-top: 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* Print */
@media print {
  header, nav, .btn, .save-bar { display: none !important; }
  body { background: white; }
  .card { border: none; padding: 0; }
}

@media (max-width: 720px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .sidebar-grid { grid-template-columns: 1fr; }
}
