/* Salon — one hand-written stylesheet, no build step.
   Tuned for three devices in priority order: desktop front desk, tablet at the
   desk (touch-first), stylists' phones (narrow views only, never the grid). */

:root {
  /* Cool neutrals so the staff colours on the calendar stay the loudest thing
     on screen. The old warm brown made every column look the same shade. */
  --bg:        #f2f5f6;
  --surface:   #ffffff;
  --surface-2: #f7fafa;
  --ink:       #12212a;
  --ink-soft:  #5c7078;
  --line:      #dde6e8;
  --line-soft: #eef3f4;

  --accent:      #0f8a7e;   /* jade */
  --accent-ink:  #0a6b61;
  --accent-wash: #e2f2f0;

  /* The sidebar is deliberately dark: it recedes, and the white content area
     beside it reads as the workspace. */
  --nav-bg:      #12313a;
  --nav-bg-2:    #0d2730;
  --nav-ink:     #cfe2e4;
  --nav-ink-dim: #8fa9af;
  --nav-active:  #0f8a7e;

  --ok:   #1f7a5c;
  --warn: #b3701a;
  --err:  #b13030;

  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 1px 2px rgba(18, 33, 42, .06), 0 4px 16px rgba(18, 33, 42, .06);

  /* Fat enough for a fingertip on the iPad at the desk. */
  --tap: 44px;
  --nav-w: 236px;
  --nav-w-collapsed: 68px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Noto Sans Thai",
          "Helvetica Neue", Arial, sans-serif;
}

[x-cloak] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.35rem; margin: 0 0 .15em; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .15em; }
a  { color: var(--accent-ink); }

.muted { color: var(--ink-soft); }
.small { font-size: .82rem; }
.num   { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Shell: fixed sidebar + scrolling content ────────────────────────── */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; }
.nav-collapsed .shell { grid-template-columns: var(--nav-w-collapsed) minmax(0, 1fr); }
.shell-main { min-width: 0; display: flex; flex-direction: column; }

.sidebar {
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--nav-bg), var(--nav-bg-2));
  color: var(--nav-ink);
  position: sticky; top: 0; height: 100vh;
  z-index: 30;
}

.sidebar-head {
  display: flex; align-items: center; gap: .5rem;
  padding: .85rem .7rem .85rem .85rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: #fff; min-width: 0; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px; flex: none;
  border-radius: 8px;
  background: var(--accent); color: #fff;
  font-weight: 700; font-size: .78rem; letter-spacing: .02em;
}
.brand-mark-lg { width: 48px; height: 48px; font-size: 1.05rem; border-radius: 12px; }
.brand-text { font-weight: 650; font-size: .92rem; letter-spacing: -.015em;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon { width: 20px; height: 20px; flex: none; }
.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: none;
  margin-left: auto;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--nav-ink-dim);
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nav-collapsed .nav-toggle { transform: rotate(180deg); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .6rem .5rem; }
.nav-group {
  margin: .9rem 0 .3rem; padding: 0 .6rem;
  font-size: .68rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--nav-ink-dim);
}
.nav-group:first-child { margin-top: .2rem; }

