:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-alt: #eef1f8;
    --border: #dde3ee;
    --text: #16213a;
    --text-muted: #5c6a85;
    --accent: #2262e8;
    --accent-text: #ffffff;
    --danger: #d64545;
    --success: #1d9e75;
    --sidebar-bg: #131c2e;
    --sidebar-text: #cdd6e8;
    --sidebar-active: #2262e8;
}

[data-theme="dark"] {
    --bg: #0e1525;
    --surface: #131c2e;
    --surface-alt: #182035;
    --border: rgba(255,255,255,.08);
    --text: #e8edf7;
    --text-muted: #8d9ab5;
    --accent: #2262e8;
    --accent-text: #ffffff;
    --danger: #e08080;
    --success: #34d399;
    --sidebar-bg: #0a0f1c;
    --sidebar-text: #8d9ab5;
    --sidebar-active: #2262e8;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Arial, sans-serif;
    min-height: 100vh;
}

a { color: inherit; }

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

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform .2s ease;
}

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

.sidebar-backdrop { display: none; }

.sidebar-logo {
    padding: 0 8px 24px;
}

.sidebar-logo img { height: 28px; }

.sidebar-section-label {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 600;
    padding: 16px 12px 6px;
}

.sidebar a.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 6px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
}

.sidebar a.nav-item:hover { background: rgba(255,255,255,.06); }
.sidebar a.nav-item.active { background: var(--sidebar-active); color: #fff; }
.sidebar a.nav-item i { font-size: 17px; width: 18px; text-align: center; }

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.theme-toggle {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.content { padding: 32px; max-width: 1100px; }

h1 { font-size: 22px; font-weight: 500; margin-bottom: 6px; }
.page-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}

.card-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; }
.card-desc { color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin: 14px 0 6px;
}

input[type=text], input[type=password], input[type=email], input[type=file], select {
    width: 100%;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 14px;
    padding: 10px 14px;
    outline: none;
    font-family: inherit;
}

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

button, .btn {
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: var(--accent-text);
    font-size: 13px;
    font-weight: 600;
    padding: 9px 18px;
    cursor: pointer;
    display: inline-block;
    text-decoration: none;
}

button:hover, .btn:hover { opacity: .9; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-danger { background: var(--danger); }

.notice {
    background: rgba(52,211,153,.12);
    border: 1px solid rgba(52,211,153,.3);
    color: var(--success);
    font-size: 13px;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 20px;
}

.error {
    background: rgba(224,85,85,.12);
    border: 1px solid rgba(224,85,85,.3);
    color: var(--danger);
    font-size: 13px;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 20px;
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.badge-admin { background: rgba(127,119,221,.15); color: #9b93e8; }
.badge-member { background: rgba(92,106,133,.15); color: var(--text-muted); }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; }
.checkbox-row label { text-transform: none; font-weight: 400; font-size: 13px; color: var(--text); margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.stat-value { font-size: 26px; font-weight: 600; }
.stat-label { color: var(--text-muted); font-size: 12px; margin-top: 4px; }

.app-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; }

.app-card {
    display: block;
    width: 240px;
    aspect-ratio: 3 / 4;
    border-radius: 16px;
    overflow: hidden;
    background: var(--sidebar-bg);
    border: 1px solid var(--border);
    box-shadow: 0 6px 18px rgba(0,0,0,.14);
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}
.app-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 32px rgba(0,0,0,.24);
}
.app-card img.app-card-bg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

@media (max-width: 900px) {
    .hamburger { display: inline-block; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 40;
        transform: translateX(-100%);
        box-shadow: 2px 0 20px rgba(0,0,0,.3);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 30;
    }
    .content { padding: 20px; }
    .topbar { padding: 14px 16px; }
    .topbar-user span { display: none; }
    .app-card { width: 100%; max-width: 320px; }
}

.action-links a { font-size: 12.5px; color: var(--accent); text-decoration: none; margin-right: 12px; }
.action-links a.danger { color: var(--danger); }

.tabs-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.tab-btn { padding: 10px 16px; background: none; border: none; color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
