:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --panel: #ffffff;
    --text: #1d252c;
    --muted: #64717d;
    --line: #dce3e8;
    --primary: #216869;
    --primary-dark: #174f50;
    --accent: #d88c45;
    --warn: #b3532b;
    --ok: #e4f4ee;
    --shadow: 0 18px 40px rgba(28, 41, 52, 0.08);
}

* {
    box-sizing: border-box;
}

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

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

h1, h2 {
    margin: 0 0 12px;
    line-height: 1.1;
}

h1 {
    font-size: 32px;
}

h2 {
    font-size: 20px;
}

button,
.button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 9px 14px;
    font: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover,
.button:hover {
    border-color: var(--primary);
}

.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.primary:hover {
    background: var(--primary-dark);
    color: #fff;
}

.danger {
    border-color: #f0b8ad;
    color: #a33a2d;
    background: #fff4f2;
}

.danger:hover {
    border-color: #c7443e;
    color: #87291f;
}

input,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 9px 11px;
    font: inherit;
}

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

fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

legend {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 8px;
}

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

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

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

td small {
    display: block;
    color: var(--muted);
    margin-top: 2px;
}

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

.brand {
    color: var(--text);
    font-weight: 750;
}

.topbar nav {
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--muted);
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 80px;
}

.auth-panel {
    width: min(430px, 100%);
    margin: 56px auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}

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

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

.flash,
.notice {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 18px;
}

.flash.ok,
.notice {
    background: var(--ok);
}

.flash.error,
.notice.warn {
    background: #fff0e9;
    color: var(--warn);
    border: 1px solid #f1c5ae;
}

.mobile-workspace {
    width: min(720px, 100%);
    margin: 0 auto;
}

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

.section-head form {
    min-width: 180px;
}

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

.time-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.task-editor {
    padding-bottom: 72px;
}

.task-grid {
    display: grid;
    grid-template-columns: minmax(150px, 1.2fr) minmax(130px, 1fr) 96px 98px 96px minmax(130px, 1fr);
    gap: 8px;
    align-items: end;
}

.day-calendar {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
    min-height: 960px;
}

.hour-rail,
.calendar-lane {
    display: grid;
    grid-template-rows: repeat(64, 15px);
}

.hour-rail {
    color: var(--muted);
    font-size: 12px;
}

.hour-rail span {
    transform: translateY(-8px);
}

.calendar-lane {
    position: relative;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: repeating-linear-gradient(
        to bottom,
        #ffffff 0,
        #ffffff 14px,
        #f2f5f7 15px,
        #ffffff 60px
    );
    overflow: hidden;
}

.hour-line {
    border-top: 1px solid var(--line);
    pointer-events: none;
}

.calendar-block {
    grid-row: var(--slot) / span var(--span);
    margin: 3px 8px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    min-height: 0;
    z-index: 2;
}

.calendar-event {
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 1px solid rgba(29, 37, 44, 0.12);
    border-left: 5px solid rgba(29, 37, 44, 0.28);
    border-radius: 8px;
    padding: 6px 8px;
    display: grid;
    align-content: start;
    gap: 1px;
    text-align: left;
    color: #172026;
    overflow: hidden;
    box-shadow: 0 8px 18px rgba(28, 41, 52, 0.08);
}

.calendar-event strong,
.calendar-event span,
.calendar-event small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-event strong {
    font-size: 12px;
}

.calendar-event span {
    font-size: 13px;
    font-weight: 700;
}

.calendar-event small {
    font-size: 11px;
}

.type-office .calendar-event,
.type-home_office .calendar-event {
    background: #dff4e8;
    border-left-color: #1f8a55;
}

.type-travel .calendar-event {
    background: #fff0bf;
    border-left-color: #c9921e;
}

.type-sick_leave .calendar-event {
    background: #ffe0df;
    border-left-color: #c7443e;
}

.type-break .calendar-event {
    background: #e6eaee;
    border-left-color: #7b8791;
}

.task-modal {
    width: min(760px, calc(100% - 24px));
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 28px 70px rgba(28, 41, 52, 0.22);
}

.task-modal::backdrop {
    background: rgba(20, 30, 38, 0.38);
}

.modal-head,
.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.modal-head {
    margin-bottom: 14px;
}

.modal-actions {
    justify-content: flex-end;
    margin-top: 16px;
}

.time-row small {
    display: block;
    color: var(--muted);
    margin-top: 2px;
}

.time-inputs {
    display: grid;
    grid-template-columns: 74px auto 74px auto;
    align-items: center;
    gap: 7px;
    color: var(--muted);
}

.time-inputs input {
    text-align: center;
    font-size: 18px;
}

.sticky-actions {
    position: sticky;
    bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 12px;
    font-weight: 700;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
    gap: 18px;
}

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

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

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}

.filter-grid {
    display: grid;
    grid-template-columns: 150px minmax(160px, 1fr) minmax(160px, 1fr) auto auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
}

.checkline {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    color: var(--text);
}

.checkline input {
    width: auto;
    min-height: 0;
}

.metric {
    margin: 0 0 4px;
    font-size: 30px;
    font-weight: 760;
}

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

tr.over {
    background: #fff5ef;
}

tr.over td:last-child {
    color: var(--warn);
    font-weight: 700;
}

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

.days legend {
    width: 100%;
}

.days label {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 9px;
    color: var(--text);
}

.days input {
    width: auto;
    min-height: 0;
}

.project-list {
    display: grid;
    gap: 10px;
}

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

.user-card {
    display: grid;
    grid-template-columns: minmax(180px, 1.2fr) minmax(120px, 0.6fr) minmax(120px, 0.6fr) minmax(260px, 1.4fr) auto;
    align-items: end;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.user-card small {
    display: block;
    color: var(--muted);
    margin-top: 2px;
}

.user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.user-details {
    display: grid;
    gap: 10px;
}

.user-detail {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.user-detail summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 14px;
}

.user-detail .table-wrap,
.user-detail .notice {
    margin: 0 14px 14px;
}

.project-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.project-card small {
    display: block;
    color: var(--muted);
}

.empty {
    color: var(--muted);
    background: #fff;
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 18px;
}

.calendar-empty {
    grid-row: 1 / span 6;
    margin: 10px;
    align-self: start;
    z-index: 1;
}

@media (max-width: 760px) {
    .topbar {
        padding: 0 16px;
    }

    .topbar nav span {
        display: none;
    }

    .shell {
        width: min(100% - 20px, 1180px);
        padding-top: 18px;
    }

    h1 {
        font-size: 27px;
    }

    .section-head,
    .time-row,
    .project-card,
    .user-card {
        grid-template-columns: 1fr;
    }

    .section-head {
        display: grid;
    }

    .section-head form {
        min-width: 0;
    }

    .time-inputs {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
    }

    .day-calendar {
        grid-template-columns: 46px minmax(0, 1fr);
    }

    .task-grid {
        grid-template-columns: 1fr 1fr;
    }

    .task-grid label:first-child,
    .task-grid label:nth-child(2),
    .task-grid label:last-child {
        grid-column: 1 / -1;
    }

    .calendar-block {
        margin: 3px 5px;
        min-height: 0;
    }

    .calendar-event {
        padding: 5px 6px;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .filter-grid {
        grid-template-columns: 1fr;
    }

    .auth-panel,
    .panel {
        padding: 16px;
    }
}
