:root {
    --bg: #f3f5f1;
    --panel: #ffffff;
    --panel-border: #d8e1d2;
    --text: #183028;
    --muted: #64756b;
    --accent: #147a57;
    --accent-soft: #e3f5ec;
    --warning: #e7a53a;
    --danger: #d0543f;
    --info: #2f74b6;
    --shadow: 0 24px 70px rgba(22, 42, 33, 0.08);
    --radius: 20px;
    --font: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background: radial-gradient(circle at top left, #f8fbf5, #edf1ea 45%, #e7ede4);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 280px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, #143229, #1b4739);
    color: #f6fbf8;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #1eb07d, #0c7650);
    font-weight: 700;
}

.brand h1,
.topbar h2,
.panel h3,
.tray-card h3 {
    margin: 0;
}

.brand p,
.topbar p {
    margin: 4px 0 0;
    color: rgba(255, 255, 255, 0.7);
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a {
    border-radius: 14px;
    padding: 12px 14px;
    color: rgba(255, 255, 255, 0.78);
}

.nav a.active,
.nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
}

.main-shell {
    padding: 24px 28px 36px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 22px;
}

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

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-chip {
    display: inline-flex;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
}

.content {
    display: grid;
    gap: 22px;
}

.metric-grid,
.card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.split-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 22px;
}

.metric-card,
.panel,
.tray-card,
.login-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.metric-card {
    padding: 22px;
    display: grid;
    gap: 8px;
}

.metric-card strong {
    font-size: 2rem;
}

.status-critical {
    background: linear-gradient(180deg, #fff9f7, #fff);
}

.panel,
.tray-card {
    padding: 22px;
}

.panel-header,
.tray-card-head,
.alert-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 0.85rem;
    background: #eff3ef;
}

.badge-active,
.badge-completed,
.badge-in_time,
.badge-entry {
    background: var(--accent-soft);
    color: var(--accent);
}

.badge-delayed,
.badge-unmatched_exit,
.badge-archived,
.badge-exit {
    background: #fde9e5;
    color: var(--danger);
}

.badge-early_exit {
    background: #fff3e0;
    color: #e65100;
}

.badge-neutral,
.badge-pending,
.badge-captured {
    background: #e8f0f8;
    color: var(--info);
}

.bars {
    min-height: 280px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
    gap: 12px;
    align-items: end;
}

.bar-group {
    display: grid;
    gap: 10px;
    justify-items: center;
}

.bar-stack {
    width: 100%;
    min-height: 220px;
    border-radius: 16px;
    background: #f5f7f4;
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 6px;
    padding: 12px 10px;
}

.bar {
    width: 12px;
    border-radius: 12px 12px 0 0;
}

.bar.entry {
    background: var(--accent);
}

.bar.exit {
    background: var(--danger);
}

.alert-list {
    display: grid;
    gap: 12px;
}

.alert-item {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid transparent;
    background: #f7f9f8;
}

.severity-critical {
    border-color: #f3c6be;
    background: #fff2ef;
}

.severity-warning {
    border-color: #f3ddb0;
    background: #fff7e7;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid #ebefea;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-weight: 600;
}

.toolbar,
.stack-form {
    display: grid;
    gap: 12px;
}

.toolbar {
    grid-template-columns: minmax(180px, 1fr) 180px auto;
    margin-bottom: 16px;
}

.settings-table input[readonly] {
    background: #f2f5f2;
    color: var(--text);
}

.stack-form label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

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

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    padding: 12px 14px;
    background: #fbfcfa;
}

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

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    cursor: pointer;
}

.button-primary {
    background: linear-gradient(135deg, #1e9f71, #137052);
    color: white;
}

.button-ghost {
    background: #eef3ee;
    color: var(--text);
}

.button-full {
    width: 100%;
}

.messages {
    display: grid;
    gap: 8px;
}

.message {
    padding: 14px 16px;
    border-radius: 14px;
}

.message.success {
    background: #e5f6ec;
    color: #0d6f4f;
}

.message.info {
    background: #e9f1fb;
    color: #245c8e;
}

.message.warning,
.message.error {
    background: #fff0ea;
    color: #b34d39;
}

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

.tray-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 18px;
    margin: 0;
}

.tray-meta div {
    display: grid;
    gap: 6px;
    align-content: start;
    min-width: 0;
}

.activity-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.tray-meta dt {
    color: var(--muted);
    line-height: 1.2;
}

.tray-meta dd {
    margin: 0;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 14px;
}

.subpanel {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid #ebefea;
}

.capture-preview img,
.capture-placeholder {
    border-radius: 18px;
    min-height: 260px;
    background: #f5f7f4;
    border: 1px dashed #d0d8cb;
    display: grid;
    place-items: center;
}

.capture-preview img {
    object-fit: cover;
    width: 100%;
}

.main-shell:only-child {
    grid-column: 1 / -1;
}

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(480px, 100%);
    padding: 32px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    font-size: 0.78rem;
}

@media (max-width: 1100px) {
    .app-shell,
    .split-grid,
    .metric-grid,
    .card-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .main-shell {
        padding: 18px;
    }

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