/* ═══════════════════════════════════════════════════════════
   Notenverwaltung FOM  ·  Premium Design System
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg: #0B0F19;
    --bg-secondary: #111827;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.07);
    --surface-active: rgba(255, 255, 255, 0.10);
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
    --accent: #E20074;
    --accent-light: #FF2D95;
    --accent-dark: #B8005E;
    --accent-glow: rgba(226, 0, 116, 0.25);
    --text: #F9FAFB;
    --text-secondary: rgba(249, 250, 251, 0.55);
    --text-muted: rgba(249, 250, 251, 0.30);
    --success: #10B981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --warning: #F59E0B;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --error: #EF4444;
    --error-bg: rgba(239, 68, 68, 0.12);
    --info: #3B82F6;
    --info-bg: rgba(59, 130, 246, 0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --transition: all .25s cubic-bezier(.4, 0, .2, 1);
    --shadow: 0 8px 32px rgba(0, 0, 0, .45);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .3);
    --sidebar-w: 280px;
    --grade-excellent: #10B981;
    --grade-good: #06B6D4;
    --grade-ok: #F59E0B;
    --grade-pass: #F97316;
    --grade-fail: #EF4444;
}

/* ═══════════════ LIGHT MODE ═══════════════ */
[data-theme="light"] {
    --bg: #F0F2F5;
    --bg-secondary: #FFFFFF;
    --surface: rgba(0, 0, 0, 0.04);
    --surface-hover: rgba(0, 0, 0, 0.07);
    --surface-active: rgba(0, 0, 0, 0.10);
    --glass: rgba(0, 0, 0, 0.02);
    --glass-border: rgba(0, 0, 0, 0.10);
    --text: #111827;
    --text-secondary: rgba(17, 24, 39, 0.60);
    --text-muted: rgba(17, 24, 39, 0.35);
    --shadow: 0 8px 32px rgba(0, 0, 0, .15);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, .10);
}

[data-theme="light"] .sidebar {
    background: rgba(255, 255, 255, .95);
    border-right-color: rgba(0, 0, 0, .08);
}

[data-theme="light"] .mobile-header {
    background: rgba(255, 255, 255, .97);
    border-bottom-color: rgba(0, 0, 0, .08);
}

[data-theme="light"] .login-card {
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .12), inset 0 1px 0 rgba(255, 255, 255, 1);
}

[data-theme="light"] .modal-card {
    box-shadow: 0 24px 80px rgba(0, 0, 0, .18);
}

[data-theme="light"] tbody td {
    border-bottom-color: rgba(0, 0, 0, .04);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .15);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, .25);
}

[data-theme="light"] .login-logo h1 {
    background: linear-gradient(135deg, #111827 0%, rgba(17, 24, 39, .7) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

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

a:hover {
    text-decoration: underline;
}

input,
select,
textarea,
button {
    font-family: inherit;
}

/* ───── scrollbar ───── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .12);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, .2);
}

/* ═══════════════ ANIMATIONS ═══════════════ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(18px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.animate {
    animation: fadeIn .5s ease both;
}

.animate-delay-1 {
    animation-delay: .08s;
}

.animate-delay-2 {
    animation-delay: .15s;
}

.animate-delay-3 {
    animation-delay: .22s;
}

.animate-delay-4 {
    animation-delay: .30s;
}

/* ═══════════════ LOGIN PAGE ═══════════════ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 20% 50%, rgba(226, 0, 116, .08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(59, 130, 246, .06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(139, 92, 246, .05) 0%, transparent 50%);
    animation: gradientShift 15s ease infinite;
    background-size: 200% 200%;
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: rgba(17, 24, 39, .65);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem 2.5rem;
    animation: fadeInScale .6s ease both;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .05);
}

.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.login-logo img {
    height: 56px;
    width: 56px;
    object-fit: cover;
    border-radius: 14px;
    margin-bottom: 1.2rem;
    box-shadow: 0 4px 16px rgba(226, 0, 116, .35);
}

.login-logo h1 {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -.5px;
    background: linear-gradient(135deg, var(--text) 0%, rgba(249, 250, 251, .7) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-logo .subtitle {
    font-size: .82rem;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: .5px;
    text-transform: uppercase;
    margin-top: .3rem;
}

/* ───── remember-me checkbox ───── */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    cursor: pointer;
    font-size: .85rem;
    color: var(--text-secondary);
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--glass-border);
    border-radius: 5px;
    background: var(--surface);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--accent);
    border-color: var(--accent);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '';
    display: block;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translateY(-1px);
}

