:root {
    --bg: #070b10;
    --bg-elevated: #0f141c;
    --bg-elevated-soft: #111827;
    --border-subtle: rgba(148, 163, 184, 0.18);
    --accent: #38bdf8;
    --accent-soft: rgba(56, 189, 248, 0.12);
    --accent-strong: #0ea5e9;
    --danger: #f97373;
    --danger-soft: rgba(239, 68, 68, 0.1);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.1);
    --text: #e5e7eb;
    --text-soft: #9ca3af;
    --muted: #6b7280;
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.9);
    --radius-lg: 18px;
    --radius-xl: 22px;
    --radius-pill: 999px;
}

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

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: radial-gradient(circle at top, #111827, #020617);
}

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

/* Layout */
.portal-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    width: 100%;
    max-width: 1400px;
    margin: 18px auto;
    padding: 0 12px;
    gap: 16px;
}

/* Sidebar */
.portal-sidebar {
    background: linear-gradient(145deg, rgba(15,23,42,0.98), rgba(15,23,42,0.94));
    border-radius: var(--radius-xl);
    padding: 18px 16px 14px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(148, 163, 184, 0.25);
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: relative;
    overflow: hidden;
}

.portal-sidebar::before {
    content: "";
    position: absolute;
    inset: -60%;
    background: radial-gradient(circle at 0% 0%, rgba(248, 250, 252, 0.05), transparent 55%);
    opacity: 0.9;
    pointer-events: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.45), 0 16px 32px rgba(15, 23, 42, 0.9);
}

.sidebar-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-brand {
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-size: 0.82rem;
}

.sidebar-subtitle {
    font-size: 0.74rem;
    color: var(--muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    z-index: 1;
}

.nav-section-label {
    margin-top: 8px;
    margin-bottom: 2px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.nav-link {
    display: block;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.83rem;
    color: var(--text-soft);
    text-decoration: none;
    position: relative;
    transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.nav-link:hover {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text);
    transform: translateX(1px);
}

.nav-link.active {
    background: radial-gradient(circle at 0% 50%, var(--accent-strong), #4f46e5);
    color: #f9fafb;
    box-shadow: 0 10px 32px rgba(56, 189, 248, 0.45);
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.user-pill {
    padding: 8px 10px;
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.35);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-size: 0.82rem;
    font-weight: 600;
}

.user-meta {
    font-size: 0.74rem;
    color: var(--muted);
}

/* Main */
.portal-main {
    background: radial-gradient(circle at top left, rgba(56,189,248,0.12), transparent 65%), radial-gradient(circle at bottom right, rgba(244,63,94,0.12), transparent 60%), linear-gradient(145deg, rgba(15,23,42,0.98), rgba(15,23,42,0.96));
    border-radius: var(--radius-xl);
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: var(--shadow-soft);
    padding: 18px 18px 16px;
    position: relative;
    overflow: hidden;
}

.portal-main::before {
    content: "";
    position: absolute;
    inset: -40%;
    background: radial-gradient(circle at 0% 0%, rgba(248, 250, 252, 0.05), transparent 50%);
    opacity: 0.8;
    pointer-events: none;
}

/* Cards */
.card {
    position: relative;
    background: rgba(15, 23, 42, 0.96);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(148, 163, 184, 0.25);
    padding: 14px 14px 12px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.9);
    margin-bottom: 14px;
}

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

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

.card-subtitle {
    font-size: 0.8rem;
    color: var(--muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.4);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
}

/* Buttons */
.btn {
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 6px 14px;
    font-size: 0.8rem;
    line-height: 1.3;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.08s ease, box-shadow 0.16s ease;
    font-weight: 500;
}

.btn-primary {
    background: radial-gradient(circle at 0% 50%, var(--accent), var(--accent-strong));
    border-color: rgba(56, 189, 248, 0.9);
    color: #f9fafb;
    box-shadow: 0 10px 32px rgba(59, 130, 246, 0.45);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 40px rgba(59, 130, 246, 0.6);
}

.btn-outline {
    background: transparent;
    border-color: rgba(148, 163, 184, 0.65);
    color: var(--text);
}

.btn-outline:hover {
    background: rgba(148, 163, 184, 0.12);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-soft);
}

.btn-ghost:hover {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text);
}

.btn-sm,
.btn-small {
    padding: 4px 10px;
    font-size: 0.75rem;
}

/* Forms */
.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.field span,
.field label {
    font-size: 0.78rem;
    color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
textarea,
select {
    width: 100%;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(15, 23, 42, 0.85);
    color: var(--text);
    padding: 6px 8px;
    font-size: 0.8rem;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.7);
    background: rgba(15, 23, 42, 0.95);
}

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

.field-hint {
    font-size: 0.72rem;
    color: var(--muted);
}

/* Grids & tables */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px 12px;
}

.table-wrapper {
    margin-top: 6px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    overflow: hidden;
    background: rgba(15, 23, 42, 0.9);
}

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

thead {
    background: rgba(15, 23, 42, 0.98);
}

th, td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(31, 41, 55, 0.9);
}

th {
    text-align: left;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

tr:nth-child(even) td {
    background: rgba(15, 23, 42, 0.96);
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.input-small {
    min-width: 90px;
    max-width: 120px;
}

/* Alerts */
.alert {
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.78rem;
    margin-bottom: 8px;
    display: inline-flex;
    align-items: center;
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid rgba(74, 222, 128, 0.7);
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.9);
}

/* Auth layout */
body.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 12px;
    background: radial-gradient(circle at top, #0b1120, #020617);
}

.auth-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.08), transparent 60%), radial-gradient(circle at bottom right, rgba(244, 63, 94, 0.12), transparent 55%), linear-gradient(145deg, rgba(15,23,42,0.98), rgba(15,23,42,0.96));
    border-radius: 22px;
    padding: 20px 18px 18px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.auth-header {
    margin-bottom: 10px;
}

.portal-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.portal-logo-img {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    box-shadow: 0 0 0 1px rgba(148, 163, 184, 0.45), 0 16px 36px rgba(15, 23, 42, 0.95);
}

.portal-logo-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.portal-logo-title {
    font-size: 0.96rem;
    font-weight: 600;
}

.portal-logo-subtitle {
    font-size: 0.76rem;
    color: var(--muted);
}

.auth-form {
    margin-top: 8px;
}

.auth-suboptions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
}

.auth-subtext {
    color: var(--muted);
}

.auth-subtext a {
    color: var(--accent);
    text-decoration: none;
}

.auth-subtext a:hover {
    text-decoration: underline;
}

/* Snow overlay */
.snow-overlay {
    pointer-events: none;
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(2px 2px at 20% 20%, rgba(248, 250, 252, 0.75), transparent),
        radial-gradient(2px 2px at 80% 30%, rgba(248, 250, 252, 0.6), transparent),
        radial-gradient(2px 2px at 40% 80%, rgba(248, 250, 252, 0.7), transparent),
        radial-gradient(2px 2px at 60% 10%, rgba(248, 250, 252, 0.5), transparent),
        radial-gradient(2px 2px at 90% 70%, rgba(248, 250, 252, 0.8), transparent);
    opacity: 0.5;
    animation: snow-fall 16s linear infinite;
}

@keyframes snow-fall {
    from { transform: translateY(-10px); }
    to   { transform: translateY(10px); }
}

/* Responsive */
@media (max-width: 900px) {
    .portal-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .portal-sidebar {
        display: none;
    }
    .portal-main {
        margin-top: 24px;
    }
}
