:root {
    --bg: #eef8f3;
    --panel: #ffffff;
    --panel-alt: #f6fbff;
    --line: #dfe8ea;
    --text: #14232b;
    --muted: #667782;
    --brand: #238bd0;
    --brand-dark: #176da8;
    --nav: #183f61;
    --accent: #d99832;
    --danger: #b54040;
    --ok: #1c8a64;
    --lavender: #eee9ff;
    --sky: #e8f5ff;
    --cream: #fff4df;
    --shadow: 0 16px 46px rgba(24, 63, 97, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

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

.sidebar {
    background: var(--nav);
    color: #f7faf5;
    padding: 24px 18px;
}

.brand {
    margin-bottom: 28px;
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0;
}

.brand-subtitle {
    color: #bdd4e3;
    font-size: 12px;
    margin-top: 4px;
}

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

.nav a {
    color: #eaf6ff;
    padding: 10px 12px;
    border-radius: 8px;
    display: block;
    text-decoration: none;
}

.nav a:hover,
.nav a.is-active {
    background: rgba(255, 255, 255, 0.14);
}

.main {
    min-width: 0;
}

.topbar {
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid var(--line);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 2;
    backdrop-filter: blur(10px);
}

.topbar h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
}

.topbar-meta {
    color: var(--muted);
    font-size: 13px;
}

.content {
    padding: 28px;
}

.eyebrow {
    color: var(--brand);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.grid {
    display: grid;
    gap: 16px;
}

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

.grid.two {
    grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.card-header {
    padding: 16px 18px 0;
}

.card-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.card-body {
    padding: 16px 18px 18px;
}

.stat {
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.stat::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--brand);
}

.stat-label {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 6px;
}

.stat-note {
    color: var(--muted);
    font-size: 12px;
    margin-top: 6px;
}

.toolbar {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.report-shell {
    display: grid;
    gap: 14px;
}

.report-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.report-tabs a {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    font-weight: 700;
    text-decoration: none;
}

.report-tabs a.is-active {
    color: #fff;
    background: var(--brand);
    border-color: var(--brand);
}

.report-card {
    box-shadow: var(--shadow);
}

.report-toolbar {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.report-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
    margin: 4px 0 14px;
}

.report-heading h2 {
    margin: 0;
    font-size: 18px;
}

.report-heading p {
    margin: 4px 0 0;
    color: var(--muted);
}

.mini-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.mini-stat {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.mini-stat span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.mini-stat strong {
    font-size: 20px;
}

.mini-stat.ok {
    background: #eaf9f2;
    border-color: rgba(28, 138, 100, 0.22);
}

.mini-stat.warn {
    background: var(--cream);
    border-color: rgba(217, 152, 50, 0.24);
}

.mini-stat.danger {
    background: #fff0f0;
    border-color: rgba(181, 64, 64, 0.20);
}

.mini-stat.info {
    background: var(--sky);
    border-color: rgba(35, 139, 208, 0.18);
}

.field {
    display: grid;
    gap: 6px;
}

.field label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

input,
select {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff;
    color: var(--text);
}

input:focus,
select:focus {
    outline: 2px solid rgba(31, 111, 91, 0.18);
    border-color: var(--brand);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--brand);
    background: var(--brand);
    color: white;
    border-radius: 8px;
    min-height: 38px;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 700;
}

.button:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

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

.button.warning {
    background: var(--accent);
    border-color: var(--accent);
}

.button.danger {
    background: var(--danger);
    border-color: var(--danger);
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    background: #f7fbfd;
}

.report-table th {
    position: sticky;
    top: 0;
    z-index: 1;
}

tr:hover td {
    background: #fbfcfa;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--line);
    color: var(--muted);
    background: #fff;
}

.badge.ok {
    color: var(--ok);
    border-color: rgba(36, 115, 77, 0.24);
    background: rgba(36, 115, 77, 0.08);
}

.badge.warn {
    color: var(--accent);
    border-color: rgba(192, 122, 34, 0.26);
    background: rgba(192, 122, 34, 0.08);
}

.badge.danger {
    color: var(--danger);
    border-color: rgba(181, 64, 64, 0.24);
    background: rgba(181, 64, 64, 0.08);
}

.badge.info {
    color: var(--brand);
    border-color: rgba(35, 139, 208, 0.24);
    background: rgba(35, 139, 208, 0.08);
}

.check-field {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
}

.check-field input {
    min-height: auto;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-alt);
}

.permission-grid .check-field {
    min-height: 30px;
}

.inline-form {
    display: inline;
    margin-left: 8px;
}

.link-button {
    border: 0;
    background: transparent;
    color: var(--brand);
    cursor: pointer;
    padding: 0;
    font: inherit;
    font-weight: 700;
}

.compact-form {
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 12px 0 16px;
}

.analysis-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.analysis-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.analysis-card strong {
    font-size: 22px;
}

.punch-chart {
    display: grid;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.punch-bar-row {
    display: grid;
    grid-template-columns: 58px minmax(120px, 1fr) 36px;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
}

.punch-bar-track {
    height: 10px;
    border-radius: 999px;
    background: #eef3f5;
    overflow: hidden;
}

.punch-bar {
    height: 100%;
    border-radius: inherit;
    background: var(--brand);
}

.punch-bar.ok {
    background: var(--ok);
}

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

.punch-bar.zero {
    background: #d7e0e4;
}

.roster-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.roster-legend span {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    color: var(--muted);
}

.roster-legend strong {
    color: var(--text);
}

.roster-table table {
    min-width: 1180px;
}

.roster-table th,
.roster-table td {
    padding: 7px;
    text-align: center;
    vertical-align: middle;
}

.roster-table th span {
    display: block;
    color: var(--muted);
    font-size: 11px;
}

.roster-table th strong {
    display: block;
    color: var(--text);
    font-size: 13px;
}

.roster-sticky {
    position: sticky;
    z-index: 2;
    background: #fff;
    text-align: left !important;
}

th.roster-sticky {
    background: #f7fbfd;
    z-index: 3;
}

.roster-name {
    left: 0;
    min-width: 170px;
}

.roster-dept {
    left: 170px;
    min-width: 150px;
}

.roster-name strong,
.roster-dept {
    font-size: 13px;
}

.roster-name span,
.roster-dept span {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
}

.roster-select {
    min-width: 76px;
    min-height: 34px;
    padding: 6px 8px;
    font-size: 12px;
}

.roster-inherit {
    background: #fbfdff;
}

.roster-override {
    background: #fff8e9;
}

.notice {
    border: 1px solid var(--line);
    background: var(--panel-alt);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.notice.error {
    border-color: rgba(181, 64, 64, 0.3);
    background: rgba(181, 64, 64, 0.08);
}

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

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

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

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

.login-panel {
    width: min(420px, 100%);
}

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

    .sidebar {
        position: static;
        padding: 16px;
    }

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

    .grid.stats,
    .grid.two,
    .form-grid,
    .permission-grid {
        grid-template-columns: 1fr;
    }

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

    .content,
    .topbar {
        padding: 18px;
    }
}

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

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

    th,
    td {
        padding: 9px;
    }

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

@media print {
    body {
        background: #fff;
    }

    .sidebar,
    .topbar,
    .report-tabs,
    .report-toolbar,
    .print-only-hide {
        display: none;
    }

    .layout {
        display: block;
    }

    .content {
        padding: 0;
    }

    .card {
        border: 0;
        box-shadow: none;
    }

    th,
    td {
        white-space: normal;
    }
}
