:root {
    --red: #d71920;
    --red-dark: #aa0f15;
    --charcoal: #22252a;
    --slate: #5c626d;
    --page: #f3f5f8;
    --panel: #ffffff;
    --line: #e5e8ed;
    --success: #12805c;
    --shadow: 0 18px 50px rgba(31, 37, 48, 0.10);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--charcoal);
    background:
        radial-gradient(circle at top right, rgba(215,25,32,.08), transparent 28rem),
        var(--page);
}

button, input { font: inherit; }

button { cursor: pointer; }

.topbar {
    min-height: 92px;
    padding: 18px clamp(20px, 4vw, 64px);
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(12px);
}

.brand-wrap, .header-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand-logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
    flex: 0 0 auto;
}

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

.topbar h1 { margin-bottom: 0; font-size: clamp(20px, 2vw, 28px); }

.eyebrow {
    margin-bottom: 5px;
    color: var(--red);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .18em;
}

.date-chip {
    border-left: 3px solid var(--red);
    padding-left: 14px;
    display: grid;
    gap: 2px;
}

.date-chip span { color: var(--slate); font-size: 12px; }
.date-chip strong { font-size: 15px; }

.logout-link {
    color: var(--charcoal);
    text-decoration: none;
    font-weight: 700;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--line);
}

.dashboard {
    width: min(1500px, calc(100% - 40px));
    margin: 28px auto 56px;
}

.hero-panel {
    padding: clamp(26px, 4vw, 48px);
    border-radius: 24px;
    background:
        linear-gradient(120deg, rgba(0,0,0,.86), rgba(35,37,42,.90)),
        linear-gradient(135deg, var(--charcoal), #3d424a);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    box-shadow: var(--shadow);
}

.hero-panel h2 {
    margin-bottom: 10px;
    font-size: clamp(28px, 4vw, 48px);
    max-width: 760px;
}

.hero-panel p:last-child { margin-bottom: 0; color: #c9cdd4; }

.live-badge {
    flex: 0 0 auto;
    padding: 12px 16px;
    border-radius: 999px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .10em;
}

.live-badge span {
    display: inline-block;
    width: 9px;
    height: 9px;
    background: #43d17f;
    border-radius: 50%;
    margin-right: 8px;
    box-shadow: 0 0 0 6px rgba(67,209,127,.15);
}

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

.metric-card {
    min-height: 158px;
    padding: 24px;
    border: 0;
    border-radius: 20px;
    text-align: left;
    background: var(--panel);
    color: var(--charcoal);
    box-shadow: 0 10px 30px rgba(31,37,48,.08);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    transition: transform .2s ease, box-shadow .2s ease;
}

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

.metric-card.accent {
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: #fff;
}

.metric-card.accent span,
.metric-card.accent small { color: rgba(255,255,255,.78); }

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    background: #f0f2f5;
    color: var(--red);
    font-size: 23px;
    font-weight: 900;
}

.metric-card.accent .metric-icon {
    color: #fff;
    background: rgba(255,255,255,.15);
}

.metric-card span, .metric-card small {
    display: block;
    color: var(--slate);
}

.metric-card span { font-size: 13px; font-weight: 700; }
.metric-card strong { display: block; margin: 7px 0 5px; font-size: 38px; line-height: 1; }
.metric-card small { font-size: 12px; }
.metric-arrow { font-size: 24px; opacity: .45; }
.time-value { font-size: 27px !important; }

.content-grid {
    margin-top: 22px;
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: 22px;
}

.panel {
    padding: 26px;
    border-radius: 20px;
    background: var(--panel);
    box-shadow: 0 10px 30px rgba(31,37,48,.07);
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.panel-heading h3 { margin-bottom: 0; font-size: 22px; }

.text-button {
    border: 0;
    background: transparent;
    color: var(--red);
    font-weight: 800;
}

.recent-list { display: grid; }

.recent-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 14px;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--line);
}

.recent-item:last-child { border-bottom: 0; }

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #f9d7d9, #fff1f1);
    color: var(--red);
    font-weight: 900;
}

.recent-person strong, .recent-person span { display: block; }
.recent-person span { margin-top: 4px; color: var(--slate); font-size: 13px; }

.recent-state { text-align: right; }
.recent-state time { display: block; margin-top: 6px; color: var(--slate); font-size: 12px; }

