:root {
    --bg: #0b132b;
    --panel: #1c2541;
    --muted: #3a506b;
    --accent: #5bc0be;
    --accent-strong: #9ef0f0;
    --text: #f5f7fb;
    --danger: #ff6b6b;
    --success: #82e1a9;
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700&display=swap');

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at 20% 20%, rgba(91, 192, 190, 0.08), transparent 35%), var(--bg);
    color: var(--text);
    min-height: 100%;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

.cluster {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.auth-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card {
    width: min(920px, 100%);
    background: linear-gradient(135deg, rgba(24, 33, 62, 0.95), rgba(17, 25, 48, 0.92));
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 22px;
    padding: 2.5rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 10% 10%, rgba(91, 192, 190, 0.22), transparent 40%),
                radial-gradient(circle at 90% 20%, rgba(255, 209, 102, 0.18), transparent 35%);
    pointer-events: none;
}

.auth-grid {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 2rem;
    align-items: center;
}

.auth-hero {
    display: grid;
    gap: 1rem;
    padding-right: 1rem;
}

.auth-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(91, 192, 190, 0.2);
    color: var(--accent-strong);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.75rem;
}

.auth-title {
    margin: 0;
    font-size: clamp(2rem, 3vw, 2.6rem);
    line-height: 1.1;
}

.auth-subtitle {
    margin: 0;
    color: #b9c4d9;
    font-size: 1.05rem;
}

.auth-list {
    margin: 0;
    padding-left: 1.2rem;
    color: #d8e3f5;
    display: grid;
    gap: 0.35rem;
}

.auth-badge {
    align-self: flex-start;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: #d8e3f5;
    font-weight: 600;
}

.auth-form {
    background: rgba(12, 19, 43, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 2rem;
    display: grid;
    gap: 1rem;
}

.auth-form h2 {
    margin: 0;
    font-size: 1.5rem;
}

.auth-form p {
    margin: 0;
    color: #b9c4d9;
}

.auth-switch {
    margin: 0;
    color: #b9c4d9;
}

form .stack { display: grid; gap: 1rem; }

input, select, textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
}

select option {
    color: #0b132b;
    background: #ffffff;
}

.check-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.4rem;
}

.check-row span {
    order: 2;
}

.check-row input[type="checkbox"] {
    order: 1;
    margin-left: 0;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    background: rgba(12, 19, 43, 0.35);
    appearance: none;
    display: inline-grid;
    place-content: center;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.check-row input[type="checkbox"]::after {
    content: "";
    width: 5px;
    height: 8px;
    border-right: 2px solid var(--accent-strong);
    border-bottom: 2px solid var(--accent-strong);
    transform: scale(0) rotate(45deg);
    transform-origin: center;
    transition: transform 0.15s ease;
}

.check-row input[type="checkbox"]:checked {
    background: rgba(91, 192, 190, 0.12);
    border-color: rgba(91, 192, 190, 0.7);
}

.check-row input[type="checkbox"]:checked::after {
    transform: scale(1) rotate(45deg);
}

.check-row input[type="checkbox"]:focus-visible {
    outline: 2px solid rgba(91, 192, 190, 0.6);
    outline-offset: 2px;
}
}

.inline-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.inline-field input,
.inline-field select {
    max-width: 180px;
}

.date-range {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

button {
    border: none;
    border-radius: 12px;
    padding: 0.85rem 1.2rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
    color: #0b132b;
}

.btn-ghost {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text);
}

.btn-ghost.danger {
    border-color: rgba(255, 107, 107, 0.5);
    color: var(--danger);
}

.layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, rgba(28, 37, 65, 0.95), rgba(12, 18, 35, 0.98));
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent-strong);
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.brand svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.nav-links {
    display: grid;
    gap: 0.4rem;
}

.nav-link {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.nav-link.active, .nav-link:hover {
    background: rgba(91, 192, 190, 0.15);
}

.nav-link.nav-sub {
    padding-left: 2rem;
    font-size: 0.95rem;
    opacity: 0.9;
}

.sidebar .bottom-actions {
    margin-top: auto;
    display: grid;
    gap: 0.5rem;
}

.sidebar-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    font-weight: 700;
}

