/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
    --bg:         #0d1117;
    --surface:    #161b22;
    --surface-2:  #1c2128;
    --border:     #30363d;
    --primary:    #58a6ff;
    --primary-h:  #79b8ff;
    --success:    #3fb950;
    --warning:    #d29922;
    --danger:     #f85149;
    --muted:      #8b949e;
    --text:       #e6edf3;
    --text-2:     #c9d1d9;
    --sidebar-w:  220px;
    --radius:     8px;
    --shadow:     0 1px 3px rgba(0,0,0,.4);
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-h); }
code { font-family: 'SF Mono', Consolas, 'Liberation Mono', monospace; }

/* ── Layout ─────────────────────────────────────────────────────────────────── */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.25rem 1.1rem;
    color: var(--primary);
    font-weight: 700;
    font-size: .95rem;
    border-bottom: 1px solid var(--border);
    letter-spacing: -.01em;
}

.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .55rem 1.1rem;
    color: var(--text-2);
    font-size: .875rem;
    border-radius: 0;
    transition: background .12s, color .12s;
    border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
    background: rgba(88,166,255,.08);
    color: var(--primary);
    border-left-color: var(--primary);
}
.nav-item svg { flex-shrink: 0; opacity: .8; }

.sidebar-footer {
    padding: 1rem 1.1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: .4rem;
    color: var(--muted);
    font-size: .8rem;
}
.btn-logout {
    display: flex;
    align-items: center;
    gap: .4rem;
    color: var(--muted);
    font-size: .8rem;
    transition: color .12s;
}
.btn-logout:hover { color: var(--danger); }

/* ── Main content ───────────────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    padding: 1.25rem 1.75rem .75rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.page-title { font-size: 1.2rem; font-weight: 600; }

.content { padding: 1.5rem 1.75rem; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.1rem;
    gap: .75rem;
}
.card-title { font-size: 1rem; font-weight: 600; }

/* ── Stats grid ─────────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.4rem;
}
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--muted); font-size: .8rem; margin-top: .2rem; }

/* ── Info grid ──────────────────────────────────────────────────────────────── */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: .75rem 1.5rem;
}
.info-label { display: block; color: var(--muted); font-size: .75rem; margin-bottom: .15rem; }
.info-value { display: block; font-size: .9rem; }

/* ── Table ──────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
.table th {
    text-align: left;
    padding: .55rem .75rem;
    color: var(--muted);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: .65rem .75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .2rem .55rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    line-height: 1.4;
}
.badge-stable     { background: rgba(63,185,80,.15);  color: #3fb950; border: 1px solid rgba(63,185,80,.3); }
.badge-beta       { background: rgba(210,153,34,.15); color: #d29922; border: 1px solid rgba(210,153,34,.3); }
.badge-alpha      { background: rgba(248,81,73,.15);  color: #f85149; border: 1px solid rgba(248,81,73,.3); }
.badge-rc         { background: rgba(88,166,255,.15); color: #58a6ff; border: 1px solid rgba(88,166,255,.3); }
.badge-deprecated { background: rgba(139,148,158,.12); color: #8b949e; border: 1px solid rgba(139,148,158,.3); }
.badge-latest     { background: rgba(63,185,80,.12);  color: #3fb950; border: 1px solid rgba(63,185,80,.25); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: 6px;
    font-size: .875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: center;
    transition: background .12s, border-color .12s, color .12s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--primary);
    color: #0d1117;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); color: #0d1117; }

.btn-outline {
    background: transparent;
    color: var(--text-2);
    border-color: var(--border);
}
.btn-outline:hover { background: var(--surface-2); color: var(--text); border-color: #4d5566; }

.btn-danger {
    background: rgba(248,81,73,.12);
    color: var(--danger);
    border-color: rgba(248,81,73,.3);
}
.btn-danger:hover { background: rgba(248,81,73,.22); }

.btn-sm  { padding: .35rem .75rem; font-size: .8rem; }
.btn-xs  { padding: .2rem .55rem;  font-size: .75rem; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label {
    display: block;
    font-size: .85rem;
    font-weight: 500;
    margin-bottom: .4rem;
    color: var(--text-2);
}
.req { color: var(--danger); }

.form-control {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: .875rem;
    padding: .5rem .75rem;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    font-family: inherit;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(88,166,255,.15);
}
.form-control:disabled { opacity: .5; cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-control-sm { padding: .3rem .6rem; font-size: .8rem; width: auto; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: .75rem 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    color: var(--text-2);
    cursor: pointer;
}
.checkbox-label input { accent-color: var(--primary); width: 15px; height: 15px; }

/* ── Toggle group ───────────────────────────────────────────────────────────── */
.toggle-group {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    width: fit-content;
}
.toggle-btn {
    padding: .45rem .9rem;
    font-size: .85rem;
    color: var(--muted);
    cursor: pointer;
    transition: background .12s, color .12s;
    background: var(--bg);
    display: flex;
    align-items: center;
    gap: .4rem;
    user-select: none;
}
.toggle-btn:not(:last-child) { border-right: 1px solid var(--border); }
.toggle-btn input[type="radio"] { display: none; }
.toggle-btn:has(input:checked) {
    background: rgba(88,166,255,.15);
    color: var(--primary);
}
.toggle-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── File drop ──────────────────────────────────────────────────────────────── */
.file-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.file-drop:hover, .file-drop.drag-over {
    border-color: var(--primary);
    background: rgba(88,166,255,.05);
}
.file-drop-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    gap: .6rem;
    text-align: center;
}
.file-drop-inner p { font-size: .9rem; color: var(--text-2); }
.link-text { color: var(--primary); }
.file-selected-name {
    font-size: .85rem;
    color: var(--success);
    font-weight: 500;
    margin-top: .25rem;
}

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert {
    padding: .75rem 1rem;
    border-radius: 6px;
    font-size: .875rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-success { background: rgba(63,185,80,.1);  color: #3fb950; border-color: rgba(63,185,80,.25); }
.alert-error   { background: rgba(248,81,73,.1);  color: #f85149; border-color: rgba(248,81,73,.25); }
.alert-warning { background: rgba(210,153,34,.1); color: #d29922; border-color: rgba(210,153,34,.25); }
.alert-info    { background: rgba(88,166,255,.1); color: #58a6ff; border-color: rgba(88,166,255,.25); }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; }
    .sidebar-brand { border-bottom: none; border-right: 1px solid var(--border); padding: .75rem 1rem; }
    .sidebar-nav { display: flex; flex-direction: row; padding: .5rem; flex: 1; }
    .nav-item { border-left: none; border-bottom: 2px solid transparent; padding: .5rem .75rem; }
    .nav-item.active { border-bottom-color: var(--primary); border-left-color: transparent; }
    .sidebar-footer { flex-direction: row; align-items: center; padding: .5rem 1rem; border-top: none; border-left: 1px solid var(--border); }
    .content { padding: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
