:root {
    --bg: #0c0d10;
    --bg-elev: #16181d;
    --bg-input: #1c1f25;
    --border: #262a31;
    --border-strong: #353a44;
    --text: #e8e9ed;
    --text-dim: #9aa0aa;
    --text-mute: #6b7280;
    --accent: #7c5cff;
    --accent-hover: #8a6cff;
    --danger: #ef4444;
    --success: #10b981;
    --warn: #f59e0b;
    --radius: 10px;
    --radius-sm: 6px;
    --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #fafbfc;
        --bg-elev: #ffffff;
        --bg-input: #f4f5f7;
        --border: #e5e7eb;
        --border-strong: #d1d5db;
        --text: #111827;
        --text-dim: #4b5563;
        --text-mute: #9ca3af;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.muted { color: var(--text-dim); font-size: 13px; }

/* Topbar */
.topbar {
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
}
.topbar-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 24px;
}
.brand { font-weight: 600; color: var(--text); font-size: 15px; }
.brand:hover { text-decoration: none; }
.topbar nav { flex: 1; display: flex; gap: 18px; }
.topbar nav a { color: var(--text-dim); font-size: 13px; }
.topbar nav a:hover { color: var(--text); text-decoration: none; }
.logout { margin: 0; }
.logout button {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
}
.logout button:hover { background: var(--bg-input); color: var(--text); }

/* Container */
.container {
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 20px 40px;
    flex: 1;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
}

/* Buttons */
.btn-primary, button.btn-primary {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary:hover { background: var(--accent-hover); color: white; text-decoration: none; }

/* Forms */
form label {
    display: block;
    margin-bottom: 14px;
}
form label span {
    display: block;
    color: var(--text-dim);
    font-size: 12px;
    margin-bottom: 5px;
}
input[type=text], input[type=email], input[type=password], textarea, select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Auth */
.auth-shell {
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 360px;
}
.auth-card h1 { margin-bottom: 2px; }
.auth-card .muted { margin-bottom: 24px; }
.auth-card .btn-primary { width: 100%; padding: 10px; margin-top: 8px; }

/* Flash */
.flash-stack { margin-bottom: 20px; }
.flash {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    font-size: 13px;
}
.flash-error { background: rgba(239, 68, 68, 0.08); border-color: rgba(239, 68, 68, 0.3); color: var(--danger); }
.flash-success { background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.3); color: var(--success); }
.flash-info { background: var(--bg-input); }

/* Projects */
.project-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elev);
}
.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.project-item:last-child { border-bottom: none; }
.project-title { color: var(--text); font-weight: 500; font-size: 14px; }
.project-title:hover { text-decoration: none; color: var(--accent); }
.project-meta { font-size: 12px; color: var(--text-dim); margin-top: 3px; }
.project-meta code { background: var(--bg-input); padding: 1px 6px; border-radius: 3px; }
.project-actions a { font-size: 13px; }

.tag {
    display: inline-block;
    padding: 1px 7px;
    font-size: 11px;
    border-radius: 3px;
    background: var(--bg-input);
    color: var(--text-dim);
}
.tag-off { color: var(--warn); background: rgba(245, 158, 11, 0.1); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
}
.empty-state p { margin: 0 0 16px; }

/* Cards */
.card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 18px;
}
.card h2 { margin-top: 0; }
.card.danger-zone { border-color: rgba(239, 68, 68, 0.4); }
.card.danger-zone h2 { color: var(--danger); }

/* Forms — extended */
.form-stack > label,
.form-stack > fieldset { margin-bottom: 16px; }
.form-stack > label:last-of-type,
.form-stack > fieldset:last-of-type { margin-bottom: 0; }
.form-stack textarea { resize: vertical; min-height: 60px; }
.form-stack small { display: block; margin-top: 4px; font-size: 11px; }
.form-stack code { background: var(--bg-input); padding: 1px 5px; border-radius: 3px; font-size: 0.92em; }
.form-stack code strong { color: var(--accent); }

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

/* Radio groups */
fieldset.radio-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px 8px;
    background: var(--bg-input);
}
fieldset.radio-group legend {
    font-size: 12px;
    color: var(--text-dim);
    padding: 0 6px;
}
label.radio {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    padding: 6px 4px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}
label.radio:hover { background: var(--bg); }
label.radio input { margin-top: 3px; }
label.radio span { flex: 1; font-size: 13px; }
label.radio strong { font-weight: 500; }

label.checkbox-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin: 0;
}
label.checkbox-inline span { font-size: 13px; }

/* Buttons — extended */
.btn-ghost {
    display: inline-block;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
    font-family: inherit;
}
.btn-ghost:hover { background: var(--bg-input); color: var(--text); text-decoration: none; }

.btn-danger {
    display: inline-block;
    background: var(--danger);
    color: white;
    border: none;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}
.btn-danger:hover { background: #dc2626; }

/* Page header actions */
.page-header-actions {
    display: flex;
    gap: 8px;
}

/* Upload */
.upload-drop {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 30px 20px;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}
.upload-drop.dragover { border-color: var(--accent); background: rgba(124, 92, 255, 0.05); }
.upload-cta { margin: 0 0 8px; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; }
.upload-hint { font-size: 12px; margin: 0; }

.upload-summary { margin-top: 16px; font-size: 13px; }
.upload-file-list {
    list-style: none;
    padding: 8px;
    margin: 8px 0 0;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    max-height: 280px;
    overflow-y: auto;
    font-size: 12px;
}
.upload-file-list li {
    padding: 3px 4px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.upload-file-list code {
    font-size: 12px;
    background: transparent;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-progress { margin-top: 16px; }
.progress-bar {
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.2s;
}
#progress-text { margin: 8px 0 0; font-size: 12px; }

.upload-result { margin-top: 12px; }

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-mute);
    border-top: 1px solid var(--border);
}
