/* ─── Hub Lunna – Design System ─────────────────────────────────── */

:root {
    --bg:        #0d0f14;
    --surface:   #141720;
    --surface2:  #1c2030;
    --border:    #252a3a;
    --accent:    #7c5cfc;
    --accent-h:  #6344e0;
    --accent-g:  linear-gradient(135deg, #7c5cfc 0%, #b06ef3 100%);
    --success:   #22c55e;
    --danger:    #ef4444;
    --warning:   #f59e0b;
    --info:      #38bdf8;
    --text:      #e2e8f0;
    --text-muted:#8892a4;
    --text-faint:#4a5568;
    --radius:    10px;
    --radius-lg: 16px;
    --sidebar-w: 240px;
    --shadow:    0 4px 24px rgba(0,0,0,.4);
}

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

html { font-size: 15px; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

/* ─── Layout ─────────────── */

.layout {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ────────────── */

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar__logo {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar__logo-mark {
    width: 36px; height: 36px;
    background: var(--accent-g);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .85rem; color: #fff;
    flex-shrink: 0;
}

.sidebar__logo-name {
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.sidebar__logo-sub {
    font-size: .68rem;
    color: var(--text-muted);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.sidebar__nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.nav-section {
    padding: 0 12px;
    margin-bottom: 4px;
}

.nav-section__label {
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-faint);
    padding: 10px 8px 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: .875rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    cursor: pointer;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--surface2);
    color: var(--text);
}

.nav-item.active {
    background: rgba(124,92,252,.15);
    color: var(--accent);
}

.nav-item svg { flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }

.sidebar__footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius);
    background: var(--surface2);
}

.user-chip__avatar {
    width: 32px; height: 32px;
    background: var(--accent-g);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.user-chip__name { font-size: .8rem; font-weight: 600; line-height: 1.2; }
.user-chip__role { font-size: .68rem; color: var(--text-muted); }

.user-chip__logout {
    margin-left: auto;
    color: var(--text-faint);
    transition: color .15s;
}
.user-chip__logout:hover { color: var(--danger); }

/* ─── Main content ───────── */

.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 60px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 50;
}

.topbar__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.topbar__spacer { flex: 1; }

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.content {
    padding: 28px;
    flex: 1;
}

/* ─── Page header ──────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
}

.page-header p {
    font-size: .85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ─── Cards ──────────────── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

/* ─── Stats grid ─────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent-g);
}

.stat-card__icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: rgba(124,92,252,.12);
    display: flex; align-items: center; justify-content: center;
    color: var(--accent);
}

.stat-card__value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.stat-card__label {
    font-size: .78rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ─── Tables ─────────────── */

.table-wrap { overflow-x: auto; }

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

thead th {
    text-align: left;
    padding: 10px 14px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-faint);
    border-bottom: 1px solid var(--border);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .12s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

td {
    padding: 12px 14px;
    vertical-align: middle;
}

/* ─── Badges ─────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .03em;
}

.badge-green  { background: rgba(34,197,94,.12);  color: var(--success); }
.badge-red    { background: rgba(239,68,68,.12);   color: var(--danger);  }
.badge-yellow { background: rgba(245,158,11,.12);  color: var(--warning); }
.badge-blue   { background: rgba(56,189,248,.12);  color: var(--info);    }
.badge-purple { background: rgba(124,92,252,.12);  color: var(--accent);  }
.badge-gray   { background: rgba(139,148,158,.12); color: var(--text-muted); }

/* ─── Buttons ────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity .15s, transform .1s;
    white-space: nowrap;
}

.btn:active { transform: scale(.98); }

.btn-primary  { background: var(--accent-g); color: #fff; }
.btn-primary:hover { opacity: .9; color: #fff; }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }

.btn-danger { background: rgba(239,68,68,.12); color: var(--danger); border: 1px solid rgba(239,68,68,.25); }
.btn-danger:hover { background: rgba(239,68,68,.2); color: var(--danger); }

.btn-sm { padding: 5px 10px; font-size: .78rem; border-radius: 7px; }

.btn-icon {
    width: 32px; height: 32px;
    padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 7px;
}

/* ─── Forms ──────────────── */

.form-group { margin-bottom: 18px; }

label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

input, select, textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px;
    color: var(--text);
    font-size: .875rem;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
}

textarea { resize: vertical; min-height: 90px; }

select option { background: var(--surface); }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

/* ─── Alerts ─────────────── */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 20px;
}

.alert-success { background: rgba(34,197,94,.1);  border: 1px solid rgba(34,197,94,.25);  color: var(--success); }
.alert-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.25);  color: var(--danger); }
.alert-info    { background: rgba(56,189,248,.1);  border: 1px solid rgba(56,189,248,.25); color: var(--info); }

/* ─── Search bar ─────────── */

.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-bar input { max-width: 320px; }

/* ─── Pagination ─────────── */

.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px; height: 34px;
    border-radius: 7px;
    font-size: .8rem;
    font-weight: 600;
    border: 1px solid var(--border);
    color: var(--text-muted);
    transition: background .15s;
    padding: 0 8px;
}

.pagination a:hover { background: var(--surface2); color: var(--text); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── Code / mono ─────────── */

code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: .82rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 2px 7px;
    border-radius: 5px;
    color: var(--accent);
}

/* ─── Auth page ──────────── */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(ellipse at 30% 40%, rgba(124,92,252,.08) 0%, transparent 60%),
                var(--bg);
}

.auth-box {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.auth-logo__mark {
    width: 44px; height: 44px;
    background: var(--accent-g);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1rem; color: #fff;
}

.auth-logo__text h1 { font-size: 1.2rem; font-weight: 800; }
.auth-logo__text p  { font-size: .75rem; color: var(--text-muted); }

/* ─── Empty state ─────────── */

.empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
}

.empty-state svg { opacity: .3; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ─── Versions list ────────── */

.version-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.version-item:last-child { border-bottom: none; }

.version-tag {
    font-family: monospace;
    font-size: .8rem;
    background: rgba(124,92,252,.12);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 5px;
    border: 1px solid rgba(124,92,252,.2);
    white-space: nowrap;
}

/* ─── Log action colors ───── */

.log-verify_ok     { color: var(--success); }
.log-verify_failed { color: var(--danger); }
.log-verify_expired{ color: var(--warning); }
.log-update_check  { color: var(--info); }
.log-download      { color: var(--accent); }
.log-update_available { color: var(--success); }

/* ─── Upload zone ─────────── */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent);
    background: rgba(124,92,252,.04);
}

.upload-zone p { color: var(--text-muted); font-size: .85rem; margin-top: 6px; }
.upload-zone input[type="file"] { display: none; }

/* ─── Responsive ─────────── */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow);
    }
    .main { margin-left: 0; }
    .hamburger { display: flex; }
    .content { padding: 16px; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
