:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-hover: #cbd5e1;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  }
  
  * { box-sizing: border-box; margin: 0; padding: 0; }
  
  body {
    font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
  }
  
  a { color: var(--primary); text-decoration: none; }
  a:hover { text-decoration: underline; }
  
  /* Layout */
  .topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
  }
  .topbar .brand {
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .topbar .brand-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--primary);
  }
  .topbar .actions {
    display: flex;
    gap: 12px;
    align-items: center;
  }
  
  .container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
  }
  .container-narrow {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
  }
  
  /* Buttons */
  .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    text-decoration: none;
  }
  .btn:hover { border-color: var(--border-hover); background: #f1f5f9; }
  .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
  }
  .btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
  .btn-danger { color: var(--danger); }
  .btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
  .btn-ghost { border: none; background: transparent; }
  .btn-ghost:hover { background: #f1f5f9; }
  .btn-sm { padding: 5px 10px; font-size: 13px; }
  .btn-lg { padding: 12px 22px; font-size: 15px; }
  .btn:disabled { opacity: .5; cursor: not-allowed; }
  
  /* Cards */
  .card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
  }
  .card + .card { margin-top: 16px; }
  
  /* Login */
  .login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
  }
  .login-box {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
  }
  .login-box h1 {
    font-size: 22px;
    margin-bottom: 8px;
  }
  .login-box p.sub {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 14px;
  }
  
  /* Forms */
  .field { margin-bottom: 16px; }
  .field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
  }
  .field input,
  .field select,
  .field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color .15s;
  }
  .field input:focus,
  .field select:focus,
  .field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
  }
  .field textarea { resize: vertical; min-height: 80px; }
  .field .hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
  }
  .field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  
  /* Dashboard grid */
  .eval-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 20px;
  }
  .eval-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all .15s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .eval-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
  }
  .eval-card h3 {
    font-size: 17px;
    font-weight: 600;
  }
  .eval-card .slug {
    font-size: 12px;
    color: var(--text-muted);
    font-family: ui-monospace, monospace;
  }
  .eval-card .metrics {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
  }
  .eval-card .metrics strong { color: var(--text); }
  .eval-card .footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
  }
  
  /* Badges */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
  }
  .badge-draft { background: #fef3c7; color: #92400e; }
  .badge-active { background: #dcfce7; color: #166534; }
  .badge-success { background: #dcfce7; color: #166534; }
  .badge-danger { background: #fee2e2; color: #991b1b; }
  .badge-info { background: var(--primary-light); color: var(--primary-dark); }
  
  /* Editor */
  .editor-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
  }
  @media (max-width: 900px) {
    .editor-layout { grid-template-columns: 1fr; }
  }
  
  .step-block {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
  }
  .step-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
  }
  .step-title {
    font-size: 16px;
    font-weight: 600;
    border: none;
    background: transparent;
    padding: 4px 8px;
    border-radius: 6px;
    width: 100%;
    font-family: inherit;
    color: var(--text);
  }
  .step-title:hover { background: #f1f5f9; }
  .step-title:focus { outline: none; background: #fff; box-shadow: 0 0 0 2px var(--primary-light); }
  
  .section-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  
  .video-preview {
    margin-top: 10px;
    aspect-ratio: 16/9;
    background: #0f172a;
    border-radius: var(--radius);
    overflow: hidden;
  }
  .video-preview iframe {
    width: 100%;
    height: 100%;
    border: 0;
  }
  
  .question-block {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
  }
  .question-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
  }
  .question-num {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
  }
  .question-text {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    background: #fff;
  }
  .question-text:focus { outline: none; border-color: var(--primary); }
  
  .option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    padding-left: 34px;
  }
  .option-row input[type="text"] {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
  }
  .option-row input[type="text"]:focus { outline: none; border-color: var(--primary); }
  .option-row .correct-toggle {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s;
  }
  .option-row .correct-toggle.on {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
  }
  .option-row .correct-toggle:hover { border-color: var(--success); }
  
  .side-panel {
    position: sticky;
    top: 80px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .side-panel .card { padding: 16px; }
  .side-panel h4 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    margin-bottom: 10px;
  }
  .flow-list {
    list-style: none;
    font-size: 13px;
  }
  .flow-list li {
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .flow-list li:last-child { border-bottom: none; }
  
  /* Results table */
  .table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
  }
  .table th,
  .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
  }
  .table th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
  }
  .table tr:last-child td { border-bottom: none; }
  .table tbody tr:hover { background: #f8fafc; }
  
  /* Empty state */
  .empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
  }
  .empty h3 {
    color: var(--text);
    margin-bottom: 8px;
    font-size: 18px;
  }
  .empty p { margin-bottom: 20px; }
  
  /* Toasts */
  #toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
  }
  .toast {
    padding: 12px 18px;
    border-radius: var(--radius);
    background: #1e293b;
    color: #fff;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideIn .2s ease-out;
    min-width: 200px;
  }
  .toast-success { background: var(--success); }
  .toast-error { background: var(--danger); }
  .toast-info { background: var(--primary); }
  .toast-out { opacity: 0; transform: translateX(20px); transition: all .3s; }
  @keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
  }
  
  /* Modal */
  .modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
  }
  .modal {
    background: #fff;
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 100%;
    padding: 24px;
    box-shadow: var(--shadow-lg);
  }
  .modal h3 { margin-bottom: 12px; }
  .modal .actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
  }
  
  /* Utils */
  .row { display: flex; align-items: center; gap: 12px; }
  .row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .mt-8 { margin-top: 8px; }
  .mt-16 { margin-top: 16px; }
  .mt-24 { margin-top: 24px; }
  .mb-8 { margin-bottom: 8px; }
  .mb-16 { margin-bottom: 16px; }
  .muted { color: var(--text-muted); font-size: 13px; }
  .text-center { text-align: center; }
  .hidden { display: none !important; }