:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #17202a;
    --muted: #6f7b87;
    --line: #e4e8ec;
    --accent: #176b57;
    --accent-dark: #105243;
    --danger: #b33a3a;
    --sidebar: #14231f;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

button, input { font: inherit; }

button { cursor: pointer; }

[hidden] { display: none !important; }

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 15% 15%, #dcebe6 0, transparent 35%),
        linear-gradient(135deg, #f7f9f8, #edf2f0);
}

.login-card {
    width: min(420px, 100%);
    padding: 42px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 24px 70px rgba(20, 35, 31, 0.12);
}

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

.brand-mark.small {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 17px;
}

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

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

h1 { margin-bottom: 8px; }

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

form label {
    display: grid;
    gap: 7px;
    margin-top: 18px;
    color: #3f4a54;
    font-size: 14px;
    font-weight: 650;
}

input {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid #cfd6dc;
    border-radius: 10px;
    background: white;
    color: var(--text);
    outline: none;
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(23, 107, 87, 0.12);
}

.primary, .secondary {
    min-height: 42px;
    padding: 10px 17px;
    border-radius: 10px;
    border: 0;
    font-weight: 750;
}

.primary {
    background: var(--accent);
    color: white;
}

.primary:hover { background: var(--accent-dark); }

.secondary {
    background: #edf0f2;
    color: var(--text);
}

.login-card .primary {
    width: 100%;
    margin-top: 24px;
}

.error {
    margin: 14px 0 0;
    padding: 10px 12px;
    border-radius: 9px;
    background: #fff0f0;
    color: var(--danger);
    font-size: 14px;
}

.dashboard {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 230px 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--sidebar);
    color: white;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 34px;
    font-weight: 800;
}

nav { display: grid; gap: 7px; }

.nav-item, .logout {
    padding: 12px 14px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #c6d2ce;
    text-align: left;
}

.nav-item.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.disabled { opacity: 0.48; }

.logout { color: #d9e1de; }

.content {
    width: min(1400px, 100%);
    padding: 34px 40px 50px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.user-badge {
    display: grid;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
}

.user-badge small { color: var(--muted); }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 16px;
    margin: 26px 0;
}

.summary-card {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
}

.summary-card span {
    display: block;
    margin-bottom: 9px;
    color: var(--muted);
    font-size: 14px;
}

.summary-card strong { font-size: 27px; }

.panel {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: white;
}

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

.panel-header h2 { margin-bottom: 5px; }

.panel-header p { margin-bottom: 0; }

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

.checkbox-label {
    display: flex;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-weight: 550;
}

.checkbox-label input { width: auto; }

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

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

th, td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td { font-size: 14px; }

.status {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    background: #e8f4ef;
    color: var(--accent);
    font-size: 12px;
    font-weight: 750;
}

.status.inactive {
    background: #f0f1f2;
    color: #727c84;
}

.row-button {
    border: 0;
    background: transparent;
    color: var(--accent);
    font-weight: 700;
}

.empty-state {
    padding: 60px 20px;
    display: grid;
    gap: 6px;
    place-items: center;
    color: var(--muted);
}

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

dialog {
    width: min(680px, calc(100% - 32px));
    padding: 0;
    border: 0;
    border-radius: 18px;
    box-shadow: 0 30px 90px rgba(0,0,0,0.25);
}

dialog::backdrop {
    background: rgba(16, 25, 22, 0.55);
}

dialog form { padding: 26px; }

.dialog-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
}

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

.icon-button {
    border: 0;
    background: transparent;
    font-size: 30px;
    color: var(--muted);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.full-width { grid-column: 1 / -1; }

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 25px;
}

@media (max-width: 800px) {
    .dashboard { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
    }
    nav, .logout { display: none; }
    .content { padding: 24px 16px; }
    .topbar, .panel-header {
        align-items: stretch;
        flex-direction: column;
    }
    .summary-grid { grid-template-columns: 1fr; }
    .actions {
        align-items: stretch;
        flex-direction: column;
    }
    .form-grid { grid-template-columns: 1fr; }
    .full-width { grid-column: auto; }
}

.nav-item {
    display: block;
    text-decoration: none;
}

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

.date-control {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
}

.date-control input {
    width: auto;
}

.summary-grid.four {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.mini-button {
    padding: 7px 11px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: white;
    color: var(--accent);
    font-size: 13px;
    font-weight: 750;
}

.mini-button:hover {
    background: #edf7f3;
}

.status.open {
    background: #fff3d8;
    color: #936600;
}

.status.absent {
    background: #f0f1f2;
    color: #727c84;
}

.status.closed {
    background: #e8f4ef;
    color: var(--accent);
}

@media (max-width: 1000px) {
    .summary-grid.four {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 800px) {
    .topbar-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .summary-grid.four {
        grid-template-columns: 1fr;
    }
}

/* Employee access page */
.access-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 24px;
}

.access-card {
    padding: 20px;
    border: 1px solid #e2e7e5;
    border-radius: 16px;
    background: #ffffff;
}

.access-card h3 {
    margin: 0 0 7px;
    font-size: 17px;
}

.access-card p {
    min-height: 22px;
    margin: 0 0 18px;
    color: #7b8792;
}

.access-card button {
    width: 100%;
    padding: 11px 16px;
    border: 0;
    border-radius: 10px;
    background: #147b67;
    color: #ffffff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.access-card button:hover {
    background: #0f6857;
}

.access-card button:disabled {
    opacity: .6;
    cursor: wait;
}

.page-message {
    grid-column: 1 / -1;
    padding: 40px;
    text-align: center;
    color: #7b8792;
}

#codeDialog {
    width: min(440px, calc(100% - 32px));
    border: 0;
    border-radius: 20px;
    padding: 0;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .25);
}

#codeDialog::backdrop {
    background: rgba(8, 28, 23, .55);
}

.code-content {
    padding: 28px;
    text-align: center;
}

.personal-code {
    margin: 22px 0 12px;
    padding: 18px;
    border-radius: 14px;
    background: #eef7f4;
    color: #087a62;
    font: 700 30px/1 monospace;
    letter-spacing: 3px;
}

.code-note {
    margin-bottom: 22px;
    color: #7b8792;
    line-height: 1.5;
}

.code-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 700px) {
    .access-grid {
        grid-template-columns: 1fr;
        padding: 14px;
    }
}