.checkbox-label:hover .checkbox-custom {
    border-color: var(--accent);
}

/* ───── tabs ───── */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 1.8rem;
}

.tab {
    flex: 1;
    padding: .65rem 1rem;
    text-align: center;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, .04);
}

.tab.active {
    color: var(--text);
    background: var(--accent);
    box-shadow: 0 4px 16px var(--accent-glow);
}

/* ───── form elements ───── */
.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .45rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-input {
    width: 100%;
    padding: .8rem 1rem;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: .92rem;
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--surface-hover);
}

.form-input::placeholder {
    color: var(--text-muted);
}

select.form-input {
    cursor: pointer;
}

select.form-input option {
    background: var(--bg-secondary);
    color: var(--text);
}

/* ───── buttons ───── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .75rem 1.5rem;
    font-size: .88rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    color: #fff;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(226, 0, 116, .4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-block {
    width: 100%;
}

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

.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, .15);
}

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

.btn-danger:hover {
    background: rgba(239, 68, 68, .2);
}

.btn-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, .2);
}

.btn-success:hover {
    background: rgba(16, 185, 129, .2);
}

.btn-sm {
    padding: .45rem .9rem;
    font-size: .8rem;
    border-radius: var(--radius-xs);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* ═══════════════ LAYOUT ═══════════════ */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ───── sidebar ───── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: rgba(17, 24, 39, .7);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    animation: slideRight .4s ease both;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .5rem .6rem;
    margin-bottom: 2rem;
}

.sidebar-brand img {
    height: 38px;
    width: 38px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(226, 0, 116, .3);
}

.sidebar-brand-text h3 {
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: -.3px;
    line-height: 1.2;
}

.sidebar-brand-text span {
    font-size: .65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem .9rem;
    border-radius: var(--radius-sm);
    font-size: .88rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

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

.nav-item.active {
    background: linear-gradient(135deg, rgba(226, 0, 116, .15) 0%, rgba(226, 0, 116, .05) 100%);
    color: var(--accent-light);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}

.nav-item {
    position: relative;
}

.nav-divider {
    height: 1px;
    background: var(--glass-border);
    margin: .8rem 0;
}

.sidebar-footer {
    padding: .8rem;
    border-top: 1px solid var(--glass-border);
    margin-top: 1rem;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .5rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
    color: #fff;
    flex-shrink: 0;
}

.user-info {
    overflow: hidden;
}

.user-info .name {
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .role {
    font-size: .7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ───── main ───── */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 2rem 2.5rem;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 2rem;
    animation: fadeIn .5s ease both;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -.5px;
    margin-bottom: .3rem;
}

.page-header p {
    color: var(--text-secondary);
    font-size: .92rem;
}

/* ═══════════════ CARDS ═══════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(255, 255, 255, .12);
}

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

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 700;
}

.card-header h3 {
    font-size: .95rem;
    font-weight: 600;
}

/* ───── KPI cards ───── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.3rem 1.5rem;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--kpi-color, var(--accent));
    border-radius: var(--radius) var(--radius) 0 0;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.kpi-icon {
    font-size: 1.5rem;
    margin-bottom: .6rem;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1;
    margin-bottom: .3rem;
}

.kpi-label {
    font-size: .78rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ═══════════════ TABLE ═══════════════ */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--glass-border);
}

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

thead th {
    background: var(--surface);
    padding: .85rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
}

tbody td {
    padding: .75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .03);
    transition: var(--transition);
}

