/* Report Studio — unified styles (login + dashboard) */

:root {
  --bg: #f5f6fb;
  --bg-elevated: #ffffff;
  --panel: #ffffff;
  --border: #e6e8f0;
  --border-strong: #d7dae7;
  --text: #1b1f2a;
  --text-soft: #5b6172;
  --text-faint: #8a90a3;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;
  --accent: #0ea5e9;
  --success: #0f9d76;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(20, 24, 48, 0.06);
  --shadow-md: 0 6px 24px rgba(20, 24, 48, 0.08);
  --shadow-lg: 0 18px 48px rgba(20, 24, 48, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body { background: var(--bg); }

h1, h2, h3, p { margin: 0; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: inline-flex; line-height: 0; border-radius: 10px; }
.brand-title { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.76rem; color: var(--text-faint); margin-top: 1px; }

/* ---------- Auth ---------- */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, #e7e9ff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #e0f2fe 0%, transparent 50%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.auth-heading { font-size: 1.4rem; font-weight: 700; margin-top: 26px; letter-spacing: -0.02em; }
.auth-copy { color: var(--text-soft); font-size: 0.9rem; margin-top: 6px; }
.auth-foot { margin-top: 22px; text-align: center; color: var(--text-faint); font-size: 0.78rem; }

.stack { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 6px;
}
.hint { color: var(--text-faint); font-weight: 500; font-size: 0.72rem; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
select {
  width: 100%;
  padding: 11px 13px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text);
  background: #fbfbfe;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235b6172' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}

input:focus, select:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

input::placeholder { color: #aab0c2; }

.input-wrap { position: relative; display: block; }
.input-wrap input { padding-right: 66px; }
.ghost-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.ghost-toggle:hover { background: var(--primary-soft); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.08s ease, opacity 0.16s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { border-color: #c3c8da; background: #fbfbff; }

.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover:not(:disabled) { background: #eceef7; color: var(--text); }

.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 0.8rem; }

/* ---------- Alerts / toast ---------- */
.alert {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  margin: 0;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert-info { background: var(--primary-soft); color: var(--primary); border: 1px solid #dcdffb; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(12px);
  background: #1f2333;
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.84rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 60;
  max-width: 90vw;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: #b91c1c; }

/* ---------- Spinner ---------- */
.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-secondary .spinner { border-color: rgba(79, 70, 229, 0.3); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App shell ---------- */
.app-body { height: 100vh; overflow: hidden; }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.brand-sm .brand-title { font-size: 0.98rem; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip {
  font-size: 0.8rem;
  color: var(--text-soft);
  background: #f1f2f9;
  padding: 6px 12px;
  border-radius: 999px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px 20px 20px;
  min-height: 0;
}

.pane {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.pane-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.pane-head h2 { font-size: 1.02rem; font-weight: 700; letter-spacing: -0.01em; }
.pane-head p { color: var(--text-faint); font-size: 0.8rem; margin-top: 3px; }
.pane-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.pane-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Independent, scrollbar-free scrolling regions */
.scroll-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior: contain;
  padding: 18px 20px 24px;
}
.scroll-area::-webkit-scrollbar { width: 0; height: 0; display: none; }

.pane-config .scroll-area { display: flex; flex-direction: column; gap: 16px; }
.pane-output .output-area { display: flex; flex-direction: column; padding: 0; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fcfcff;
  padding: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.card-head h3 { font-size: 0.92rem; font-weight: 700; }
.card-copy { color: var(--text-soft); font-size: 0.81rem; line-height: 1.5; margin-bottom: 14px; }
.card .field { margin-bottom: 12px; }
.card .field:last-of-type { margin-bottom: 0; }
.card .btn { margin-top: 14px; }

.badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: 999px;
}
.badge-muted { background: #eef0f7; color: var(--text-faint); }

/* ---------- Choice cards ---------- */
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 2px; }
.choice {
  text-align: left;
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-top: 10px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.choice:hover { border-color: #c3c8da; }
.choice.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.choice-title { font-size: 0.84rem; font-weight: 700; color: var(--text); }
.choice-copy { font-size: 0.72rem; color: var(--text-soft); line-height: 1.4; }

/* ---------- Progress ---------- */
.card-progress { background: #f7f8ff; border-color: #dfe2fb; }
.progress-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.progress-head h3 { font-size: 0.9rem; font-weight: 700; }
.progress-head .card-copy { margin: 2px 0 0; }
.pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.5);
  animation: pulse 1.6s ease-out infinite;
  flex: none;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(79, 70, 229, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}
.progress-track {
  height: 7px;
  background: #e3e5f5;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #4f46e5);
  transition: width 0.5s ease;
}

/* ---------- Report list ---------- */
.report-list { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 24px; }

.report-item {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.1s ease;
}
.report-item:hover {
  border-color: #c8cce4;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.report-icon {
  width: 40px; height: 40px; flex: none;
  border-radius: 11px;
  display: grid; place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
}
.report-meta { flex: 1; min-width: 0; }
.report-title {
  font-size: 0.9rem; font-weight: 650; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.report-sub { font-size: 0.76rem; color: var(--text-faint); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }
.report-arrow { color: var(--text-faint); flex: none; }

.empty-state {
  margin: 60px auto 0;
  text-align: center;
  color: var(--text-faint);
  max-width: 260px;
}
.empty-icon {
  width: 58px; height: 58px; margin: 0 auto 14px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: #eef0f9;
  color: #9aa0b8;
}
.empty-state p { font-weight: 700; color: var(--text-soft); font-size: 0.92rem; }
.empty-state span { font-size: 0.8rem; display: block; margin-top: 5px; line-height: 1.5; }

/* ---------- Preview ---------- */
.report-preview { flex: 1 1 auto; min-height: 0; display: flex; }
.report-preview[hidden] { display: none; }
.report-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app-body { height: auto; overflow: auto; }
  .app-shell { height: auto; }
  .workspace { grid-template-columns: 1fr; }
  .scroll-area { overflow: visible; }
  .pane { max-height: none; }
  .report-preview iframe { min-height: 70vh; }
  .field-row { grid-template-columns: 1fr; }
  .choice-grid { grid-template-columns: 1fr; }
}
