:root {
    --ink: #18211f;
    --muted: #68736f;
    --line: #dde3e0;
    --surface: #ffffff;
    --canvas: #f3f6f4;
    --sidebar: #17211f;
    --teal: #167b68;
    --teal-soft: #e4f2ee;
    --amber: #b57416;
    --amber-soft: #fff2d9;
    --coral: #bd5546;
    --coral-soft: #fbe8e4;
    --blue: #3d6f8e;
    --blue-soft: #e7f0f5;
    --shadow: 0 10px 30px rgba(24, 33, 31, .08);
}

* { box-sizing: border-box; }

html { background: var(--canvas); color: var(--ink); font-family: "Segoe UI", Tahoma, sans-serif; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: 232px;
    flex-direction: column;
    padding: 22px 16px;
    background: var(--sidebar);
    color: #f7fbf9;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 46px;
    padding: 0 8px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 6px;
    background: #f4b942;
    color: #17211f;
    font-size: 13px;
    font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 2px; color: #9eaaa6; font-size: 11px; }

.sidebar-nav { display: grid; gap: 5px; margin-top: 34px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 42px;
    padding: 0 12px;
    border-radius: 6px;
    color: #b9c4c0;
    font-size: 13px;
    text-decoration: none;
}
.nav-item.is-active { background: #26332f; color: #fff; }
.nav-item.is-muted { opacity: .58; cursor: default; }
.nav-symbol { width: 17px; color: #8fa19b; font-size: 17px; text-align: center; }
.nav-item.is-active .nav-symbol { color: #f4b942; }

.sidebar-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding: 14px 9px 2px;
    border-top: 1px solid #32413d;
}
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 12px; font-weight: 600; }
.sidebar-foot small { margin-top: 3px; color: #91a09b; font-size: 10px; }
.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: #48c496; box-shadow: 0 0 0 4px rgba(72, 196, 150, .12); }

.main-content { min-height: 100vh; margin-left: 232px; padding: 30px clamp(24px, 3vw, 48px) 50px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.eyebrow { margin: 0 0 4px; color: var(--teal); font-size: 12px; font-weight: 700; }
h1 { margin: 0; font-size: clamp(24px, 3vw, 32px); line-height: 1.2; letter-spacing: 0; }
.as-of { text-align: right; }
.as-of span, .as-of strong { display: block; }
.as-of span { color: var(--muted); font-size: 11px; }
.as-of strong { margin-top: 4px; font-size: 12px; font-weight: 600; }

.alert {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding: 12px 14px;
    border: 1px solid #edb8ae;
    border-radius: 6px;
    background: var(--coral-soft);
    color: #78372e;
    font-size: 13px;
}

.control-band {
    display: grid;
    grid-template-columns: minmax(430px, 1fr) minmax(210px, 280px);
    align-items: end;
    gap: 18px;
    margin-top: 26px;
    padding: 16px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.report-filters { display: flex; align-items: flex-end; gap: 10px; }
.filter-field { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 600; }
.filter-field input, .filter-field select, .search-control, .export-button {
    height: 38px;
    border: 1px solid #cfd7d3;
    border-radius: 6px;
    background: var(--surface);
}
.filter-field input, .filter-field select { padding: 0 10px; color: var(--ink); }
.filter-field input { width: 156px; }
.filter-field select { width: 174px; }
.export-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-width: 92px;
    padding: 0 13px;
    border-color: var(--teal);
    background: var(--teal);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}
.export-button:hover, .export-button:focus { background: #116956; outline: 0; }
.export-button span { font-size: 16px; line-height: 1; }

.role-filter { display: flex; align-items: center; justify-self: center; padding: 3px; border: 1px solid var(--line); border-radius: 6px; background: #e9eeeb; }
.segment { min-height: 31px; padding: 0 13px; border: 0; border-radius: 4px; background: transparent; color: #58625f; font-size: 12px; font-weight: 600; }
.segment span { margin-left: 4px; color: #87918d; font-size: 10px; }
.segment.is-active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(24, 33, 31, .12); }
.segment.is-active span { color: var(--teal); }

.search-control { display: flex; align-items: center; gap: 8px; padding: 0 11px; color: #82908b; }
.search-control input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 12px; }
.search-control:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(22, 123, 104, .1); }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-top: 22px; }
.kpi-card { min-height: 124px; padding: 17px 18px; border: 1px solid var(--line); border-top-width: 3px; border-radius: 6px; background: var(--surface); }
.kpi-card p { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi-card div { display: flex; align-items: baseline; gap: 5px; margin-top: 8px; }
.kpi-card strong { font-size: 24px; line-height: 1; }
.kpi-card div span { color: var(--muted); font-size: 12px; }
.kpi-card small { display: block; margin-top: 11px; color: #87918d; font-size: 10px; line-height: 1.4; }
.kpi-employees { border-top-color: var(--blue); }
.kpi-utilization { border-top-color: var(--teal); }
.kpi-payroll { border-top-color: #536c8d; }
.kpi-used-cost { border-top-color: var(--teal); }
.kpi-idle-cost { border-top-color: var(--coral); }

.data-notice {
    display: none;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px 12px;
    border-left: 3px solid var(--amber);
    background: #fff8e9;
    color: #705221;
    font-size: 11px;
}
.data-notice.is-visible { display: flex; }
.data-notice strong { white-space: nowrap; }
.cost-method-note { margin: 8px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }

.employee-section { margin-top: 27px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 17px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.result-count { color: var(--muted); font-size: 11px; }

.table-frame { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: 0 4px 18px rgba(24, 33, 31, .04); }
.employee-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.employee-table th { height: 42px; padding: 0 12px; border-bottom: 1px solid var(--line); background: #f7f9f8; color: #6d7773; font-size: 10px; font-weight: 700; text-align: left; white-space: nowrap; }
.employee-table td { height: 66px; padding: 8px 12px; border-bottom: 1px solid #edf0ee; color: #34403c; font-size: 12px; vertical-align: middle; }
.employee-table tbody tr { outline: 0; transition: background-color .15s ease; }
.employee-table tbody tr:hover, .employee-table tbody tr:focus { background: #f7fbf9; }
.employee-table tbody tr:last-child td { border-bottom: 0; }
.employee-table th:nth-child(1) { width: 82px; }
.employee-table th:nth-child(2) { width: 180px; }
.employee-table th:nth-child(3) { width: 100px; }
.employee-table th:nth-child(4) { width: 105px; }
.employee-table th:nth-child(5) { width: 120px; }
.employee-table th:nth-child(6) { width: 112px; }
.employee-table th:nth-child(7) { width: 105px; }
.employee-table th:nth-child(8), .employee-table th:nth-child(9) { width: 120px; }
.employee-table th:nth-child(10) { width: 46px; }
.number-cell { text-align: center !important; }
.money-cell { text-align: right !important; white-space: nowrap; }
.money-cell strong { color: var(--ink); }
.used-cost { color: var(--teal) !important; font-weight: 700; }
.idle-cost { color: var(--coral) !important; font-weight: 700; }
.number-cell strong { color: var(--ink); font-size: 15px; }
.number-cell span { margin-left: 2px; color: #909995; font-size: 10px; }
.workday-cell small { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; white-space: nowrap; }
.employee-code { font-family: Consolas, monospace; color: #51605b; font-size: 11px; }

.employee-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.employee-identity > span:last-child { min-width: 0; }
.employee-identity strong, .employee-identity small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.employee-identity strong { color: var(--ink); font-size: 12px; }
.employee-identity small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.avatar { display: grid; flex: 0 0 auto; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: #dfeae6; color: #275b50; font-size: 12px; font-weight: 800; }
.avatar-large { width: 48px; height: 48px; background: #d6e9e3; font-size: 18px; }

.role-badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 4px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.role-driver { background: var(--blue-soft); color: #315f79; }
.role-housekeeper { background: var(--amber-soft); color: #825512; }

.utilization-cell { display: grid; gap: 6px; }
.utilization-cell strong { color: var(--ink); font-size: 11px; }
.progress-track { display: block; width: 100%; height: 5px; overflow: hidden; border-radius: 3px; background: #e8ecea; }
.progress-track > span { display: block; height: 100%; border-radius: inherit; background: var(--teal); }
.latest-location { display: block; overflow: hidden; color: #58645f; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.detail-button { display: grid; width: 30px; height: 30px; place-items: center; border: 0; border-radius: 50%; background: transparent; color: #6e7a76; font-size: 23px; }
.detail-button:hover, .detail-button:focus { background: #e8f1ee; color: var(--teal); outline: 0; }

.empty-state { display: none; min-height: 180px; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.empty-state.is-visible { display: flex; }
.empty-state strong { color: var(--ink); font-size: 14px; }
.empty-state span { margin-top: 5px; font-size: 11px; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(16, 25, 22, .42); }
.detail-drawer { position: fixed; inset: 0 0 0 auto; z-index: 50; width: min(520px, 100%); overflow: auto; transform: translateX(102%); background: #fff; box-shadow: -16px 0 40px rgba(24, 33, 31, .18); transition: transform .22s ease; }
.detail-drawer.is-open { transform: translateX(0); }
.drawer-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 18px; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .97); }
.drawer-person { display: flex; align-items: center; gap: 13px; min-width: 0; }
.drawer-person p { margin: 0 0 2px; color: var(--muted); font-family: Consolas, monospace; font-size: 10px; }
.drawer-person h2 { margin: 0 0 6px; font-size: 17px; }
.close-button { display: grid; flex: 0 0 auto; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: #55615d; font-size: 22px; line-height: 1; }
.close-button:hover, .close-button:focus { border-color: #aeb9b5; outline: 0; }
.drawer-body { padding: 20px 24px 36px; }
.drawer-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--line); }
.drawer-metrics div { padding: 13px 12px; background: #fff; }
.drawer-metrics span, .drawer-metrics strong { display: block; }
.drawer-metrics span { color: var(--muted); font-size: 10px; }
.drawer-metrics strong { margin-top: 5px; font-size: 18px; }
.calendar-section, .timeline-section { margin-top: 24px; }
.drawer-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.drawer-section-heading h3 { margin: 0; font-size: 13px; }
.drawer-section-heading > span { color: var(--muted); font-size: 10px; }
.calendar-legend { display: flex; gap: 10px; color: var(--muted); font-size: 9px; }
.calendar-legend span { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 7px; height: 7px; border-radius: 50%; }
.work-dot { background: var(--teal); }
.substitute-dot { background: var(--amber); }
.weekday-row, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.weekday-row { margin-bottom: 4px; color: #8b9591; font-size: 9px; text-align: center; }
.calendar-grid { gap: 4px; }
.calendar-day { position: relative; display: grid; aspect-ratio: 1; min-width: 0; place-items: center; border: 1px solid transparent; border-radius: 4px; color: #5f6a66; background: #f6f8f7; font-size: 10px; }
.calendar-day.is-empty { background: transparent; }
.calendar-day.has-work { border-color: #b6d8ce; background: var(--teal-soft); color: #155e50; font-weight: 700; }
.calendar-day.is-substitute { border-color: #edca88; background: var(--amber-soft); color: #7a5014; }
.calendar-day::after { content: ''; position: absolute; bottom: 4px; width: 3px; height: 3px; border-radius: 50%; background: transparent; }
.calendar-day.has-work::after { background: var(--teal); }
.calendar-day.is-substitute::after { background: var(--amber); }

.work-timeline { display: grid; gap: 0; }
.timeline-item { position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; padding: 0 0 18px; }
.timeline-item:not(:last-child)::after { content: ''; position: absolute; left: 69px; top: 17px; bottom: 0; width: 1px; background: var(--line); }
.timeline-date { color: var(--muted); font-size: 10px; text-align: right; }
.timeline-content { position: relative; min-width: 0; padding-left: 14px; }
.timeline-content::before { content: ''; position: absolute; left: -11px; top: 4px; z-index: 1; width: 7px; height: 7px; border: 2px solid #fff; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.timeline-item.is-substitute .timeline-content::before { background: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.timeline-content strong { display: block; color: var(--ink); font-size: 11px; }
.timeline-content small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.location-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.location-chip { max-width: 100%; padding: 4px 6px; border-radius: 3px; background: #f0f3f1; color: #52605b; font-size: 9px; line-height: 1.4; overflow-wrap: anywhere; }
.timeline-empty { padding: 28px 10px; color: var(--muted); font-size: 11px; text-align: center; }
body.drawer-open { overflow: hidden; }

@media (max-width: 1100px) {
    .control-band { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .table-frame { overflow-x: auto; }
    .employee-table { min-width: 1090px; }
}

@media (min-width: 1101px) and (max-width: 1300px) {
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .sidebar { position: static; width: 100%; height: 64px; flex-direction: row; align-items: center; padding: 9px 16px; }
    .brand { padding: 0; }
    .brand-mark { width: 34px; height: 34px; }
    .brand small { display: none; }
    .sidebar-nav { display: flex; margin: 0 0 0 auto; }
    .nav-item { min-height: 36px; padding: 0 9px; }
    .nav-item:not(.is-active), .nav-item.is-active .nav-symbol { display: none; }
    .sidebar-foot { display: none; }
    .main-content { margin-left: 0; padding: 22px 16px 38px; }
    .as-of { display: none; }
    .control-band { grid-template-columns: 1fr; align-items: stretch; gap: 12px; margin-top: 20px; }
    .report-filters { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; }
    .filter-field input, .filter-field select { width: 100%; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .kpi-card { min-height: 112px; padding: 14px; }
    .kpi-card strong { font-size: 24px; }
    .section-heading { align-items: flex-start; }
    .alert { flex-direction: column; }
}

@media (max-width: 430px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi-card { min-height: 98px; }
    .detail-drawer { width: 100%; }
    .drawer-header, .drawer-body { padding-left: 17px; padding-right: 17px; }
    .drawer-metrics strong { font-size: 16px; }
    .drawer-metrics { grid-template-columns: repeat(2, 1fr); }
    .report-filters { grid-template-columns: 1fr 1fr; }
    .export-button { width: 100%; grid-column: 1 / -1; }
    .data-notice { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
