:root {
    color-scheme: light;
    --bg: #f7f7f5;
    --surface: #ffffff;
    --line: #d8d8d2;
    --line-strong: #b8b8ae;
    --text: #20201d;
    --muted: #6b6b63;
    --soft: #eeeeea;
    --accent: #0f766e;
    --accent-soft: #d9efeb;
    --warn: #a16207;
    --warn-soft: #fff1cc;
    --bad: #b42318;
    --bad-soft: #ffe4df;
    --good: #166534;
    --good-soft: #dff2df;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
}

button:hover {
    background: var(--soft);
}

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

.search-pane {
    border-right: 1px solid var(--line);
    background: #fbfbf9;
    padding: 22px;
}

.brand {
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
}

.brand h1,
.topbar h2,
.drawer-head h3 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0;
}

.brand p,
.topbar p,
.drawer-head p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.field {
    display: grid;
    gap: 7px;
    margin-bottom: 14px;
}

.field span {
    color: var(--muted);
    font-size: 13px;
}

.field input,
.field select {
    width: 100%;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 11px;
    outline: none;
}

.field input:focus,
.field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.result-list {
    display: grid;
    gap: 6px;
    margin-top: 18px;
}

.result-item {
    width: 100%;
    text-align: left;
    border-color: transparent;
    background: transparent;
    padding: 10px;
}

.result-item strong,
.ledger-row strong {
    display: block;
    font-size: 14px;
    line-height: 1.25;
}

.result-item span,
.ledger-row span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.result-item.active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.workspace {
    min-width: 0;
    padding: 22px 26px 30px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.summary-strip {
    display: grid;
    grid-template-columns: repeat(6, minmax(110px, 1fr));
    gap: 1px;
    margin: 18px 0;
    border: 1px solid var(--line);
    background: var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.summary-item {
    background: var(--surface);
    padding: 13px;
    min-height: 70px;
}

.summary-item span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.summary-item strong {
    display: block;
    margin-top: 5px;
    font-size: 18px;
}

.calendar-wrap,
.ledger-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
}

.ledger-wrap {
    margin-top: 18px;
}

.calendar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 48px;
    padding: 0 14px;
    border-bottom: 1px solid var(--line);
}

.calendar-head span {
    color: var(--muted);
    font-size: 13px;
}

.dow-grid,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.dow-grid {
    border-bottom: 1px solid var(--line);
    background: #fbfbf9;
}

.dow-grid span {
    padding: 9px 10px;
    color: var(--muted);
    font-size: 12px;
    border-right: 1px solid var(--line);
}

.dow-grid span:last-child {
    border-right: 0;
}

.calendar-grid {
    min-height: 460px;
}

.day-cell {
    position: relative;
    min-height: 116px;
    padding: 10px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    cursor: pointer;
}

.day-cell:nth-child(7n) {
    border-right: 0;
}

.day-cell.empty {
    background: #fafaf8;
    cursor: default;
}

.day-cell:hover:not(.empty) {
    background: #f4f7f5;
}

.day-num {
    font-weight: 700;
    font-size: 13px;
}

.day-status {
    margin-top: 8px;
    font-size: 12px;
    font-weight: 700;
}

.day-times,
.day-worked,
.day-schedule {
    margin-top: 5px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.3;
}

.status-normal,
.status-present,
.status-ok {
    color: var(--good);
}

.status-late,
.status-missing {
    color: var(--warn);
}

.status-absent {
    color: var(--bad);
}

.cell-normal {
    background: var(--good-soft);
}

.cell-late,
.cell-missing {
    background: var(--warn-soft);
}

.cell-absent {
    background: var(--bad-soft);
}

.cell-rest {
    background: #ededeb;
}

.marker {
    position: absolute;
    right: 9px;
    top: 9px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

.ledger-list {
    display: grid;
    gap: 1px;
    background: var(--line);
}

.ledger-row {
    display: grid;
    grid-template-columns: 1fr 110px 110px;
    gap: 12px;
    background: var(--surface);
    padding: 12px 14px;
}

.empty-state {
    display: block;
    padding: 22px;
    color: var(--muted);
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 18, 0.28);
}

.day-drawer {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(420px, 100vw);
    background: var(--surface);
    border-left: 1px solid var(--line-strong);
    box-shadow: -6px 0 20px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
}

.drawer-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.drawer-content {
    overflow: auto;
    padding: 18px;
}

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

.detail {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.detail span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.detail strong {
    display: block;
    margin-top: 5px;
}

.punch-list {
    margin-top: 18px;
    display: grid;
    gap: 6px;
}

.punch-row {
    display: grid;
    grid-template-columns: 56px 1fr 70px;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
}

.punch-row strong {
    font-variant-numeric: tabular-nums;
}

.punch-row span {
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 900px) {
    .shell {
        display: block;
    }

    .search-pane {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

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

    .day-cell {
        min-height: 104px;
        padding: 8px;
    }

    .day-times,
    .day-worked,
    .day-schedule {
        font-size: 11px;
    }
}
