:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(18px, calc(16px + .18vw), 20px);
  --bg: #202124;
  --surface: #2a2b2f;
  --surface-2: #34353a;
  --line: #585960;
  --text: #faf7f8;
  --muted: #d4cfd1;
  --wine: #a92f4b;
  --wine-light: #f08aa0;
  --wine-soft: #4a202b;
  --good: #8addbd;
  --good-bg: #173a30;
  --warn: #f1cc7d;
  --warn-bg: #443619;
  --bad: #ff9cac;
  --bad-bg: #4b222b;
  --radius: 1rem;
  --shadow: 0 3px 12px rgb(0 0 0 / .15);
}

* { box-sizing: border-box; }
.personal-settings { max-width: 60rem; }
.proposals-page { max-width: 64rem; margin-inline: auto; }
.proposal-list-row { width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; margin-block: .5rem; text-align: left; }
.proposal-list-row > * { min-width: 0; overflow-wrap: anywhere; }
.proposal-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.proposal-preview { display: block; width: 100%; height: 32rem; margin-top: .75rem; border: 1px solid var(--line); border-radius: .5rem; background: white; }
.personal-settings > label { display: grid; gap: .4rem; max-width: 24rem; margin-bottom: 1rem; }
.preference-route { display: grid; grid-template-columns: minmax(0, 1fr) minmax(7rem, .4fr) minmax(5rem, .3fr); align-items: start; gap: .75rem; padding-block: .75rem; border-bottom: 1px solid var(--line); }
.preference-route label { min-width: 0; }
.preference-route input[type="checkbox"] { width: 28px; height: 44px; min-height: 44px; margin: 0; accent-color: var(--wine); }
.preference-route input, .preference-route select { max-width: 100%; }
.preference-actions { flex-wrap: wrap; }
body[data-density="compact"] .card { padding: .75rem; }
body[data-density="compact"] .list-item { padding-block: .5rem; }
body[data-density="compact"] .section { margin-top: .75rem; }
@media (max-width: 600px) {
  .preference-route { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .preference-route > label:first-child { grid-column: 1 / -1; }
  .preference-actions > button { width: 100%; }
}
html, body { min-width: 0; min-height: 100%; margin: 0; background: var(--bg); }
body { color: var(--text); line-height: 1.5; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: .65rem; padding: .75rem; display: grid; gap: .5rem; }
.hint { overflow-wrap: anywhere; min-width: 0; }
fieldset label { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: .75rem; }
fieldset input[type="checkbox"] { width: 24px; min-height: 24px; flex: 0 0 24px; }
input[type="file"], details, .stack, form { min-width: 0; max-width: 100%; }
details > summary { cursor: pointer; min-height: 44px; padding-block: .5rem; overflow-wrap: anywhere; }
.status.cancelled { border: 1px solid var(--line); color: var(--muted); }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--wine-light); outline-offset: 2px; }
.skip-link { position: fixed; z-index: 99; top: .6rem; left: .6rem; padding: .7rem 1rem; background: var(--wine); color: white; border-radius: .6rem; transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.loading, .fatal { min-height: 100vh; display: grid; place-items: center; padding: 2rem; text-align: center; }
.login-screen { padding: clamp(.75rem, 4vw, 2rem); }
.login-card { width: min(100%, 36rem); padding: clamp(.8rem, 4vw, 2rem); }
.login-logo { width: min(100%, 520px); aspect-ratio: 4000 / 958; margin-inline: auto; background-color: var(--wine); mask: url('/mahov-logo.png') center / contain no-repeat; -webkit-mask: url('/mahov-logo.png') center / contain no-repeat; }
.shell { min-height: 100vh; padding-bottom: calc(8rem + env(safe-area-inset-bottom)); }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem clamp(.8rem, 3vw, 2.2rem); border-bottom: 1px solid var(--line); background: rgb(32 33 36 / .94); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.brand-mark { display: grid; place-items: center; flex: 0 0 2.6rem; width: 2.6rem; height: 2.6rem; border-radius: .8rem; background: linear-gradient(145deg, #73192e, var(--wine)); font-weight: 900; }
.brand-copy { min-width: 0; }
.brand-copy strong, .brand-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-copy small { color: var(--muted); font-size: .78rem; }
.top-actions { display: flex; align-items: center; gap: .5rem; }
.project-select { max-width: min(34vw, 18rem); }
.container { width: 100%; margin: 0 auto; padding: clamp(1rem, 2.5vw, 2rem); }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .2rem; font-size: clamp(1.55rem, 3.6vw, 2.4rem); line-height: 1.12; }
h2 { margin-bottom: .8rem; font-size: 1.18rem; }
h3 { margin-bottom: .45rem; font-size: 1rem; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .83rem; }
.synthetic { display: inline-flex; padding: .28rem .65rem; border: 1px solid #90546a; border-radius: 999px; color: #ffdbe4; background: var(--wine-soft); font-size: .78rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); gap: 1rem; align-items: start; }
.card { min-width: 0; padding: clamp(.8rem, 1.5vw, 1.1rem); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card.flush { padding: 0; overflow: hidden; }
.metric strong { display: block; margin-top: .25rem; font-size: clamp(1.3rem, 4vw, 2rem); font-variant-numeric: tabular-nums; }
.metric.accent { border-color: #9c4960; background: linear-gradient(145deg, var(--wine-soft), var(--surface)); }
.section { margin-top: 1.2rem; }
.stack { display: grid; gap: .85rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.between { justify-content: space-between; }
.list { display: grid; gap: .65rem; }
.list-item { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem 1rem; padding: .85rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--surface-2); }
.list-item p { margin-bottom: 0; }
.money { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.status { display: inline-flex; align-items: center; padding: .2rem .55rem; border-radius: 999px; font-size: .78rem; }
.status.pending { color: var(--warn); background: var(--warn-bg); }
.status.accepted, .status.approved { color: var(--good); background: var(--good-bg); }
.status.absent, .status.error { color: var(--bad); background: var(--bad-bg); }
.status.sent { color: #cbd8ff; background: #25304e; }
form { display: grid; gap: .8rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: .8rem; }
label { display: grid; align-content: start; gap: .35rem; color: var(--muted); font-size: .86rem; }
input, select, textarea { width: 100%; min-height: 2.8rem; padding: .58rem .7rem; border: 1px solid var(--line); border-radius: .65rem; background: #222327; }
textarea { min-height: 5.3rem; resize: vertical; }
.button { display: inline-flex; min-height: 2.8rem; align-items: center; justify-content: center; padding: .55rem .9rem; border: 1px solid #c84e69; border-radius: .7rem; color: white; background: var(--wine); font-weight: 750; text-decoration: none; }
.button.secondary { border-color: var(--line); background: var(--surface-2); }
.button.ghost { border-color: transparent; background: transparent; }
.button:disabled { cursor: wait; opacity: .55; }
.month-control { display: grid; gap: .5rem; width: 100%; max-width: 100%; }
.page-head > .month-control { flex: 1 1 18rem; }
.page-head > .row { flex: 1 1 22rem; }
.month-navigation { display: grid; grid-template-columns: 2.8rem minmax(0, 1fr) 2.8rem; gap: .25rem; }
.month-arrow { padding-inline: .25rem; font-size: 1.5rem; line-height: 1; }
.month-label { min-width: 0; padding-inline: .5rem; white-space: nowrap; font-size: .9rem; }
.month-picker { padding: .65rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--surface); }
.month-fallback { display: grid; gap: .5rem; }
.period-loading { display: grid; justify-items: center; gap: 1rem; padding-top: 2rem; }
.calendar-wrap { min-width: 0; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .2rem; width: 100%; }
.weekday, .day { min-width: 0; text-align: center; }
.weekday { padding: .3rem 0; color: var(--muted); font-size: .8rem; }
.day { position: relative; display: grid; min-height: 2.5rem; place-items: center; padding: .2rem; border: 1px solid transparent; border-radius: .55rem; background: #232428; font-size: .8rem; }
.day.blank { visibility: hidden; }
.day.approved { border-color: #45896f; background: var(--good-bg); }
.day.pending { border-color: #9b7933; background: var(--warn-bg); }
.day.absent { border-color: #9f4455; background: var(--bad-bg); }
.day.unmarked { color: #aaa4a6; }
.day[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--wine-light); }
.day-marker { position: absolute; right: .15rem; bottom: 0; font-size: .65rem; line-height: 1; }
.calendar-legend { margin: .5rem 0; }
.day-details { margin-top: .65rem; padding-top: .65rem; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.day-details p { margin-bottom: .4rem; }
.day-edit { margin-top: .65rem; }
.rates-panel { margin-bottom: 1rem; }
.rate-person + .rate-person { padding-top: .65rem; border-top: 1px solid var(--line); }
.rate-person p { margin-bottom: .4rem; overflow-wrap: anywhere; }
.day-edit summary { min-height: 2.5rem; display: flex; align-items: center; color: var(--wine-light); }
.person-card { display: grid; gap: .9rem; }
.person-card + .person-card { margin-top: 1rem; }
.payroll-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem 1rem; margin: 0 0 .6rem; padding-block: .6rem; border-block: 1px solid var(--line); }
.payroll-values dt { color: var(--muted); font-size: .83rem; }
.payroll-values dd { margin: .15rem 0 0; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.payroll-schedules { margin-bottom: 1rem; }
.payroll-person + .payroll-person { padding-top: .65rem; border-top: 1px solid var(--line); }
.payroll-person p { margin: .3rem 0 0; }
.payroll-amount { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.payroll-status { display: grid; gap: .65rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; min-width: 38rem; border-collapse: collapse; background: var(--surface); }
th, td { padding: .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .78rem; }
.check-row { display: flex; align-items: flex-start; gap: .6rem; }
.check-row input { width: 1.25rem; min-height: 1.25rem; margin-top: .15rem; }
.notice { position: fixed; z-index: 60; right: 1rem; bottom: 5.7rem; width: min(calc(100% - 2rem), 30rem); padding: .9rem 1rem; border: 1px solid #487e6b; border-radius: .8rem; color: var(--good); background: #17362d; box-shadow: var(--shadow); }
.notice.error { border-color: #a4485a; color: var(--bad); background: #462029; }
.notice.warn { border-color: #95732f; color: var(--warn); background: #403315; }
.bottom-nav { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .2rem; padding: .45rem max(.45rem, env(safe-area-inset-right)) calc(.45rem + env(safe-area-inset-bottom)) max(.45rem, env(safe-area-inset-left)); border-top: 1px solid var(--line); background: rgb(32 33 36 / .97); }
.nav-link { display: grid; min-width: 0; min-height: 2.8rem; place-items: center; padding: .3rem .2rem; border-radius: .65rem; color: var(--muted); font-size: .8rem; text-align: center; text-decoration: none; overflow-wrap: anywhere; }
.nav-link.active { color: white; background: var(--wine-soft); }
.empty { padding: 1rem; border: 1px dashed var(--line); border-radius: .75rem; color: var(--muted); text-align: center; }
summary { cursor: pointer; }
.history-entry summary { display: grid; gap: .2rem; }
.history-title { font-weight: 800; }
.history-meta, .history-reason { color: var(--muted); font-size: .78rem; }
.change-list { display: grid; gap: .5rem; margin: 0; padding-left: 1.2rem; }
.change-list li { padding-left: .2rem; overflow-wrap: anywhere; }
.estimate-visibility { display: grid; gap: .7rem; }
.estimate-room { border-top: 1px solid var(--line); padding-top: .55rem; }
.estimate-room summary { min-height: 2.5rem; display: flex; align-items: center; color: var(--wine-light); }
.estimate-material-links { flex-wrap: wrap; gap: .5rem; }
.estimate-material-links a { overflow-wrap: anywhere; }
.warning { margin: 0; padding: .55rem .7rem; border-left: 3px solid var(--warn); color: var(--warn); background: var(--warn-bg); overflow-wrap: anywhere; }

@media (min-width: 800px) {
  .shell { padding-bottom: 0; padding-left: 12rem; }
  .bottom-nav { display: flex; top: 4.15rem; right: auto; width: 12rem; flex-direction: column; justify-content: flex-start; padding: 1rem .7rem; border-top: 0; border-right: 1px solid var(--line); overflow-y: auto; }
  .page-head > .month-control, .page-head > .row { flex-grow: 0; max-width: 26rem; }
  .payroll-values { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .nav-link { display: flex; flex: 0 0 auto; min-height: 3rem; justify-content: flex-start; font-size: .84rem; }
  .notice { bottom: 1rem; }
}

@media (max-width: 799px) {
  .page-head > .month-control, .page-head > .row { flex-basis: 100%; }
  .notice { bottom: calc(7.5rem + env(safe-area-inset-bottom)); }
}

@media (min-width: 1100px) {
  .person-card { grid-template-columns: minmax(0, 1fr) 22rem; align-items: start; column-gap: 1.5rem; }
  .person-card > .calendar-wrap { grid-column: 2; grid-row: 1 / span 2; }
  .person-card .payroll-values { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1050px) {
  .topbar { padding-inline: .65rem; flex-wrap: wrap; gap: .5rem; }
  .brand { width: 100%; }
  .top-actions { width: 100%; display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: .3rem; }
  .project-select { max-width: 100%; min-width: 0; }
  .top-actions .button { padding-inline: .4rem; }
}

@media (max-width: 520px) {
  .brand-copy small { display: none; }
  .container { padding-inline: .7rem; }
  .card { border-radius: .8rem; }
}