tbody tr:hover td {
    background: var(--surface-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* grade badge */
.grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .25rem .65rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: .82rem;
    min-width: 48px;
}

.grade-excellent {
    background: rgba(16, 185, 129, .15);
    color: var(--grade-excellent);
}

.grade-good {
    background: rgba(6, 182, 212, .15);
    color: var(--grade-good);
}

.grade-ok {
    background: rgba(245, 158, 11, .15);
    color: var(--grade-ok);
}

.grade-pass {
    background: rgba(249, 115, 22, .15);
    color: var(--grade-pass);
}

.grade-fail {
    background: rgba(239, 68, 68, .15);
    color: var(--grade-fail);
}

/* ═══════════════ GRID HELPERS ═══════════════ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

.flex {
    display: flex;
}

.gap-sm {
    gap: .5rem;
}

.gap-md {
    gap: 1rem;
}

.gap-lg {
    gap: 1.5rem;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.mt-1 {
    margin-top: .5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: .5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

/* ═══════════════ TOAST ═══════════════ */
#toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.toast {
    padding: .85rem 1.2rem;
    border-radius: var(--radius-sm);
    font-size: .85rem;
    font-weight: 500;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: fadeIn .3s ease both;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: .6rem;
    box-shadow: var(--shadow);
}

.toast-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, .2);
}

.toast-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, .2);
}

.toast-info {
    background: var(--info-bg);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, .2);
}

.toast.fade-out {
    opacity: 0;
    transform: translateY(-10px);
    transition: all .3s ease;
}

/* ═══════════════  MODAL ═══════════════ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn .2s ease both;
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 2rem;
    min-width: 380px;
    max-width: 500px;
    width: 90%;
    animation: fadeInScale .3s ease both;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
}

.modal-card h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 1.2rem;
}

/* ═══════════════  MISC ═══════════════ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: .5;
}

.empty-state p {
    font-size: .9rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.badge-accent {
    background: rgba(226, 0, 116, .15);
    color: var(--accent-light);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.info-banner {
    background: linear-gradient(135deg, rgba(226, 0, 116, .08) 0%, rgba(59, 130, 246, .08) 100%);
    border: 1px solid rgba(226, 0, 116, .15);
    border-radius: var(--radius-sm);
    padding: 1rem 1.2rem;
    font-size: .88rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .75rem;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    font-size: .8rem;
    color: var(--text-secondary);
}

.chip .remove {
    cursor: pointer;
    color: var(--error);
    font-weight: 700;
    opacity: .7;
    transition: var(--transition);
}

.chip .remove:hover {
    opacity: 1;
}

/* ═══════════════ THEME TOGGLE ═══════════════ */
.theme-toggle-floating {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 50;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.1rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}

.theme-toggle-floating:hover {
    background: var(--surface-hover);
    color: var(--text);
    transform: translateY(-1px);
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--glass-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

/* ═══════════════ MOBILE HEADER & HAMBURGER ═══════════════ */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: rgba(11, 15, 25, .97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 200;
    align-items: center;
    padding: 0 1rem;
    gap: .75rem;
}

.mobile-header-title {
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: -.3px;
    flex: 1;
}

.hamburger {
    width: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}

.hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: var(--transition);
}

.hamburger.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger.open span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.hamburger.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 99;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
    animation: fadeIn .2s ease both;
}

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 1024px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .grid-3 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    /* Show mobile top bar */
    .mobile-header {
        display: flex;
    }

    /* Sidebar becomes a slide-in drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        bottom: 0;
        width: 280px;
        min-height: 100vh;
        z-index: 100;
        transition: left .3s cubic-bezier(.4, 0, .2, 1);
    }

    .sidebar.open {
        left: 0;
        box-shadow: 8px 0 40px rgba(0, 0, 0, .6);
    }

    /* Main fills full width; extra top padding for the mobile header */
    .main {
        margin-left: 0;
        padding: 1.25rem 1rem;
        padding-top: calc(56px + 1.25rem);
    }

    .layout {
        flex-direction: row;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }

    .login-card {
        padding: 2rem 1.5rem;
    }

    .grid-3 {
        grid-template-columns: 1fr;
    }

    /* Modal: remove fixed min-width on mobile */
    .modal-card {
        min-width: unset;
        width: calc(100% - 2rem);
    }

    /* Toast at bottom on mobile so it doesn't cover content */
    #toast-container {
        top: auto;
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }

    .toast {
        max-width: 100%;
    }

    /* Larger tap targets */
    .btn-icon {
        width: 44px;
        height: 44px;
    }

    .btn-sm {
        padding: .6rem 1rem;
        font-size: .82rem;
    }

    .page-header h1 {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 1.5rem 1.25rem;
    }

    /* Stack card-header actions below title on very small screens */
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: .75rem;
    }
}