:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #d8e0ea;
  --border-strong: #b6c3d4;
  --text: #152238;
  --text-muted: #52627a;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --success: #15803d;
  --success-soft: #ecfdf5;
  --success-border: #86efac;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --warning-border: #fcd34d;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fca5a5;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 14px rgba(15, 23, 42, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.brand strong {
  display: block;
  font-size: 1.05rem;
  line-height: 1.15;
}

.brand small {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  font-size: 0.94rem;
}

.nav-link:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.agent-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-box label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.agent-box input {
  width: 175px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  font-size: 0.88rem;
  background: var(--surface-alt);
  color: var(--text);
}

.agent-box input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  background: #ffffff;
}

/* Main */
.main-content {
  flex: 1;
  padding-top: 28px;
  padding-bottom: 48px;
}

.loading-box {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

/* Hero & Stats */
.hero {
  background: linear-gradient(135deg, #102a5c 0%, #1d4ed8 100%);
  color: #ffffff;
  border-radius: 14px;
  padding: 28px 30px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0 0 8px 0;
  font-size: 1.65rem;
  line-height: 1.25;
}

.hero p {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  max-width: 780px;
  font-size: 0.98rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin-top: 4px;
  color: var(--text);
}

.kpi-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Scenario Cards */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-head h2 {
  margin: 0;
  font-size: 1.25rem;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.scenario-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.scenario-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.scenario-num {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.scenario-card h3 {
  margin: 6px 0 8px 0;
  font-size: 1.12rem;
}

.scenario-card p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  font-size: 0.76rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
}

.scenario-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.scenario-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-easy {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-medium {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #bfdbfe;
}

.badge-hard {
  background: var(--warning-soft);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-expert {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

.badge-neutral {
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface-alt);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background: #166534;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover {
  background: #991b1b;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.82rem;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Scenario Page Layout */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.scenario-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.scenario-header h1 {
  margin: 0 0 6px 0;
  font-size: 1.48rem;
}

.scenario-header p {
  margin: 0;
  color: var(--text-muted);
  max-width: 720px;
}

/* Mode Switcher */
.mode-tabs {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.mode-tab {
  padding: 8px 14px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}

.mode-tab.active {
  background: var(--primary);
  color: #ffffff;
}

/* Task Brief Box */
.task-brief {
  background: #f0f7ff;
  border: 1.5px solid #93c5fd;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.task-brief-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.task-brief-head h2 {
  margin: 0;
  font-size: 1.05rem;
  color: #1e3a8a;
}

.task-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.9rem;
  background: #ffffff;
  border: 1px solid #bfdbfe;
  padding: 4px 10px;
  border-radius: 7px;
  color: #1e40af;
}

.task-narrative {
  background: #ffffff;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 12px 0;
}

.expected-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.expected-chip {
  background: #ffffff;
  border: 1px solid #dbeafe;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 0.84rem;
}

.expected-chip strong {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.expected-chip span {
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
}

/* Info / Alert Boxes */
.alert {
  border-radius: 9px;
  padding: 13px 16px;
  margin-bottom: 18px;
  font-size: 0.92rem;
}

.alert-info {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
}

.alert-danger {
  background: var(--danger-soft);
  border: 1.5px solid var(--danger-border);
  color: var(--danger);
}

.alert-success {
  background: var(--success-soft);
  border: 1.5px solid var(--success-border);
  color: var(--success);
}

.alert-warning {
  background: var(--warning-soft);
  border: 1.5px solid var(--warning-border);
  color: var(--warning);
}

.alert ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

/* Form Elements */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.form-section-title {
  margin: 0 0 14px 0;
  font-size: 1.05rem;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field.full-width {
  grid-column: 1 / -1;
}

.form-field > label,
.field-legend {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.req {
  color: var(--danger);
  margin-left: 2px;
}

.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="password"],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: #ffffff;
}

.form-field textarea {
  resize: vertical;
  min-height: 86px;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.form-field.has-error input,
.form-field.has-error select,
.form-field.has-error textarea {
  border-color: var(--danger);
  background: #fffafa;
}

.field-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.field-error {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--danger);
}

.option-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
}

.option-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.92rem;
  cursor: pointer;
  font-weight: 500;
}

.option-item input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-single {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  cursor: pointer;
}

.checkbox-single input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.range-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.range-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
}

.range-val {
  min-width: 58px;
  text-align: center;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 7px;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #bfdbfe;
}

.conditional-box {
  grid-column: 1 / -1;
  padding: 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 9px;
  background: var(--surface-alt);
}

.conditional-box h3 {
  margin: 0 0 12px 0;
  font-size: 0.96rem;
  color: var(--text);
}

/* Dynamic line items */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 6px;
}

.items-table th,
.items-table td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.items-table th {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--surface-alt);
}

.items-table input {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid var(--border-strong);
  border-radius: 7px;
  font-size: 0.9rem;
}

.totals-box {
  margin-top: 14px;
  margin-left: auto;
  max-width: 320px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.92rem;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

.totals-row.grand {
  border-top: 1px solid var(--border-strong);
  margin-top: 6px;
  padding-top: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
}

/* Wizard Stepper */
.stepper {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.step-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88rem;
}

.step-pill.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.step-pill.done {
  border-color: var(--success-border);
  background: var(--success-soft);
  color: var(--success);
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: currentColor;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

.step-num span {
  color: #ffffff;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.form-actions-right {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* Demo accounts box */
.demo-cred-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.demo-cred-card {
  background: #ffffff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
}

.demo-cred-card code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  background: var(--success-soft);
  border: 1.5px solid var(--success-border);
  border-radius: 9px;
  margin-bottom: 18px;
}

/* Tables */
.data-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 18px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filter-bar .form-field {
  min-width: 180px;
  flex: 1;
}

.hidden {
  display: none !important;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 16px 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 760px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .stepper {
    grid-template-columns: 1fr;
  }
  .agent-box input {
    width: 140px;
  }
}
