:root {
    --bg: #050816;
    --bg-elevated: #0b1020;
    --bg-soft: #111827;
    --accent: #22c55e;
    --accent-soft: rgba(34, 197, 94, 0.15);
    --accent-strong: #16a34a;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --border-subtle: #1f2937;
    --danger: #ef4444;
    --warning: #facc15;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.3);
    --transition-fast: 0.15s ease-out;
    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: var(--font-sans);
    background: radial-gradient(circle at top, #1f2937 0, #020617 55%);
    color: var(--text);
}

/* ===== LOGIN ===== */

.login-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top, rgba(59,130,246,0.16), transparent 60%),
                radial-gradient(circle at bottom, rgba(34,197,94,0.16), transparent 60%),
                #020617;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 20;
}

.login-card {
    width: 100%;
    max-width: 460px;
    background: linear-gradient(135deg, rgba(15,23,42,0.95), rgba(12,10,27,0.98));
    border-radius: 24px;
    padding: 1.75rem 1.75rem 1.5rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(148,163,184,0.22);
    backdrop-filter: blur(24px);
}

.login-header {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.login-logo-circle {
    width: 46px;
    height: 46px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 0, #22c55e, #22c55e22 55%, transparent 70%);
    border: 1px solid rgba(34,197,94,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.4rem;
    color: #dcfce7;
}

.login-header h1 {
    font-size: 1.5rem;
    letter-spacing: 0.03em;
}

.login-header p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-bottom: 1rem;
}

.login-form label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.login-form input,
.login-form select {
    margin-top: 0.18rem;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border-radius: 0.9rem;
    border: 1px solid var(--border-subtle);
    background: rgba(15,23,42,0.96);
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.login-form input:focus,
.login-form select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(34,197,94,0.2);
    background: #020617;
}

.login-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.55rem;
}

.login-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.tag {
    font-size: 0.7rem;
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    border: 1px solid rgba(148,163,184,0.4);
    color: var(--text-muted);
}

/* ===== BUTTONS ===== */

.btn {
    border: none;
    border-radius: 999px;
    padding: 0.5rem 1.05rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #022c22;
    box-shadow: 0 14px 30px rgba(34,197,94,0.45);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 40px rgba(34,197,94,0.55);
}

.btn-secondary {
    background: rgba(15,23,42,0.9);
    color: var(--text);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
    border-color: rgba(148,163,184,0.7);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    padding-inline: 0;
}

.btn-xs {
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
}

/* ===== APP SHELL ===== */

.hidden {
    display: none !important;
}

.app-shell {
    display: flex;
    height: 100vh;
    background: radial-gradient(circle at top, rgba(59,130,246,0.16), transparent 60%),
                radial-gradient(circle at bottom, rgba(34,197,94,0.14), transparent 65%),
                #020617;
}

/* Sidebar */

.sidebar {
    width: 250px;
    min-width: 230px;
    background: rgba(15,23,42,0.98);
    backdrop-filter: blur(16px);
    border-right: 1px solid rgba(31,41,55,0.95);
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1.5rem;
}

.sidebar-logo-circle {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: radial-gradient(circle at 25% 0, #22c55e, transparent 70%);
    border: 1px solid rgba(34,197,94,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #dcfce7;
}

.sidebar-title .brand {
    font-weight: 600;
    font-size: 0.95rem;
}

.sidebar-title .brand-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.nav-link {
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-radius: 0.7rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.nav-link:hover {
    background: rgba(15,23,42,0.9);
    color: var(--text);
    transform: translateX(2px);
}

.nav-link.active {
    background: radial-gradient(circle at left top, var(--accent-soft), transparent 70%);
    color: var(--accent);
    border: 1px solid rgba(34,197,94,0.6);
}

.sidebar-footer {
    margin-top: 1rem;
}

/* Main Layout */

.main-layout {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Topbar */

.topbar {
    height: 70px;
    border-bottom: 1px solid rgba(31,41,55,0.95);
    padding: 0.8rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(16px);
    background: linear-gradient(to right, rgba(15,23,42,0.92), rgba(15,23,42,0.86));
}

.topbar-left h2 {
    font-size: 1.1rem;
}

.topbar-left p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.role-badge {
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    border: 1px solid rgba(148,163,184,0.7);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Content */

.content {
    flex: 1;
    padding: 1.25rem 1.5rem 1.5rem;
    overflow-y: auto;
}

/* Cards & Grid */

.card {
    background: rgba(15,23,42,0.95);
    border-radius: var(--radius-lg);
    padding: 1rem 1rem;
    border: 1px solid rgba(31,41,55,0.95);
    box-shadow: 0 10px 30px rgba(15,23,42,0.8);
}

.card h3 {
    margin-bottom: 0.75rem;
    font-size: 1.05rem;
}

.card h4 {
    margin-bottom: 0.5rem;
    font-size: 0.96rem;
}

.grid {
    display: grid;
    gap: 1rem;
}

.grid-2 {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mt-lg {
    margin-top: 1.1rem;
}

/* Metrics */

.metric {
    font-size: 1.7rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.metric-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Activity */

.activity-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    display: inline-block;
    margin-right: 0.4rem;
}

.dot-green { background: var(--accent); }
.dot-blue { background: #3b82f6; }
.dot-yellow { background: var(--warning); }

/* Tables */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.table th,
.table td {
    padding: 0.45rem 0.4rem;
    text-align: left;
    border-bottom: 1px solid rgba(31,41,55,0.9);
    white-space: nowrap;
}

.table th {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.table tbody tr:hover {
    background: rgba(15,23,42,0.85);
}

/* Status Pills */

.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.75rem;
}

.status-green {
    background: rgba(34,197,94,0.16);
    color: #bbf7d0;
}

.status-blue {
    background: rgba(59,130,246,0.14);
    color: #bfdbfe;
}

/* Forms */

.form {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.form-row-inline {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.form label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form input,
.form select {
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: #020617;
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form input:focus,
.form select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(34,197,94,0.25);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.3rem;
}

/* Checkbox */

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

/* Permissions grid */

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.4rem 0.8rem;
    margin-top: 0.15rem;
}

/* Views */

.view {
    display: none;
}

.view.active {
    display: block;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6rem;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 960px) {
    .sidebar {
        display: none;
    }
    .app-shell {
        flex-direction: column;
    }
    .topbar {
        padding-inline: 1rem;
    }
    .content {
        padding-inline: 1rem;
    }
    .grid-2,
    .grid-3 {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .login-card {
        padding: 1.25rem 1.1rem;
    }
    .login-header h1 {
        font-size: 1.25rem;
    }
    .login-header p {
        font-size: 0.8rem;
    }
    .login-footer {
        flex-direction: column;
        align-items: stretch;
    }
}