.state-pill, .dept-badge, .count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-weight: 800;
    white-space: nowrap;
}

.state-pill {
    padding: 6px 10px;
    background: #eef8f4;
    color: var(--success);
    font-size: 11px;
}

.dept-badge {
    padding: 6px 10px;
    background: #f0f2f5;
    color: #4e5560;
    font-size: 12px;
}

.count-badge {
    min-width: 30px;
    padding: 5px 9px;
    background: #fff0f0;
    color: var(--red);
}

.department-list { display: grid; gap: 20px; }

.department-row {
    display: grid;
    grid-template-columns: 150px 1fr 46px;
    align-items: center;
    gap: 14px;
}

.department-meta strong, .department-meta span { display: block; }
.department-meta span { margin-top: 4px; color: var(--slate); font-size: 12px; }

.progress-track {
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: #eef0f3;
}

.progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--red), #f15a60);
}

.department-row b { text-align: right; font-size: 13px; }

.alert {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 12px;
}

.alert.error {
    background: #fff1f1;
    color: #9e1117;
    border: 1px solid #f2c7c9;
}

.alert strong, .alert span { display: block; }
.alert span { margin-top: 5px; font-size: 13px; }

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
}

.modal.is-open { display: block; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17,20,25,.70);
    backdrop-filter: blur(7px);
}

.modal-dialog {
    position: relative;
    width: min(980px, calc(100% - 32px));
    max-height: calc(100vh - 48px);
    margin: 24px auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 30px 90px rgba(0,0,0,.25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-wide { width: min(1400px, calc(100% - 32px)); }

.modal-header {
    padding: 24px 28px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

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

.close-button {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 0;
    background: #f0f2f5;
    font-size: 28px;
    line-height: 1;
}

.table-toolbar {
    padding: 15px 20px;
    background: #fafbfc;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
}

.table-search {
    flex: 1;
    min-width: 220px;
    padding: 12px 14px;
    border: 1px solid #d7dbe2;
    border-radius: 11px;
    outline: none;
}

.table-search:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(215,25,32,.10);
}

.secondary-button, .primary-button {
    border: 0;
    border-radius: 11px;
    padding: 12px 16px;
    font-weight: 800;
}

.secondary-button {
    background: var(--charcoal);
    color: #fff;
}

.primary-button {
    width: 100%;
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: #fff;
}

.table-wrap { overflow: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f7f8fa;
    color: #5c626d;
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 2;
}

tbody tr:hover { background: #fffafa; }

body.modal-open { overflow: hidden; }

.empty-state {
    padding: 36px 14px;
    text-align: center;
    color: var(--slate);
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(19,21,25,.94), rgba(54,57,64,.90)),
        var(--charcoal);
}

.login-shell { width: min(460px, 100%); }

.login-card {
    padding: 38px;
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 30px 100px rgba(0,0,0,.25);
}

.login-logo {
    display: block;
    width: 82px;
    height: 82px;
    object-fit: contain;
    margin: 0 auto 24px auto;
}

.login-card h1 { margin-bottom: 10px; }
.muted { color: var(--slate); }

.login-form { display: grid; gap: 16px; margin-top: 24px; }
.login-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }

.login-form input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid #d7dbe2;
    border-radius: 11px;
    outline: none;
}

.login-form input:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(215,25,32,.10);
}

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

@media (max-width: 700px) {
    .topbar { align-items: flex-start; }
    .topbar h1 { display: none; }
    .brand-logo {
    width: 34px;
    height: 34px;
}
    .date-chip { display: none; }
    .dashboard { width: min(100% - 24px, 1500px); margin-top: 14px; }
    .hero-panel { align-items: flex-start; flex-direction: column; border-radius: 18px; }
    .metric-grid { grid-template-columns: 1fr; gap: 12px; }
    .metric-card { min-height: 132px; }
    .department-row { grid-template-columns: 120px 1fr 40px; }
    .table-toolbar { flex-direction: column; }
    .modal-dialog, .modal-wide { width: calc(100% - 14px); margin: 7px auto; max-height: calc(100vh - 14px); border-radius: 15px; }
    .modal-header { padding: 18px; }
    .recent-item { grid-template-columns: auto 1fr; }
    .recent-state { grid-column: 2; text-align: left; }
}
