:root {
    --cw-primary: #3d5c99;
    --cw-primary-dark: #2f4778;
    --cw-dark: #010f21;
    --cw-dark-2: #000611;
    --bg: #f7f8fa;
    --surface: #ffffff;
    --text: #111111;
    --text-body: #666666;
    --muted: #888888;
    --danger: #c0392b;
    --weekend: #fff5f5;
    --night: #eef3fa;
    --border: #e2e6ec;
    --radius: 4px;
    --shadow: 0 2px 8px rgba(1, 15, 33, 0.08);
    --font: 'Open Sans', Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-body);
    line-height: 1.6;
    font-size: 15px;
}
h1, h2, h3 { color: var(--text); font-weight: 700; }
h1 { font-size: 1.75rem; margin: 0 0 .5rem; }
a { color: var(--cw-primary); }
.container { max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }

.header {
    background: linear-gradient(90deg, var(--cw-dark-2) 0%, var(--cw-dark) 47%);
    color: #fff;
    padding: .9rem 0;
    box-shadow: var(--shadow);
}
.header__inner { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logo { text-decoration: none; display: flex; align-items: center; gap: .4rem; }
.logo__img { height: 32px; width: auto; display: block; }
.logo__mark { font-weight: 700; font-size: 1.25rem; color: #fff; letter-spacing: .02em; }
.logo__sub { font-size: .85rem; color: rgba(255,255,255,.65); font-weight: 400; }
.header__client-logo { height: 28px; width: auto; border-radius: 3px; background: #fff; padding: 2px 4px; }
.header__project {
    color: rgba(255,255,255,.9);
    padding-left: 1rem;
    border-left: 1px solid rgba(255,255,255,.2);
    font-weight: 600;
}
.header__links { margin-left: auto; display: flex; gap: 1rem; align-items: center; }
.header__ext { color: rgba(255,255,255,.7); font-size: .85rem; text-decoration: none; }
.header__ext:hover { color: #fff; }

.nav {
    display: flex;
    gap: .35rem;
    flex-wrap: wrap;
    padding: .85rem 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}
.nav a {
    padding: .45rem .9rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-size: .9rem;
    font-weight: 600;
    border: 1px solid transparent;
}
.nav a:hover { background: #eef3fa; color: var(--cw-primary); border-color: var(--border); }

.main { padding: 1.75rem 1.25rem 3rem; }
.header__user { color: rgba(255,255,255,.75); font-size: .85rem; }
.session-timer {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .55rem;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: var(--radius);
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.9);
    font: inherit;
    font-size: .8rem;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.session-timer:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.45); }
.session-timer__label { opacity: .75; font-weight: 600; }
.session-timer__value { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 2.8rem; text-align: center; }
.session-timer--warn { border-color: #f59e0b; background: rgba(245, 158, 11, .15); }
.session-timer--critical { border-color: #ef4444; background: rgba(239, 68, 68, .2); animation: session-blink 1s step-end infinite; }
.session-timer--pulse { box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
@keyframes session-blink { 50% { opacity: .65; } }
.header__logout-form { display: inline; margin: 0; }
.header__logout { background: none; border: none; cursor: pointer; font: inherit; padding: 0; }
.header__logout:hover { color: #fff; }

.user-menu { position: relative; }
.user-menu__trigger {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .2rem .45rem .2rem .2rem;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 999px;
    background: rgba(255,255,255,.06);
    color: #fff;
    font: inherit;
    font-size: .85rem;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.user-menu__trigger:hover,
.user-menu--open .user-menu__trigger { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.35); }
.user-menu__avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255,255,255,.15);
    color: rgba(255,255,255,.9);
    flex-shrink: 0;
}
.user-menu__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.user-menu__avatar svg { width: 18px; height: 18px; }
.user-menu__name { font-weight: 600; max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu__dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + .35rem);
    min-width: 11rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 50;
    overflow: hidden;
}
.user-menu--open .user-menu__dropdown,
.user-menu:hover .user-menu__dropdown { display: block; }
.user-menu__dropdown a,
.user-menu__dropdown button {
    display: block;
    width: 100%;
    padding: .65rem .9rem;
    text-align: left;
    text-decoration: none;
    color: var(--text);
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    border: none;
    background: none;
    cursor: pointer;
}
.user-menu__dropdown a:hover,
.user-menu__dropdown button:hover { background: #eef3fa; color: var(--cw-primary); }
.user-menu__dropdown form { margin: 0; border-top: 1px solid var(--border); }

.app-release-label { margin: 0 0 .35rem; font-size: 1.05rem; color: var(--cw-primary); }
.avatar-upload { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .75rem; }
.avatar-upload__preview {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    background: #eef3fa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cw-primary);
    flex-shrink: 0;
}
.avatar-upload__img { width: 100%; height: 100%; object-fit: cover; }
.avatar-upload__placeholder svg { width: 32px; height: 32px; }
.avatar-upload__fields { flex: 1; min-width: 200px; }
.avatar-remove-form { margin: 0 0 1rem; }
.btn--small { font-size: .82rem; padding: .35rem .65rem; }

.notice-contract {
    background: #f7f8fa;
    border: 1px solid #d8dee8;
    border-left: 4px solid #8fa4c8;
    padding: 14px 18px;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.65;
    margin: 0 0 20px;
}
.notice-contract strong { color: #3d5c99; }

.stats-heatmap { width: 100%; border-collapse: collapse; margin-top: .5rem; }
.stats-heatmap td { text-align: center; font-size: .85rem; padding: .65rem .5rem; border: 1px solid var(--border); }
.stats-heatmap .heat-day { font-weight: 700; display: block; margin-bottom: .15rem; }
.stats-heatmap .heat-0 { background: #f8fafc; }
.stats-heatmap .heat-1 { background: #dde6f3; }
.stats-heatmap .heat-2 { background: #b8c9e8; }
.stats-heatmap .heat-3 { background: #3d5c99; color: #fff; }
.stats-amounts { margin: 0; padding: 0; list-style: none; }
.stats-amounts li {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    padding: .45rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}
.stats-amounts li:last-child { border-bottom: none; font-weight: 700; color: var(--cw-primary); }

.auth-page { min-height: 100vh; display: flex; flex-direction: column; }
.auth-page__footer { margin-top: auto; }
.auth-card-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 1.35rem; margin: 0 0 .35rem; }
.auth-card__brand { text-align: center; margin-bottom: 1.25rem; }
.auth-card__logo { max-height: 40px; width: auto; }
.auth-card__title { font-size: 1.2rem; color: var(--cw-primary); }
.auth-card__version { margin: 1.25rem 0 0; text-align: center; font-size: .8rem; color: #888; }
.auth-form label { display: block; margin: .75rem 0; font-weight: 600; font-size: .9rem; }
.auth-form input { width: 100%; margin-top: .35rem; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; }
.btn--block { width: 100%; justify-content: center; }

.footer {
    background: rgba(0,0,0,.85);
    color: rgba(255,255,255,.6);
    padding: 1.25rem 0;
    margin-top: 2rem;
}
.footer__inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; }
.footer a { color: rgba(255,255,255,.8); text-decoration: none; }
.footer a:hover { color: #fff; text-decoration: underline; }

.muted { color: var(--muted); }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem; }
.page-header__actions { display: flex; gap: .35rem; align-items: center; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--cw-primary); transform: translateY(-1px); }
.card h2 { margin: 0 0 .25rem; font-size: 1.05rem; color: var(--cw-primary); }
.card__desc { margin: 0; font-size: .82rem; }
.card__icon { display: block; color: var(--cw-primary); margin-bottom: .4rem; line-height: 0; }
.card--home .card__icon svg { display: block; }
.card--info { cursor: default; }
.card--info:hover { transform: none; border-color: var(--border); }
.card--empty { grid-column: 1 / -1; }

.btn {
    display: inline-block;
    padding: .55rem 1.15rem;
    border-radius: var(--radius);
    border: 2px solid transparent;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    font-size: .9rem;
    font-weight: 600;
    font-family: var(--font);
    background: var(--surface);
    border-color: var(--border);
    transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--cw-primary); color: var(--cw-primary); }
.btn--primary { background: var(--cw-primary); color: #fff; border-color: var(--cw-primary); }
.btn--primary:hover { background: var(--cw-primary-dark); border-color: var(--cw-primary-dark); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: #eef3fa; }
.btn--sm { padding: .3rem .65rem; font-size: .8rem; }

.filters {
    background: var(--surface);
    padding: 1rem 1.15rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.filters__row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.filters label { display: flex; flex-direction: column; gap: .25rem; font-size: .82rem; font-weight: 600; color: var(--text); }
input, select, textarea {
    padding: .5rem .65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--cw-primary);
    box-shadow: 0 0 0 2px rgba(61, 92, 153, .15);
}

.stats-bar { display: flex; gap: 1.5rem; margin-bottom: 1rem; flex-wrap: wrap; font-size: .9rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; margin-top: 1rem; }
.stats-grid .card { cursor: default; min-width: 0; }
.stats-grid .card:hover { transform: none; border-color: var(--border); }
.stats-grid .card h2 { margin: 0 0 .75rem; }
.stats-grid__full { grid-column: 1 / -1; }
.stats-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.stats-weekday-table { width: 100%; min-width: 22rem; }
.stats-weekday-table .num { text-align: right; white-space: nowrap; }
.stat-row { display: flex; align-items: center; gap: .6rem; margin: .4rem 0 .15rem; font-size: .88rem; }
.stat-row__label { flex: 0 0 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-row__bar { flex: 1; height: 12px; background: #eef3fa; border-radius: 2px; min-width: 40px; }
.stat-row__fill { height: 100%; background: var(--cw-primary); border-radius: 2px; min-width: 2px; }
.stat-row__value { flex: 0 0 52px; text-align: right; font-weight: 600; font-size: .82rem; white-space: nowrap; }
.stat-row__meta { margin: 0 0 .5rem calc(120px + .6rem); font-size: .78rem; line-height: 1.35; }
.table--compact th, .table--compact td { padding: .45rem .6rem; font-size: .82rem; }
.table-wrap { overflow-x: auto; box-shadow: var(--shadow); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { padding: .65rem .8rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; font-size: .88rem; }
.table th { background: #f0f3f8; font-weight: 700; color: var(--text); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.row--weekend { background: var(--weekend); }
.row--night { background: var(--night); }
.row--emergency { background: #fff8f0; }
.row--inactive { opacity: .5; }
.worksheet tbody tr.data-row:nth-child(4n+1),
.worksheet tbody tr.data-row:nth-child(4n+3) { background: #f8fafc; }
.worksheet tbody tr.data-row.row--weekend:nth-child(4n+1),
.worksheet tbody tr.data-row.row--weekend:nth-child(4n+3) { background: #fff0f0; }
.worksheet tbody tr.data-row.row--night:nth-child(4n+1),
.worksheet tbody tr.data-row.row--night:nth-child(4n+3) { background: #e8eef8; }
.table tbody tr.data-row:nth-child(even) { background: #f8fafc; }
.badge { font-size: .72rem; padding: .2rem .45rem; border-radius: 3px; font-weight: 600; }
.badge--emergency { background: #fde8d0; color: #8b4513; }
.badge--service { background: #e8f5e9; color: #2e7d32; }
.badge--trip { background: #eef3fa; color: var(--cw-primary); font-weight: 600; }
.trip-fields { margin-top: .75rem; }

.form {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.form__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.form--hours .form__section--flat { margin: 0 0 1.25rem; padding: 0; border-top: none; }
.form--hours .form__section--flat h3 { margin: 0 0 .75rem; font-size: .95rem; color: var(--cw-primary); }
.form--hours .form label input,
.form--hours .form label select,
.form--hours .form__notes textarea,
.form--hours .markdown-editor { width: 100%; max-width: 100%; box-sizing: border-box; }
.form--hours .form__notes { display: block; margin: 1rem 0; }
.multiplier-auto__value {
    background: #eef3fa;
    color: var(--cw-primary);
    font-weight: 700;
    cursor: default;
}
.multiplier-auto__hint { color: var(--muted); font-weight: 400; }
.form__grid--flags { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.form label { display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; font-weight: 600; color: var(--text); min-width: 0; }
.form label small { font-weight: 400; color: var(--muted); }
.form label.checkbox { flex-direction: row; align-items: center; font-weight: 400; }
.form__section { margin: 1.25rem 0; padding-top: 1rem; border-top: 1px solid var(--border); }
.form__section h3 { margin: 0 0 .75rem; font-size: 1rem; color: var(--cw-primary); }
.form__actions { display: flex; gap: .5rem; margin-top: 1.25rem; flex-wrap: wrap; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.card--info h2 { margin: 0 0 .75rem; font-size: .95rem; display: flex; justify-content: space-between; align-items: center; color: var(--text); }
.card--info dl { display: grid; grid-template-columns: 1fr auto; gap: .35rem .75rem; margin: 0; font-size: .88rem; }
.card--info dt { color: var(--muted); }
.card--info dd { margin: 0; font-weight: 600; color: var(--text); text-align: right; }
.contact-list { list-style: none; padding: 0; margin: 0; }
.contact-list li { padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.summary-grid dl { display: grid; grid-template-columns: 1fr auto; gap: .35rem .75rem; margin: 0; }
.summary-grid dt { color: var(--muted); }
.summary-grid .total { font-size: 1.1rem; border-top: 1px solid var(--border); padding-top: .5rem; margin-top: .25rem; }

.worksheet .insert-row td { padding: .25rem .8rem; background: #f5f7fb; border-bottom: 1px dashed var(--border); }
.insert-link { font-size: .78rem; color: var(--muted); text-decoration: none; font-weight: 600; }
.insert-link:hover { color: var(--cw-primary); }

.hint-box, .alert {
    padding: .85rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .9rem;
}
.hint-box { background: #eef3fa; border: 1px solid #c5d4ea; color: var(--text); }
.hint-box--ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert--success { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert--warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert--error { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }
.logo-preview { max-height: 48px; margin-top: .5rem; }
.client-logo { max-height: 56px; margin-bottom: .5rem; }
.card--client { display: flex; flex-direction: column; align-items: flex-start; min-height: 140px; }
.card__logo {
    height: 48px;
    width: 100%;
    max-width: 160px;
    margin-bottom: .65rem;
    object-fit: contain;
    object-position: left center;
}
.checkbox--emergency { grid-column: 1 / -1; border: 1px dashed #d4a574; padding: .6rem; border-radius: var(--radius); background: #fffaf5; }
.formula-hint { margin-top: 1rem; font-size: .88rem; color: var(--muted); }

.notes-cell { max-width: 280px; }
.markdown-preview { font-size: .85rem; }
.actions { white-space: nowrap; }
.actions form { display: inline; }
.link-danger { background: none; border: none; color: var(--danger); cursor: pointer; text-decoration: underline; padding: 0; font: inherit; }
.empty { text-align: center; color: var(--muted); padding: 2rem !important; }

.page-header__actions--wrap { flex-wrap: wrap; }
.btn--preview { font-size: .95rem; }
.reopen-form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.reopen-form__check { font-weight: 400; font-size: .85rem; margin: 0; }

.audit-log { margin-top: 1.25rem; }
.audit-log__list { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.audit-log__list li { padding: .45rem 0; border-bottom: 1px solid var(--border); }
.audit-log__list time { color: var(--muted); margin-right: .5rem; font-size: .82rem; }

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    margin-left: auto;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: var(--radius);
    background: rgba(255,255,255,.08);
    cursor: pointer;
}
.nav-toggle__bar {
    display: block;
    height: 2px;
    background: #fff;
    border-radius: 1px;
}

.hours-cards { display: none; }
.hours-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: .75rem;
    box-shadow: var(--shadow);
}
.hours-card--weekend { background: var(--weekend); }
.hours-card--night { background: var(--night); }
.hours-card__head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .65rem; }
.hours-card__meta { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem .75rem; margin: 0; font-size: .85rem; }
.hours-card__meta div { display: contents; }
.hours-card__meta dt { color: var(--muted); font-weight: 600; }
.hours-card__meta dd { margin: 0; }
.hours-card__notes { font-size: .85rem; margin-top: .5rem; }
.hours-card__actions { display: flex; gap: .75rem; margin-top: .75rem; padding-top: .5rem; border-top: 1px solid var(--border); font-size: .88rem; }

@media (max-width: 1024px) {
    .form--hours .form__grid--time {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .header__project { display: none; }
    .header__client-logo { display: none; }
    .header__user { display: none; }
    .nav-toggle { display: flex; }
    .header__links { margin-left: 0; gap: .5rem; }

    .nav {
        display: none;
        flex-direction: column;
        align-items: stretch;
        padding: 0;
        border-bottom: none;
    }
    .nav.nav--open {
        display: flex;
        padding: .5rem 0 1rem;
        border-bottom: 1px solid var(--border);
    }
    .nav a {
        border-radius: 0;
        border-bottom: 1px solid var(--border);
        padding: .75rem 1.25rem;
    }

    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header__actions { width: 100%; }
    .page-header__actions .btn,
    .page-header__actions form { flex: 1 1 auto; }

    .filters__row { flex-direction: column; align-items: stretch; }
    .filters label { width: 100%; }
    .form__grid,
    .form--hours .form__grid,
    .form--hours .form__grid--time { grid-template-columns: 1fr; }
    .form--hours { padding: 1rem; }
    .form--hours .form__actions { flex-direction: column; }
    .form--hours .form__actions .btn { width: 100%; text-align: center; }

    .hours-table { display: none; }
    .hours-cards { display: block; }

    .summary-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    .stat-row__label { flex: 0 0 5.5rem; }
    .stat-row__value { flex: 0 0 2.75rem; }
    .stat-row__meta { margin-left: calc(5.5rem + .6rem); }
}

.rate-toggle { display: none; }
.rate-toggle.is-visible { display: contents; }
