:root {
    --bg-primary: #f3f6fb;
    --bg-panel: #ffffff;
    --bg-mute: #eef4ff;
    --sidebar-bg: #0f172a;
    --sidebar-soft: #1d2b42;
    --text-primary: #1d2433;
    --text-muted: #65738b;
    --primary: #4361ee;
    --primary-soft: #ebf0ff;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    --shadow: 0 24px 48px rgba(15, 23, 42, 0.12);
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #eef4ff 0%, #f8fafc 35%, #eef6f0 100%);
    color: var(--text-primary);
}

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

.hidden {
    display: none !important;
}

#app {
    min-height: 100vh;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    background: linear-gradient(135deg, rgba(67, 97, 238, 0.1), rgba(34, 197, 94, 0.08));
}

.auth-branding {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 4rem 5rem;
    background: radial-gradient(circle at top left, rgba(67, 97, 238, 0.12), transparent 38%), #fff;
}

.brand-badge {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), #7c8cff);
    color: #fff;
    box-shadow: var(--shadow);
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.auth-branding h1 {
    font-size: clamp(2.6rem, 4vw, 4rem);
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.05em;
}

.auth-branding p {
    margin-top: 1rem;
    max-width: 560px;
    font-size: 1.08rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.brand-points {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin-top: 2rem;
}

.brand-points span {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    border-radius: 999px;
    background: var(--bg-mute);
    color: var(--text-primary);
    font-weight: 600;
}

.auth-panel {
    display: grid;
    place-items: center;
    padding: 3rem 2rem;
}

.auth-card {
    width: min(100%, 460px);
    padding: 2rem;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(148, 163, 184, 0.18);
    box-shadow: var(--shadow);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(8px);
}

.form-header {
    margin-bottom: 1.5rem;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--primary);
}

.form-header h3 {
    margin: 0;
    font-weight: 800;
    font-size: 2rem;
}

.form-label {
    margin-bottom: 0.55rem;
    font-weight: 600;
    color: var(--text-primary);
}

.input-group-text {
    background: var(--bg-mute);
    border-color: rgba(148, 163, 184, 0.25);
    color: var(--primary);
}

.form-control,
.form-select,
textarea {
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: #fff;
    box-shadow: none;
    min-height: 48px;
}

.form-control:focus,
.form-select:focus,
textarea:focus {
    border-color: rgba(67, 97, 238, 0.45);
    box-shadow: 0 0 0 0.2rem rgba(67, 97, 238, 0.12);
}

.btn {
    border-radius: 12px;
    font-weight: 600;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #6b7cff);
    border: none;
    box-shadow: 0 12px 24px rgba(67, 97, 238, 0.24);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #1fbf70);
    border: none;
    box-shadow: 0 12px 24px rgba(34, 197, 94, 0.2);
}

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

.sidebar {
    width: 280px;
    background: linear-gradient(180deg, var(--sidebar-bg), #111a2d);
    color: #dfe8ff;
    box-shadow: 20px 0 40px rgba(15, 23, 42, 0.12);
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 1.3rem 1rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.8rem 0.9rem 1.3rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.brand-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(67, 97, 238, 0.18);
    color: #c9d5ff;
}

.sidebar-brand h4 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.nav-menu {
    margin-top: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #ced8f6;
    text-decoration: none;
    padding: 0.85rem 0.9rem;
    border-radius: 12px;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(148, 163, 184, 0.14);
    color: #fff;
    transform: translateX(4px);
}

.nav-link.logout-link {
    margin-top: auto;
    color: #ffd8d8;
}

.sidebar-footer {
    padding-top: 1.2rem;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 999px;
    padding: 0.85rem 0.9rem;
    color: #eef5ff;
    font-weight: 600;
}

.user-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 6px rgba(74, 222, 128, 0.15);
}

.main-panel {
    flex: 1;
    padding: 2rem 2.2rem 2.5rem;
    position: relative;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.page-kicker {
    margin: 0;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.1em;
    font-size: 0.72rem;
}

.topbar h2 {
    margin: 0.2rem 0 0;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.notification-button {
    position: relative;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(148, 163, 184, 0.18);
}

.notification-count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    min-height: 20px;
    padding: 0.2rem 0.38rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--danger), #ff6680);
    color: white;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    display: none;
}

.notification-panel {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: var(--radius-md);
    box-shadow: 0 20px 35px rgba(15, 23, 42, 0.08);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.notification-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.75rem;
}

.notification-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.15);
    padding: 0.9rem 1rem;
    border-radius: 12px;
}

.notification-item.unread {
    border-left: 4px solid var(--primary);
}

.notification-item small {
    color: var(--text-muted);
}

.content-area {
    display: grid;
    gap: 1.2rem;
}

.card {
    border-radius: var(--radius-md);
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.05);
    background: rgba(255, 255, 255, 0.96);
}

.card-header {
    background: linear-gradient(180deg, rgba(67, 97, 238, 0.02), rgba(67, 97, 238, 0.07));
    border-bottom: 1px solid rgba(148, 163, 184, 0.15);
    font-weight: 800;
    color: var(--text-primary);
    padding: 1rem 1.1rem;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.card-body {
    padding: 1.2rem 1.1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 1rem;
}

.stat-card {
    position: relative;
    overflow: hidden;
    border-left: 4px solid var(--primary);
    padding: 1.1rem 1rem;
    border-radius: var(--radius-md);
    background: #fff;
    border: 1px solid rgba(148, 163, 184, 0.15);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.stat-card.warning { border-left-color: var(--warning); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.info { border-left-color: var(--info); }

.stat-card .label {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-card .value {
    margin-top: 0.6rem;
    font-size: clamp(1.6rem, 2vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.04em;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.list-group-item {
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    margin-bottom: 0.6rem;
}

.table-responsive {
    overflow-x: auto;
}

.table {
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
}

.table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border: none;
    padding: 0.9rem 1rem;
}

.table td {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-left: none;
    border-right: none;
    padding: 0.9rem 1rem;
    vertical-align: middle;
}

.table tr td:first-child {
    border-left: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 12px 0 0 12px;
}

.table tr td:last-child {
    border-right: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 0 12px 12px 0;
}

.tracking-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    background: rgba(67, 97, 238, 0.08);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    font-family: "Consolas", "Courier New", monospace;
}

.status-badge {
    font-size: 0.74rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0.45rem 0.7rem;
}

.escalated {
    background: rgba(239, 68, 68, 0.04) !important;
}

.alert {
    border: none;
    border-radius: 12px;
    padding: 0.9rem 1rem;
    font-weight: 600;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.meta-block {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    margin-top: 1rem;
}

.meta-item {
    background: #f8fafc;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 12px;
    padding: 0.85rem 0.95rem;
}

.meta-item strong {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.audit-log {
    max-height: 360px;
    overflow-y: auto;
}

.audit-log table {
    width: 100%;
}

@media (max-width: 1080px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

@media (max-width: 860px) {
    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-branding {
        padding: 3rem 1.5rem 1rem;
    }

    .app-layout {
        display: block;
    }

    .sidebar {
        width: 100%;
    }

    .sidebar-inner {
        min-height: initial;
    }

    .main-panel {
        padding: 1.25rem 1rem 2rem;
    }
}

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

    .meta-block {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 1.4rem;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }
}