.nav-link {
  display: flex; align-items: center; gap: .7rem;
  min-height: var(--tap);
  padding: .5rem .6rem;
  border-radius: var(--radius-sm);
  color: var(--nav-ink); text-decoration: none; font-weight: 550;
  white-space: nowrap;
}
.nav-link:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.nav-link.is-active { background: var(--nav-active); color: #fff; }
.nav-link.is-active .icon { color: #fff; }

/* ── Account / settings, pinned to the foot ──────────────────────────── */
.sidebar-foot { position: relative; padding: .5rem; border-top: 1px solid rgba(255, 255, 255, .08); }
.account {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  min-height: var(--tap); padding: .45rem .5rem;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--nav-ink);
  font: inherit; text-align: left; cursor: pointer;
}
.account:hover { background: rgba(255, 255, 255, .09); }
.avatar {
  display: grid; place-items: center;
  width: 30px; height: 30px; flex: none;
  border-radius: 50%; color: #fff; font-weight: 700; font-size: .85rem;
}
.account-text { display: grid; min-width: 0; line-height: 1.25; }
.account-text strong { color: #fff; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }
.account-text .muted { color: var(--nav-ink-dim); text-transform: capitalize; }
.account-chevron { margin-left: auto; color: var(--nav-ink-dim); }

.account-menu {
  position: absolute; bottom: calc(100% - .2rem); left: .5rem; right: .5rem;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(9, 22, 28, .35);
  padding: .3rem; display: grid; gap: .1rem; z-index: 40;
}
.account-item {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  min-height: var(--tap); padding: .5rem .6rem;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink);
  font: inherit; font-weight: 550; text-align: left; text-decoration: none; cursor: pointer;
}
.account-item:hover { background: var(--surface-2); }
.account-menu form { display: contents; }

/* ── Collapsed: icons only ───────────────────────────────────────────── */
.nav-collapsed .brand-text,
.nav-collapsed .nav-link span,
.nav-collapsed .account-text,
.nav-collapsed .account-chevron { display: none; }
.nav-collapsed .nav-group { text-align: center; padding: 0; font-size: 0; margin: .7rem 0 .25rem; }
.nav-collapsed .nav-group::after {
  content: ""; display: block; height: 1px; background: rgba(255, 255, 255, .12); margin: 0 .6rem;
}
.nav-collapsed .nav-link,
.nav-collapsed .account { justify-content: center; padding-left: 0; padding-right: 0; }
.nav-collapsed .sidebar-head { justify-content: center; padding: .85rem .4rem; }
.nav-collapsed .icon-btn { margin-left: 0; }

/* Mobile drawer bits — inert on desktop. */
.mobilebar { display: none; }
.nav-scrim { display: none; }

/* ── Layout ──────────────────────────────────────────────────────────── */
.page { width: 100%; max-width: 1100px; margin-inline: auto; padding: 1.25rem 1rem 3rem; }
.page-calendar { max-width: none; padding: .75rem .75rem 1rem; }
.page-head { margin-bottom: 1rem; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap); min-width: var(--tap);
  padding: .5rem .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-weight: 550;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon { padding: .4rem .7rem; font-size: 1.15rem; line-height: 1; }
.btn-block { width: 100%; }

/* ── Day bar ─────────────────────────────────────────────────────────── */
.daybar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem;
}
.daybar-nav { display: flex; align-items: center; gap: .4rem; }
.daybar-nav-compact { margin-bottom: 1rem; }
.daybar-date { display: flex; align-items: baseline; gap: .5rem; padding: 0 .35rem; }
.daybar-date strong { font-size: 1.1rem; }
.daybar-jump { display: flex; gap: .4rem; }
.daybar-jump input {
  min-height: var(--tap);
  padding: .4rem .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface);
}

