:root {
    --bg: #0f1419;
    --panel: #1a212b;
    --panel-2: #232c38;
    --border: #2d3848;
    --text: #e6edf3;
    --muted: #8a96a4;
    --accent: #4a9eff;
    --ok: #3fb950;
    --warn: #fbbf24;
    --err: #f85149;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login {
    background: var(--panel); padding: 32px; border-radius: 12px;
    border: 1px solid var(--border); min-width: 320px; display: flex;
    flex-direction: column; gap: 12px;
}
.login h1 { margin: 0 0 8px 0; }
input, textarea, select {
    width: 100%; padding: 10px 12px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
    font-family: inherit; font-size: 14px;
}
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Topbar */
.topbar {
    display: flex; align-items: center; gap: 24px;
    padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
    padding: 6px 14px; border-radius: 6px; color: var(--muted);
}
.topbar nav a.on, .topbar nav a:hover {
    color: var(--text); background: var(--panel-2); text-decoration: none;
}
.signout { color: var(--muted); }

/* Layout */
.wrap { max-width: 1400px; margin: 24px auto; padding: 0 24px; display: flex; flex-direction: column; gap: 16px; }
.card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px; padding: 20px;
}
.card h2 { margin: 0 0 12px 0; font-size: 16px; }
.card-head {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    margin-bottom: 12px; flex-wrap: wrap;
}
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.row-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.row-form input, .row-form select { flex: 1; min-width: 140px; width: auto; }
label.block { display: block; margin-bottom: 12px; }
label.block input, label.block textarea { margin-top: 4px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border);
    vertical-align: top;
}
th { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Buttons */
button, .btn-link {
    padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--panel-2); color: var(--text); cursor: pointer;
    font-size: 13px; font-family: inherit;
}
button:hover, .btn-link:hover { border-color: var(--accent); }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { filter: brightness(1.1); }
.danger { color: var(--err); border-color: rgba(248,81,73,0.3); }
.danger:hover { background: rgba(248,81,73,0.1); }
.actions form { display: inline; }
.actions button { padding: 4px 8px; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 6px; }
.alert.ok  { background: rgba(63,185,80,0.12); color: var(--ok); border: 1px solid rgba(63,185,80,0.3); }
.alert.err { background: rgba(248,81,73,0.12); color: var(--err); border: 1px solid rgba(248,81,73,0.3); }

/* Pills */
.pill {
    display: inline-block; padding: 2px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 500; text-transform: lowercase;
}
.pill-pending, .pill-idle { background: rgba(138,150,164,0.15); color: var(--muted); }
.pill-fetching, .pill-running, .pill-queued, .pill-batch_running { background: rgba(251,191,36,0.15); color: var(--warn); }
.pill-fetched, .pill-done, .pill-ok { background: rgba(63,185,80,0.15); color: var(--ok); }
.pill-failed { background: rgba(248,81,73,0.15); color: var(--err); }

/* Misc */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err-text { color: var(--err); }
.ai-output {
    white-space: pre-wrap; word-wrap: break-word;
    background: var(--panel-2); padding: 12px; border-radius: 6px;
    margin: 6px 0 0 0; max-height: 400px; overflow-y: auto;
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px;
}
.output-cell details > summary { cursor: pointer; padding: 4px 0; }
.hidden { display: none; }
.progress {
    background: rgba(74,158,255,0.12); color: var(--accent);
    padding: 10px 14px; border-radius: 6px; border: 1px solid rgba(74,158,255,0.3);
    margin-bottom: 12px; font-weight: 500;
}
code {
    background: var(--panel-2); padding: 1px 5px;
    border-radius: 4px; font-size: 12px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}
