@font-face {
  font-family: Inter;
  src: url(/fonts/inter.woff2) format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f4f5f2;
  --surf: #fff;
  --ink: #17201a;
  --muted: #56615a;
  --line: #dde2db;
  --line-soft: #e7eae5;
  --field: #9aa39c;
  --green: #1e6a43;
  --green-dark: #154d31;
  --green-tint: #e6f1ea;
  --warn: #8f4400;
  --warn-dot: #c96a12;
  --warn-tint: #fdf6ec;
  --free: #dcefe2;
  --busy: #8a938c;
  --busy-line: #a7aea8;
  --own: #1f5fa8;
  --err: #a02222;
  --err-tint: #fbeaea;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  /* Safety net: the page itself never scrolls sideways; wide tables scroll inside their own box. */
  overflow-x: hidden; overflow-x: clip;
  font: 17px/1.45 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
}
body.app { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
h1, .h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: break-word; }
a, button, label, select, summary { touch-action: manipulation; }
h2, .h2 { margin: 0; font-size: 20px; line-height: 1.25; font-weight: 700; }
p { margin: 0; }
a { color: var(--green); }
a:hover { color: var(--green-dark); }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 15px; }
.center { text-align: center; }
.fine { font-size: 13px; color: var(--muted); text-align: center; margin-top: auto; }
.label { margin: 0; font-size: 15px; font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.grow { flex: 1; min-width: 0; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }
.narrow { max-width: 560px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-l { display: flex; flex-direction: column; gap: 24px; }
.card { background: var(--surf); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.card.now { border: 1.5px solid var(--green); }
.card.line { display: flex; align-items: center; gap: 12px; padding: 16px 20px; }

/* header + navigation */
.top { background: var(--surf); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1200px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px 32px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; color: var(--ink); text-decoration: none; }
.brand-long, .top-nav, .who-name { display: none; }
.top-nav { flex: 1; gap: 4px; }
.top-nav a { display: flex; align-items: center; height: 44px; padding: 0 14px; border-radius: 10px; font-size: 16px; font-weight: 500; color: var(--ink); text-decoration: none; }
.top-nav a.on { font-weight: 600; color: var(--green); background: var(--green-tint); }
.who { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 15px; color: var(--muted); }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--surf); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: 72px; font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none; }
.tabs a.on { font-weight: 600; color: var(--green); }

/* buttons + fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 0 18px; font: inherit; font-size: 16px; font-weight: 600; color: var(--ink); background: var(--surf); border: 1.5px solid var(--field); border-radius: 12px; text-decoration: none; cursor: pointer; }
.btn:hover, .btn:active { color: var(--ink); background: var(--bg); }
.btn.primary { color: #fff; background: var(--green); border-color: var(--green); }
.btn.primary:hover, .btn.primary:active { color: #fff; background: var(--green-dark); }
.btn.big { min-height: 56px; font-size: 18px; width: 100%; }
button.link { padding: 0; min-height: 44px; font: inherit; font-weight: 500; color: var(--green); background: none; border: 0; cursor: pointer; text-decoration: underline; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; color: var(--ink); background: var(--surf); border: 1.5px solid var(--line); border-radius: 10px; }
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; font-size: 16px; font-weight: 500; text-decoration: none; }

.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; font-size: 15px; font-weight: 600; }
input, select, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--surf); border: 1.5px solid var(--field); border-radius: 10px; min-height: 48px; padding: 0 14px; width: 100%; }
textarea { padding: 12px 14px; line-height: 1.4; resize: vertical; }
/* iOS gives date fields a fixed inner width that pushes them out of narrow columns. */
input[type='date'] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; line-height: 45px; }
input[type='date'].big { line-height: 53px; }
input::-webkit-date-and-time-value { text-align: left; margin: 0; }
/* Own dropdown arrow with room to the edge; gradients because the CSP allows no data: images. */
select {
  appearance: none; -webkit-appearance: none; padding-right: 42px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 21px center, right 15px center; background-size: 6px 6px; background-repeat: no-repeat;
}
input.big, select.big { min-height: 56px; font-size: 18px; border-radius: 12px; }
select.big { font-weight: 600; }
input.code { font-size: 28px; font-weight: 700; letter-spacing: 0.3em; text-align: center; }
.check { display: flex; align-items: flex-start; gap: 12px; font-size: 16px; }
.check input { width: 24px; height: 24px; min-height: 0; margin-top: 1px; accent-color: var(--green); flex: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
details summary { min-height: 44px; display: flex; align-items: center; font-size: 15px; font-weight: 500; color: var(--green); cursor: pointer; }
details[open] summary { margin-bottom: 4px; }

.alert { padding: 12px 16px; border-radius: 12px; font-size: 16px; font-weight: 500; }
.alert.error { color: var(--err); background: var(--err-tint); }
.alert.ok { color: var(--green-dark); background: var(--green-tint); }

/* login */
body.plain .wrap { max-width: 440px; min-height: 100vh; min-height: 100dvh; display: flex; }
.login { flex: 1; display: flex; flex-direction: column; gap: 24px; padding: 32px 8px 8px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 15px; }
.login-brand svg { margin-bottom: 14px; }
.login-brand strong { font-size: 30px; letter-spacing: -0.02em; line-height: 1.1; }

/* lists */
.list { background: var(--surf); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line-soft); }
.row:last-child { border-bottom: 0; }
a.row:hover, a.row:active { color: var(--ink); background: #fafaf8; }
.row > svg { color: var(--muted); flex: none; }
.row.off { background: #fafaf8; }
.row.off .row-name { color: var(--muted); }
.row.sel, a.row.sel:hover { background: var(--green-tint); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-name { font-weight: 600; }
.list.compact .row { padding: 0 16px; min-height: 52px; }
.list.compact .row-main { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.list.compact .row > svg { display: none; }
.list.compact .status { font-size: 14px; text-align: right; }

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 500; }
.status .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.status.free { color: var(--green); }
.status.free .dot { background: var(--green); }
.status.busy { color: var(--muted); }
.status.busy .dot { border: 2px solid var(--muted); }
.status.maint { color: var(--warn); }
.status.maint .dot { background: var(--warn-dot); border-radius: 2px; }

/* machine detail */
.split-list { display: none; }
.detail { padding: 16px; }
.detail-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.chip { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 10px; font-size: 15px; font-weight: 500; color: var(--ink); background: var(--surf); border: 1.5px solid var(--field); border-radius: 12px; text-decoration: none; white-space: nowrap; }
.chip:active { background: var(--bg); }
.chip.on { font-weight: 600; color: #fff; background: var(--green); border-color: var(--green); }
.chip-form { min-width: 0; display: flex; gap: 8px; }
.chip-cal { position: relative; overflow: hidden; cursor: pointer; }
.chip-cal svg { flex: none; }
.chip-cal:focus-within { outline: 3px solid var(--green); outline-offset: 2px; }
/* Invisible date field on top of the button; its picker indicator fills it, so any click opens the calendar. */
.chip-cal input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.chip-cal input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; margin: 0; padding: 0; cursor: pointer; }

.wk-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 24px; }
.wk-nav { gap: 8px; }
.wk { display: flex; flex-direction: column; gap: 8px; }
.wk-row { display: none; align-items: center; gap: 12px; }
.wk-row.sel { display: flex; }
.wk-day { display: none; width: 76px; flex: none; font-size: 15px; color: var(--muted); text-decoration: none; }
.wk-row.sel .wk-day { font-weight: 700; color: var(--ink); }
.bar { flex: 1; min-width: 0; height: 44px; border-radius: 8px; display: block; }
.bar-bg { fill: var(--free); }
.seg.own { fill: var(--own); }
.hatch-bg { fill: var(--busy); }
.hatch-line { fill: var(--busy-line); }
.defs { position: absolute; width: 0; height: 0; }
.tick-row { flex: 1; display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 14px; border-radius: 3px; }
.sw.free { background: var(--free); }
.sw.busy { background: repeating-linear-gradient(45deg, var(--busy) 0 3px, var(--busy-line) 3px 5px); }
.sw.own { background: var(--own); }
.only-desktop { display: none; }
.book { padding-top: 20px; border-top: 1px solid var(--line-soft); }

/* return */
.stepper { display: flex; align-items: center; gap: 12px; }
.step { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; flex: none; color: var(--ink); background: var(--bg); border: 1.5px solid var(--field); border-radius: 16px; cursor: pointer; }
.step-val { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: 15px; }
.step-val input { border: 0; min-height: 0; padding: 0; font-size: 48px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; text-align: center; background: none; }
.cost { display: flex; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line-soft); font-size: 16px; }

/* admin */
.subtabs { display: flex; flex-wrap: wrap; gap: 0 24px; border-bottom: 1px solid var(--line); margin-top: -8px; }
.subtabs a { display: flex; align-items: center; height: 44px; font-size: 16px; font-weight: 500; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; }
.subtabs a.on { font-weight: 600; color: var(--green); border-color: var(--green); }
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; gap: 12px; }
.filter-actions { grid-column: 1 / -1; display: flex; gap: 12px; }
.filter-actions .btn.primary { flex: 1; }
.bar-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.bar-row .btn { flex: 1 1 100%; }
.kpis { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.kpi { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 12px; font-size: 15px; }
.kpi strong { font-size: 20px; color: var(--ink); white-space: nowrap; }
.table-box { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surf); border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; min-width: 860px; border-collapse: collapse; font-size: 15px; }
th { padding: 14px 12px; text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
.num { text-align: right; white-space: nowrap; }
tr.warn { background: var(--warn-tint); }
.warn-text { color: var(--warn); font-weight: 600; }
tr.inactive td { color: var(--muted); }
/* Return note of a member, e.g. damage: must stand out for the admin. */
td.note { min-width: 180px; max-width: 280px; font-size: 14px; font-weight: 500; color: var(--warn); overflow-wrap: break-word; hyphens: auto; }
.actions { text-align: right; white-space: nowrap; }
.actions a, .actions button { font-weight: 500; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline select { width: auto; min-height: 44px; font-size: 15px; font-weight: 600; }
.inline input { min-height: 44px; font-size: 15px; min-width: 180px; }
.inline .btn { min-height: 44px; font-size: 15px; padding: 0 14px; }
select.st-available { color: var(--green); background-color: var(--green-tint); border-color: var(--green); }
select.st-maintenance, select.st-out_of_service { color: var(--warn); background-color: #fbead7; border-color: var(--warn); }

/* Phones: every table row becomes a card with labelled values, so nothing has to scroll sideways. */
@media (max-width: 699px) {
  .table-box { overflow: visible; background: none; border: 0; border-radius: 0; }
  table, tbody { display: block; min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody { display: flex; flex-direction: column; gap: 12px; }
  tr { display: flex; flex-direction: column; gap: 8px; padding: 16px; background: var(--surf); border: 1px solid var(--line); border-radius: 16px; }
  tr.warn { background: var(--warn-tint); border-color: #ecd6b8; }
  td { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 0; border: 0; min-width: 0; text-align: right; overflow-wrap: anywhere; }
  td:first-child, td:last-child { padding-left: 0; padding-right: 0; }
  td[data-label]::before { content: attr(data-label); flex: none; font-size: 14px; font-weight: 400; color: var(--muted); text-align: left; }
  td.title { order: -1; font-size: 18px; text-align: left; }
  td.wide, td.empty { display: block; text-align: left; }
  td.note { display: block; min-width: 0; max-width: none; padding: 10px 12px; text-align: left; background: var(--warn-tint); border: 1px solid #ecd6b8; border-radius: 10px; }
  td.note::before { display: block; margin-bottom: 2px; }
  td.note.none { display: none; }
  td.actions { justify-content: flex-end; padding-top: 8px; border-top: 1px solid var(--line-soft); }
  td.actions a { display: inline-flex; align-items: center; min-height: 44px; }
  .inline { flex-wrap: wrap; padding-top: 4px; }
  .inline select { flex: 1 1 100%; width: 100%; min-height: 48px; font-size: 16px; }
  .inline input { flex: 1 1 140px; min-width: 0; min-height: 48px; font-size: 16px; }
  .inline .btn { min-height: 48px; font-size: 16px; }
}

@media (min-width: 600px) {
  .filters { display: flex; flex-wrap: wrap; align-items: flex-end; }
  .filters .field { flex: 1 1 150px; }
  .filter-actions { flex: none; }
  .filter-actions .btn.primary { flex: none; }
  .bar-row .btn { flex: none; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .kpi { flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 2px; padding: 14px 16px; font-size: 14px; }
  .kpi strong { font-size: 22px; }
}

@media (min-width: 860px) {
  body.app { padding-bottom: 0; }
  .wrap { padding: 32px 24px 48px; }
  .top-in { padding: 12px 24px; }
  .tabs, .brand-short, .only-mobile { display: none; }
  .brand-long, .who-name { display: inline; }
  .top-nav { display: flex; }
  .only-desktop { display: inline; }
  .wk-nav.only-desktop { display: flex; }
  .split { display: flex; align-items: flex-start; gap: 24px; }
  .split-list { display: flex; flex: 1 1 340px; min-width: 0; }
  .detail { flex: 2 1 560px; min-width: 0; padding: 28px; }
  .detail .back { display: none; }
  .wk-row, .wk-day { display: flex; }
  .bar { height: 36px; }
  .wk-row.sel .bar { outline: 1.5px solid var(--green); }
  .wk-row.ticks .bar { outline: 0; }
  .btn.big { width: auto; align-self: flex-start; min-width: 220px; }
  .login .btn.big, .narrow .btn.big { width: 100%; }
}