.sidebar-backdrop {
    display: none;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(11, 19, 43, 0.75);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .cluster {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header .cluster:last-child {
    margin-left: auto;
}

.pill {
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    background: rgba(91, 192, 190, 0.15);
    color: var(--accent-strong);
    font-weight: 700;
}

.user-menu {
    position: relative;
}

.user-menu summary {
    list-style: none;
    cursor: pointer;
}

.user-menu summary::-webkit-details-marker {
    display: none;
}

.user-menu-panel {
    position: absolute;
    right: 0;
    top: 120%;
    min-width: 280px;
    background: rgba(28, 37, 65, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 1rem;
    box-shadow: var(--shadow);
    z-index: 120;
}

.user-menu-panel .user-menu-content {
    gap: 1rem;
}

.user-menu-panel .user-menu-actions {
    gap: 0.75rem;
}

.user-menu-panel .user-menu-danger {
    margin-top: 0.5rem;
}

.user-menu-panel .user-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin-top: 0.25rem;
}

.content {
    padding: 1.5rem;
    display: grid;
    gap: 1.5rem;
}

.panel {
    background: rgba(28, 37, 65, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.panel h2 {
    margin: 0 0 0.75rem;
    font-size: 1.2rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.summary-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stat-card {
    display: grid;
    gap: 0.25rem;
}

.stat-label {
    color: #b9c4d9;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
}

.stat-value {
    font-size: clamp(1.8rem, 2.8vw, 2.4rem);
    font-weight: 700;
}

.target-percent {
    font-size: 1.05rem;
    font-weight: 700;
}

.progress {
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 0.75rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
    border-radius: 999px;
    transition: width 0.3s ease;
}

table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    color: var(--text);
}

table thead,
table tbody {
}

table th, table td {
    padding: 0.65rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

table th {
    color: #b9c4d9;
    font-weight: 600;
}

.responsive-table {
    width: 100%;
    display: block;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.table-card-list {
    display: none;
    gap: 0.9rem;
}

.table-card {
    background: rgba(20, 29, 52, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 0.9rem;
    display: grid;
    gap: 0.75rem;
    box-shadow: var(--shadow);
}

.table-card-fields {
    margin: 0;
    display: grid;
    gap: 0.6rem;
}

.table-card-field {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
}

.table-card-field dt {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #b9c4d9;
    font-weight: 600;
}

.table-card-field dd {
    margin: 0;
    text-align: right;
    word-break: break-word;
}

.table-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

.icon-spin {
    animation: icon-spin 1s linear infinite;
    transform-origin: 50% 50%;
}

@keyframes icon-spin {
    to { transform: rotate(360deg); }
}

.table-view.flip .responsive-table {
    display: none;
}

.table-view.flip .table-card-list {
    display: grid;
}

.table-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 0.75rem;
}

.table-tools input {
    width: auto;
    flex: 1 1 260px;
    max-width: 420px;
}

.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sort-indicator {
    margin-left: 0.35rem;
    color: var(--accent-strong);
}

.column-toggle {
    position: relative;
}

.column-toggle summary {
    list-style: none;
}

.column-toggle summary::-webkit-details-marker {
    display: none;
}

.column-toggle-panel {
    position: absolute;
    right: 0;
    top: 110%;
    min-width: 180px;
    max-width: min(320px, 92vw);
    max-height: 70vh;
    overflow: auto;
    background: rgba(28, 37, 65, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.75rem;
    display: grid;
    gap: 0.4rem;
    box-shadow: var(--shadow);
    z-index: 50;
}

.column-toggle-panel label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.9rem;
    width: 100%;
}

.column-toggle-panel label span {
    flex: 1;
}

.column-toggle-panel input[type="checkbox"] {
    margin-left: 0.5rem;
}

.icon-menu {
    position: relative;
}

.icon-menu summary {
    list-style: none;
}

.icon-menu summary::-webkit-details-marker {
    display: none;
}

.icon-menu-panel {
    position: absolute;
    right: 0;
    top: 110%;
    min-width: 160px;
    max-width: min(320px, 92vw);
    max-height: 70vh;
    overflow: visible;
    background: rgba(28, 37, 65, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.5rem;
    display: grid;
    gap: 0.35rem;
    box-shadow: var(--shadow);
    z-index: 50;
}

.icon-menu.align-left .icon-menu-panel {
    left: 0;
    right: auto;
}

.icon-menu-panel .btn-ghost,
.icon-menu-panel summary.btn-ghost {
    width: 100%;
    text-align: left;
    font-weight: 600;
    border: none;
    background: transparent;
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
}

.icon-menu-panel .btn-ghost:hover,
.icon-menu-panel summary.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
}

.icon-menu > summary.btn-ghost {
    border: none;
    background: transparent;
}

.icon-menu > summary.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.06);
}

.icon-menu > summary.btn-ghost.framed {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: transparent;
}

.icon-menu > summary.btn-ghost.framed:hover {
    background: rgba(255, 255, 255, 0.06);
}

.icon-submenu {
    position: relative;
}

.icon-submenu > .column-toggle-panel {
    position: absolute;
    left: 100%;
    top: 0;
    margin-left: 0.5rem;
    min-width: 180px;
    max-width: min(260px, 80vw);
    max-height: 70vh;
    overflow: auto;
    background: rgba(28, 37, 65, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.75rem;
    box-shadow: var(--shadow);
    z-index: 60;
}

.icon-menu-panel .icon-submenu > .column-toggle-panel {
    display: none;
}

.icon-submenu[open] > .column-toggle-panel {
    display: grid;
    gap: 0.4rem;
}

.badge {
    display: inline-block;
    padding: 0.4rem 0.7rem;
    border-radius: 10px;
    background: rgba(91, 192, 190, 0.2);
    color: var(--accent-strong);
    font-weight: 700;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: grid;
    place-items: center;
    z-index: 2000;
}

.modal {
    display: block !important;
    background: rgba(28, 37, 65, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    width: min(520px, 92vw);
    height: auto !important;
    max-height: 90vh;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    z-index: 2100;
    position: relative;
    overflow: auto;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 12px;
    background: rgba(255, 107, 107, 0.12);
    border: 1px solid rgba(255, 107, 107, 0.4);
    color: #ffc1c1;
}

.chip-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip { padding: 0.4rem 0.7rem; background: rgba(255,255,255,0.06); border-radius: 10px; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.6rem 0.8rem;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.spacer { flex: 1; }

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 0.6rem 1rem;
    background: #ffecec;
    color: #222;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

@media (max-width: 1024px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(320px, 86vw);
        transform: translateX(-105%);
        transition: transform 0.25s ease, opacity 0.25s ease;
        opacity: 0;
        z-index: 1200;
        flex-direction: column;
        overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); opacity: 1; }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: 1100;
        display: block;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }
    .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
    .sidebar-toggle { display: inline-flex; align-items: center; }
    .header { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
    .header .cluster { flex-wrap: wrap; }
}

@media (max-width: 640px) {
    .auth-shell {
        padding: 0;
        place-items: stretch;
    }
    .auth-card {
        width: 100%;
        padding-left: 0;
        padding-right: 0;
    }
    .auth-hero,
    .auth-form {
        width: 100%;
    }
    .auth-form {
        min-width: 0;
    }
    .header select {
        max-width: 140px;
    }
    .header .cluster {
        gap: 0.5rem;
    }
    .pill {
        padding: 0.4rem 0.7rem;
        font-size: 0.9rem;
    }
    .user-menu-panel {
        right: 0;
        left: auto;
        width: min(320px, 92vw);
    }
    table th,
    table td {
        white-space: nowrap;
    }
    .responsive-table {
        display: none;
    }
    .table-card-list {
        display: grid;
    }
    .table-card-field {
        display: grid;
        grid-template-columns: minmax(120px, 40%) minmax(0, 1fr);
        align-items: start;
    }
    .table-card-field dd {
        text-align: right;
        width: auto;
    }
    .table-card-actions {
        justify-content: flex-start;
    }
    .table-view.flip .responsive-table {
        display: table;
    }
    .table-view.flip .table-card-list {
        display: none;
    }
    .icon-menu-panel {
        left: 0;
        right: auto;
        width: min(320px, 92vw);
    }
    .icon-submenu > .column-toggle-panel {
        left: 0;
        top: 110%;
        margin-left: 0;
        width: min(320px, 92vw);
    }
    .auth-grid {
        grid-template-columns: 1fr;
    }
    .auth-hero {
        padding: 1.25rem 1rem 0;
    }
    .auth-form {
        padding: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .sidebar-backdrop {
        transition: none;
    }
    .icon-spin {
        animation: none;
    }
}
