:root {
    --bg: #f5f7f8;
    --ink: #17202a;
    --muted: #66727f;
    --line: #dce3e8;
    --panel: #ffffff;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --danger: #b42318;
    --weekend: #fff7ed;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.4;
}

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
    padding: 12px clamp(16px, 4vw, 40px);
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

.brand {
    font-weight: 800;
    font-size: 20px;
    text-decoration: none;
}

.nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 650;
}

.page {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 24px clamp(14px, 4vw, 32px) 48px;
}

.auth-panel,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.auth-panel {
    max-width: 420px;
    margin: 8vh auto 0;
}

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

h1 {
    font-size: clamp(26px, 4vw, 38px);
    margin-bottom: 8px;
}

h2 {
    font-size: 20px;
}

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

.form,
.compact-form,
.inline-form {
    display: grid;
    gap: 12px;
}

.inline-form {
    display: inline;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-weight: 650;
}

input,
select,
button,
.button-link {
    min-height: 44px;
    border-radius: 8px;
    font: inherit;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--ink);
    padding: 0 12px;
}

button,
.button-link {
    border: 0;
    background: var(--accent);
    color: #ffffff;
    padding: 0 16px;
    font-weight: 750;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover,
.button-link:hover {
    background: var(--accent-strong);
}

button.ghost {
    background: transparent;
    color: var(--muted);
    padding: 0 4px;
}

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

.error {
    color: var(--danger);
    font-weight: 700;
}

.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.month-switch {
    display: grid;
    grid-template-columns: 44px minmax(96px, auto) 44px;
    align-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.month-switch a,
.month-switch span {
    min-height: 44px;
    display: grid;
    place-items: center;
    text-decoration: none;
    font-weight: 800;
}

.month-switch span {
    border-inline: 1px solid var(--line);
}

.days {
    display: grid;
    gap: 8px;
}

.day-row {
    display: grid;
    grid-template-columns: 86px minmax(128px, 160px) minmax(80px, 110px) 1fr 94px;
    gap: 8px;
    align-items: center;
    padding: 10px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.day-row.rest-day,
tr.rest-day td {
    background: var(--weekend) !important;
}

.day-row:target {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
    scroll-margin-top: 84px;
}

.day-title {
    display: grid;
    gap: 2px;
}

.day-title strong {
    font-size: 18px;
}

.day-title span,
.user-row span {
    color: var(--muted);
    font-size: 14px;
}

.grid.two {
    display: grid;
    grid-template-columns: minmax(280px, 380px) 1fr;
    gap: 18px;
    align-items: start;
}

.user-list {
    display: grid;
    gap: 12px;
}

.worker-view {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 18px;
    align-items: start;
}

.worker-menu {
    position: sticky;
    top: 84px;
}

.worker-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.worker-links a,
.worker-button {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none !important;
    font-weight: 750;
    background: #ffffff;
    line-height: 1;
}

.worker-links a.active,
.worker-links a:hover,
.worker-button.active,
.worker-button:hover {
    border-color: var(--accent);
    background: #ecfdf5;
    color: var(--accent-strong);
    text-decoration: none !important;
}

.detail-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

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

.note-cell {
    min-width: 220px;
    white-space: normal;
}

.user-row {
    display: grid;
    grid-template-columns: minmax(160px, 1fr) minmax(260px, 420px);
    gap: 12px;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.user-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.compact-form {
    grid-template-columns: 1fr auto auto;
}

.table-wrap {
    overflow-x: auto;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

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

th {
    color: var(--muted);
    font-size: 14px;
}

tr:last-child td {
    border-bottom: 0;
}

.actions {
    margin-top: 16px;
}

@media (max-width: 820px) {
    .topbar,
    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .nav {
        justify-content: flex-start;
    }

    .day-row {
        grid-template-columns: 72px 1fr 84px;
    }

    .day-row input[name="note"],
    .day-row button {
        grid-column: 1 / -1;
    }

    .grid.two,
    .worker-view,
    .user-row {
        grid-template-columns: 1fr;
    }

    .worker-menu {
        position: static;
    }

    .compact-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 430px) {
    .page {
        padding-inline: 10px;
    }

    .day-row {
        grid-template-columns: 1fr 1fr;
    }

    .day-title {
        grid-column: 1 / -1;
        grid-template-columns: auto auto;
        justify-content: space-between;
    }
}