/* ── Pills / tags / badges ───────────────────────────────────────────── */
.pill, .tag, .status-badge {
  display: inline-flex; align-items: center;
  padding: .12rem .5rem;
  border-radius: 999px;
  font-size: .75rem; font-weight: 600;
  white-space: nowrap;
}
.tag        { background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line-soft); }
.pill-today { background: var(--accent-wash); color: var(--accent-ink); }
.pill-warn  { background: #fdf0dd; color: var(--warn); }
.pill-off   { background: #f0eeec; color: var(--ink-soft); }
.pill-ok    { background: #e5f2eb; color: var(--ok); }

.status-badge { text-transform: capitalize; }
.status-badge.is-booked    { background: var(--accent-wash); color: var(--accent-ink); }
.status-badge.is-confirmed { background: #e5f2eb; color: var(--ok); }
.status-badge.is-completed { background: #eceaf7; color: #514a8a; }
.status-badge.is-cancelled { background: #f7e9e9; color: var(--err); }
.status-badge.is-no_show   { background: #f7e9e9; color: var(--err); }
.status-badge.is-inquiry,
.status-badge.is-proposed  { background: #f0eeec; color: var(--ink-soft); }

/* ── Alerts ──────────────────────────────────────────────────────────── */
.alert { padding: .7rem .9rem; border-radius: var(--radius-sm); margin: 0 0 1rem; font-size: .9rem; }
.alert-error { background: #f9ebeb; color: var(--err); border: 1px solid #eed6d6; }
.alert-warn  { background: #fdf4e6; color: var(--warn); border: 1px solid #f2e2c8; }

/* ── Calendar ────────────────────────────────────────────────────────── */
.calendar-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: .9rem; align-items: start; }

.calendar {
  display: grid;
  grid-template-columns: 58px repeat(var(--columns), minmax(150px, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.cal-colhead {
  height: 46px;
  display: flex; align-items: center; gap: .45rem;
  padding: 0 .6rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  position: sticky; top: 0; z-index: 3;
}
.cal-colname  { font-weight: 650; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-colcount {
  margin-left: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 .45rem;
  font-size: .74rem; color: var(--ink-soft); font-variant-numeric: tabular-nums;
}

.cal-gutter { border-right: 1px solid var(--line); }
.cal-hours  { position: relative; }
/* Rows are sized from the hour count so the grid and the percent-positioned
   appointments always describe the same day. */
.cal-hour {
  height: 60px;
  border-bottom: 1px solid var(--line-soft);
  position: relative;
}
.cal-hour span {
  position: absolute; top: -.55em; right: .5rem;
  font-size: .72rem; color: var(--ink-soft);
  background: var(--surface); padding: 0 .2rem;
  font-variant-numeric: tabular-nums;
}
.cal-hour:first-child span { top: .2rem; }

.cal-col { border-right: 1px solid var(--line-soft); min-width: 0; }
.cal-col:last-child { border-right: 0; }

.cal-slots { position: relative; }
.cal-rule  { height: 60px; border-bottom: 1px solid var(--line-soft); }

.appt {
  position: absolute;
  /* left/width are set inline from the lane assignment; the margin keeps
     neighbouring lanes visually separate. */
  margin: 0 3px;
  min-height: 22px;
  display: flex; flex-direction: column; gap: 1px;
  padding: .28rem .45rem;
  border: 1px solid color-mix(in srgb, var(--accent, #8b5e3c) 35%, var(--line));
  border-left: 3px solid var(--accent, #8b5e3c);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent, #8b5e3c) 8%, #fff);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow .12s ease, transform .12s ease;
}
.appt:hover { box-shadow: var(--shadow); z-index: 2; }
.appt.is-selected { box-shadow: 0 0 0 2px var(--accent); z-index: 3; }
.appt-time { font-size: .72rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.appt-name { font-weight: 600; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-flag { position: absolute; top: .25rem; right: .3rem; font-size: .7rem; color: var(--warn); }

.appt.is-completed { opacity: .72; }
.appt.is-confirmed { background: color-mix(in srgb, var(--ok) 8%, #fff); }
.appt.is-tentative { border-style: dashed; background: var(--surface-2); }

/* Blocks read as unavailable, not as work. */
.appt.is-block {
  background: repeating-linear-gradient(
    45deg, #f2efec, #f2efec 6px, #eae5e0 6px, #eae5e0 12px);
  border-color: var(--line);
  border-left-color: var(--ink-soft);
  color: var(--ink-soft);
}

/* Overlap is legitimate (colour processing), so both bookings stay readable:
   left/width come from the lane assignment in web.py, not from CSS. The inset
   below just keeps adjacent lanes from touching. */
.appt.is-overlapping { box-shadow: inset 0 0 0 1px #fff; }

/* Hours a stylist isn't working. Shading only — the desk can still book into
   it deliberately (someone stays late); it just shouldn't look available. */
.cal-off {
  position: absolute;
  left: 0; right: 0;
  background: repeating-linear-gradient(
    -45deg, rgba(107,99,96,.055), rgba(107,99,96,.055) 5px,
            rgba(107,99,96,.11) 5px, rgba(107,99,96,.11) 10px);
  pointer-events: none;
}
.cal-slots.is-off-all-day { background: var(--surface-2); }

/* ── Schedule editor ─────────────────────────────────────────────────── */
.staff-picker { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .9rem; }
.schedule-week { display: grid; gap: .5rem; max-width: 480px; }
.week-row { display: grid; grid-template-columns: 90px 1fr auto 1fr auto; gap: .5rem; align-items: center; }
.week-day { font-weight: 600; font-size: .88rem; }
.week-row input, .inline-form input, .inline-form select {
  min-height: var(--tap);
  padding: .4rem .55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 1rem;
  background: var(--surface); color: var(--ink);
  min-width: 0;
}
.inline-form { display: flex; flex-wrap: wrap; gap: .7rem; align-items: end; margin-bottom: .9rem; }
.inline-form label { display: grid; gap: .25rem; font-size: .8rem; font-weight: 550; color: var(--ink-soft); }
.inline-form .form-note { flex-basis: 100%; margin: 0; }

/* ── Add / edit forms ────────────────────────────────────────────────── */
/* A <details> disclosure so the list stays the point of the page and the form
   is one tap away. It springs open when editing, or when a save came back with
   an error — otherwise the message would sit above a collapsed form. */
.form-card { padding: 0; margin-bottom: 1.1rem; scroll-margin-top: 1rem; }
.form-card > summary {
  cursor: pointer; list-style: none;
  padding: .8rem 1rem; min-height: var(--tap);
  display: flex; align-items: center; gap: .5rem;
  font-weight: 600; color: var(--accent);
  border-radius: var(--radius);
}
.form-card > summary::-webkit-details-marker { display: none; }
.form-card > summary::before { content: "＋"; font-size: 1.05rem; line-height: 1; }
.form-card[open] > summary::before { content: "×"; }
.form-card > summary:hover { background: var(--surface-2); }
.form-card[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; }

.stack-form { display: grid; gap: .9rem; padding: 1rem; }
.form-grid {
  display: grid; gap: .75rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  /* Bottom-align the cells so the inputs sit on one line even when a label
     wraps to two — otherwise one hint ("— 30 means 30%") drops its field
     below its neighbours and the row looks broken. */
  align-items: end;
}
.form-grid label { display: grid; gap: .3rem; align-content: end; font-size: .8rem; font-weight: 550; color: var(--ink-soft); }
.form-grid input, .form-grid select {
  min-height: var(--tap);
  padding: .4rem .55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 1rem;
  background: var(--surface); color: var(--ink);
  min-width: 0;
}
.form-grid input[type="color"] { padding: .2rem; cursor: pointer; }

.form-checks { display: grid; gap: .55rem; }
/* Whole row is the hit target — a bare 13px checkbox is unusable on the iPad. */
.check {
  display: flex; align-items: center; gap: .6rem;
  min-height: var(--tap); cursor: pointer;
  font-size: .88rem; color: var(--ink-soft);
}
.check input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.check strong { color: var(--ink); }

.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.card-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.btn-sm { min-height: 34px; padding: .25rem .6rem; font-size: .82rem; }
/* Edit is the primary thing you do to a row, so it has to read as a control.
   As btn-quiet it was transparent grey text and people didn't see it at all. */
.btn-edit {
  background: var(--accent-wash); border-color: var(--accent-wash); color: var(--accent-ink);
  font-weight: 600;
}
.btn-edit:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

.stock-form { margin: 0; padding: 0 1rem 1rem; border-top: 1px solid var(--line); padding-top: .9rem; }

/* ── Detail panel ────────────────────────────────────────────────────── */
.detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  position: sticky; top: 62px;
  min-height: 180px;
}
.detail-empty { display: grid; gap: .5rem; }
.detail-head  { display: flex; justify-content: space-between; align-items: start; gap: .75rem; margin-bottom: .85rem; }
.detail-list  { display: grid; grid-template-columns: max-content 1fr; gap: .45rem .85rem; margin: 0; }
.detail-list dt { color: var(--ink-soft); font-size: .8rem; padding-top: .1rem; }
.detail-list dd { margin: 0; }
.detail-list dd .muted.small { display: block; }
.detail-line  { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; }
.detail-line + .detail-line { margin-top: .3rem; }

/* ── Tables ──────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table {
  width: 100%; border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table th, .table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line-soft); }
.table th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.table th.num, .table td.num { text-align: right; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-inactive { opacity: .55; }
.th-name { display: block; font-size: .8rem; color: var(--ink-soft); }

/* ── Cards ───────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: .9rem;
}
.card.is-inactive { opacity: .6; }
.card-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .7rem; }
.card-head strong { display: block; }
.card-head .pill { margin-left: auto; }
.card-body { display: grid; grid-template-columns: max-content 1fr; gap: .35rem .8rem; margin: 0; }
.card-body dt { color: var(--ink-soft); font-size: .8rem; }
.card-body dd { margin: 0; display: flex; flex-wrap: wrap; gap: .25rem; }

/* ── Agenda (phone "my day") ─────────────────────────────────────────── */
.agenda { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.agenda-row {
  display: grid;
  grid-template-columns: 62px 1fr max-content;
  gap: .75rem; align-items: start;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: .75rem;
  box-shadow: var(--shadow);
}
.agenda-row.is-block { border-left-color: var(--ink-soft); background: var(--surface-2); }
.agenda-time { display: grid; font-variant-numeric: tabular-nums; }
.agenda-services { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .3rem; }
.agenda-body p { margin: .35rem 0 0; }
.agenda-empty { padding: 2rem 1rem; text-align: center; }

/* ── Login ───────────────────────────────────────────────────────────── */
.page-login { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.75rem;
}
.login-brand { text-align: center; margin-bottom: 1.5rem; display: grid; justify-items: center; gap: .3rem; }
.login-brand h1 { margin: .4rem 0 0; }
.login-brand p  { margin: 0; }
.login-note { margin: 1.25rem 0 0; text-align: center; }

.stack { display: grid; gap: .85rem; }
.stack label { display: grid; gap: .3rem; font-size: .85rem; font-weight: 550; color: var(--ink-soft); }
.stack input {
  min-height: var(--tap);
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 1rem;  /* >=16px: stops iOS zooming the field */
  background: var(--surface);
  color: var(--ink);
}
.stack input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

/* ── Check-out ───────────────────────────────────────────────────────── */
.checkout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
.checkout-head { display: flex; justify-content: space-between; align-items: start; gap: 1rem; }

.add-line { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .7rem; margin-top: .9rem; }
.add-line label, .pay label { display: grid; gap: .3rem; font-size: .82rem; font-weight: 550; color: var(--ink-soft); }
.add-line select, .pay select, .totals input {
  min-height: var(--tap);
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit; font-size: 1rem;   /* >=16px stops iOS zooming the field */
  color: var(--ink);
}

.checkout-total {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem; position: sticky; top: 62px;
}
.totals { display: grid; grid-template-columns: 1fr max-content; gap: .5rem .75rem; align-items: center; margin: 0 0 .75rem; }
.totals dt { color: var(--ink-soft); font-size: .88rem; }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.totals input { width: 110px; text-align: right; }
.totals .grand { font-size: 1.15rem; font-weight: 700; color: var(--ink); border-top: 1px solid var(--line); padding-top: .6rem; }
.pay { display: grid; gap: .7rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line-soft); }

/* ── Stats (reports) ─────────────────────────────────────────────────── */
.section-head { margin: 1.75rem 0 .6rem; font-size: 1rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; }
.stat-row-narrow { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .9rem 1rem; display: grid; gap: .15rem;
}
.stat-accent { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: var(--accent-wash); }
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin: 0; }
.stat-note { font-size: .78rem; color: var(--ink-soft); }

/* ── Week view ───────────────────────────────────────────────────────── */
.view-switch { display: flex; gap: .25rem; }
.cal-colhead.is-today { background: var(--accent-wash); }
.cal-colhead.is-today .cal-colname { color: var(--accent-ink); }
.detail-week { margin-top: .9rem; padding: .75rem 1rem; min-height: 0; }

/* ── Settings ────────────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem; }
.settings-card {
  display: flex; gap: .8rem; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .9rem; text-decoration: none; color: var(--ink);
}
.settings-card:hover { border-color: var(--accent); box-shadow: 0 2px 4px rgba(18,33,42,.08), 0 8px 24px rgba(18,33,42,.08); }
.settings-icon {
  display: grid; place-items: center; flex: none;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: var(--accent-wash); color: var(--accent-ink);
}
.settings-body { display: grid; gap: .15rem; min-width: 0; }
.settings-body .tag { justify-self: start; margin-top: .25rem; }

/* ── Responsive ──────────────────────────────────────────────────────── */

/* Tablet: the detail panel drops under the grid so columns keep their width,
   and the sidebar defaults to the icon rail to buy back horizontal space. */
@media (max-width: 1100px) {
  .shell { grid-template-columns: var(--nav-w-collapsed) minmax(0, 1fr); }
  .brand-text, .nav-link span, .account-text, .account-chevron { display: none; }
  .nav-group { text-align: center; padding: 0; font-size: 0; margin: .7rem 0 .25rem; }
  .nav-group::after {
    content: ""; display: block; height: 1px; background: rgba(255,255,255,.12); margin: 0 .6rem;
  }
  .nav-link, .account { justify-content: center; padding-left: 0; padding-right: 0; }
  .sidebar-head { justify-content: center; padding: .85rem .4rem; }
  .nav-toggle { display: none; }
  .account-menu { left: calc(100% + .4rem); right: auto; width: 190px; bottom: .5rem; }
}

@media (max-width: 1024px) {
  .calendar-wrap { grid-template-columns: minmax(0, 1fr); }
  .checkout { grid-template-columns: minmax(0, 1fr); }
  .checkout-total { position: static; }
  .detail { position: static; }
  .calendar { overflow-x: auto; }
}

/* Phone: the sidebar becomes an off-canvas drawer behind a hamburger, and the
   multi-column calendar is never squeezed — /me is the phone view. */
@media (max-width: 700px) {
  .shell { grid-template-columns: minmax(0, 1fr); }

  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: min(80vw, var(--nav-w));
    transform: translateX(-100%);
    transition: transform .18s ease;
  }
  .nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(9, 22, 28, .5); }

  /* Undo the tablet icon-rail: the drawer has room for labels. */
  .brand-text, .nav-link span, .account-text, .account-chevron { display: revert; }
  .nav-group { text-align: left; padding: 0 .6rem; font-size: .68rem; }
  .nav-group::after { content: none; }
  .nav-link, .account { justify-content: flex-start; padding-left: .6rem; padding-right: .6rem; }
  .sidebar-head { justify-content: space-between; padding: .85rem .7rem; }
  .nav-toggle { display: none; }
  .account-menu { left: .5rem; right: .5rem; width: auto; bottom: calc(100% - .2rem); }

  .mobilebar {
    display: flex; align-items: center; gap: .6rem;
    padding: .4rem .6rem;
    background: var(--surface); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
  }
  .mobilebar .icon-btn { margin-left: 0; color: var(--ink-soft); }
  .mobilebar .icon-btn:hover { background: var(--surface-2); color: var(--ink); }
  .mobilebar .brand-text { color: var(--ink); font-size: .95rem; }

  .nav-open .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 25;
    background: rgba(9, 22, 28, .45); border: 0; padding: 0;
  }

  .page { padding: 1rem .75rem 2.5rem; }
  .daybar { gap: .5rem; }
  .daybar-jump { width: 100%; }
  .daybar-jump input { flex: 1; }

  .calendar { grid-template-columns: 46px repeat(var(--columns), minmax(128px, 1fr)); }
  .agenda-row { grid-template-columns: 56px 1fr; }
  .agenda-row .status-badge { grid-column: 2; justify-self: start; }
  .week-row { grid-template-columns: 74px 1fr auto 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
