:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-soft: #f8fafb;
    --text: #15212b;
    --muted: #6f7d88;
    --line: #dde4e8;
    --brand: #133f3a;
    --brand-soft: #e5f0ee;
    --accent: #d59042;
    --danger: #b84444;
    --danger-soft: #fae9e9;
    --shadow: 0 18px 45px rgba(24, 45, 54, 0.08);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, #dcebe8 0, transparent 35%),
        linear-gradient(145deg, #f8fafb 0%, #edf2f2 100%);
}

.login-card {
    width: min(440px, 100%);
    padding: 42px;
    border: 1px solid rgba(19, 63, 58, 0.1);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
}

.brand-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: var(--brand);
    color: white;
    font-size: 26px;
    font-weight: 800;
}

.brand-mark.small {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 20px;
}

.eyebrow {
    margin: 24px 0 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.15em;
}

h1,
h2,
p {
    margin-top: 0;
}

.login-card h1 {
    margin-bottom: 10px;
    font-size: 34px;
}

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

form {
    margin-top: 28px;
}

label {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
    color: #33434e;
    font-size: 14px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
    padding: 12px 14px;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(19, 63, 58, 0.12);
}

form button,
.toolbar button {
    border: 0;
    border-radius: 12px;
    background: var(--brand);
    color: white;
    padding: 12px 18px;
    font-weight: 800;
}

form button {
    width: 100%;
}

.error-message {
    min-height: 20px;
    margin: 14px 0 0;
    color: var(--danger);
    font-size: 13px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 28px 20px;
    background: #102f2c;
    color: white;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand span,
.user-panel span {
    display: block;
    margin-top: 3px;
    color: #abc2bf;
    font-size: 12px;
}

nav {
    margin-top: 42px;
}

.nav-item {
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 12px 14px;
    text-align: left;
    background: rgba(255, 255, 255, 0.11);
    color: white;
    font-weight: 800;
}

.user-panel {
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
}

.user-panel button {
    margin-top: 14px;
    border: 0;
    background: transparent;
    color: #f0c898;
    padding: 0;
}

.content {
    min-width: 0;
    padding: 32px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-end;
}

.topbar .eyebrow {
    margin-top: 0;
}

.topbar h1 {
    margin-bottom: 0;
    font-size: 32px;
}

.toolbar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.tenant-picker {
    min-width: 240px;
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 28px 0 20px;
}

.stat-card {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(24, 45, 54, 0.04);
}

.stat-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
}

.stat-card.attention {
    background: var(--danger-soft);
    border-color: #efcaca;
}

.table-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: 0 10px 30px rgba(24, 45, 54, 0.04);
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    padding: 22px 24px;
    border-bottom: 1px solid var(--line);
}

.table-toolbar h2 {
    margin-bottom: 4px;
}

.table-toolbar p {
    margin-bottom: 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    white-space: nowrap;
}

.checkbox-label input {
    width: auto;
}

.table-wrap {
    padding: 18px 22px 24px;
    overflow-x: auto;
}

table.dataTable {
    width: 100% !important;
}

table.dataTable thead th {
    color: #4e5f69;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table.dataTable tbody tr {
    cursor: pointer;
}

table.dataTable tbody tr:hover {
    background: #f1f7f6;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 9px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
}

.status-pill.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(8, 23, 27, 0.35);
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 40;
    width: min(600px, 96vw);
    height: 100vh;
    transform: translateX(105%);
    transition: transform 180ms ease;
    background: white;
    box-shadow: -20px 0 55px rgba(10, 29, 35, 0.18);
    overflow-y: auto;
}

.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding: 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.97);
}

.drawer-header .eyebrow {
    margin-top: 0;
}

.drawer-header h2 {
    margin-bottom: 0;
}

.drawer-header button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
    font-size: 24px;
}

.drawer-content {
    padding: 24px;
}

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

.detail-item {
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-soft);
}

.detail-item span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.detail-item strong,
.detail-item pre {
    margin: 0;
    font-size: 13px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.timeline {
    margin-top: 26px;
}

.timeline-item {
    position: relative;
    margin-left: 8px;
    padding: 0 0 22px 22px;
    border-left: 2px solid var(--line);
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
}

.timeline-item time {
    color: var(--muted);
    font-size: 12px;
}

.timeline-item p {
    margin: 7px 0 0;
    line-height: 1.5;
}

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

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
    }

    .sidebar nav,
    .user-panel span {
        display: none;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .content {
        padding: 20px 14px;
    }

    .topbar,
    .toolbar,
    .table-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .tenant-picker {
        min-width: 0;
    }

    .stats-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }
}
