/* Mobile-first shell for the V2 turnover app. Dependency-free (no icon
   fonts, no CDN) — icons are plain unicode/emoji glyphs. */

:root {
  /* Wave 7.9 "Etiquette". The palette comes from the housekeeping world -
     bleached cotton, laundry marker, institutional petrol - rather than the
     framework default (#2563eb on #f3f4f6), which read as a generic
     dashboard. Green is deliberately NOT the primary: it stays reserved for
     "clean", which is the room-status convention staff already know. */
  --hk-primary: #0f4c5c;        /* petrol - signage, not framework blue */
  --hk-primary-dark: #0a3743;
  --hk-primary-soft: #e2eef1;   /* focus halo / tinted fills */
  --hk-on-primary: #ffffff;     /* text ON primary; overridden in dark mode */
  --hk-success: #2f7d4f;        /* "clean" */
  --hk-danger: #a93226;
  --hk-warning: #b45309; /* §B #11: 4.6:1 on white (#d97706 was 3.2:1); single definition, see Wave 7.6 note near file end */
  --hk-bg: #e6eae6;             /* bleached cotton, cool-shifted */
  --hk-surface: #ffffff;
  --hk-text: #15181a;           /* laundry marker */
  --hk-text-muted: #5c6660;
  --hk-border: #d3dad5;
  --hk-radius: 12px;
  --hk-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, "Roboto Mono", "Cascadia Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hk-bg: #101413;
    --hk-surface: #1a211f;
    --hk-text: #e8ede9;
    --hk-text-muted: #9ba8a1;
    --hk-border: #2e3835;
    --hk-warning: #f59e0b; /* dark surfaces (was the 7.6 override at file end) */
    /* 7.9: primary had NO dark override before, so #2563eb sat on #1f2937 at
       ~3.1:1. Petrol is lifted here, and because a lifted primary cannot
       carry white text, --hk-on-primary flips to near-black. */
    --hk-primary: #5fb6c9;
    --hk-primary-dark: #7fcadb;
    --hk-primary-soft: #16302f;
    --hk-on-primary: #08211f;
    --hk-success: #5fbf87;
    --hk-danger: #f09189;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--hk-bg);
  color: var(--hk-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font-family: inherit; }

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Login ---- */

.hk-login {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.hk-login-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--hk-surface);
  border-radius: var(--hk-radius);
  padding: 28px 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.hk-login-card h1 {
  font-size: 1.4rem;
  margin: 0 0 4px;
  padding-right: 86px;
}

.hk-login-subtitle {
  color: var(--hk-text-muted);
  margin: 0 0 20px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.hk-login-lang {
  position: absolute;
  top: 20px;
  right: 20px;
  min-height: 36px;
}

.hk-login-feedback {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.4;
}

.hk-login-feedback:empty { display: none; }

.hk-login-feedback.is-error {
  color: var(--hk-danger);
  background: #fef2f2;
}

.hk-login-feedback:focus { outline: 2px solid var(--hk-danger); outline-offset: 2px; }

.hk-login-verify-failed .hk-login-feedback { margin-bottom: 12px; }

.hk-login-alternative {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
  color: var(--hk-text-muted);
  font-size: 0.82rem;
}

.hk-login-switch {
  min-height: 44px;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  color: var(--hk-primary);
  font-size: 0.86rem;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.hk-login-switch:focus-visible,
.hk-login-lang:focus-visible {
  outline: 2px solid var(--hk-primary);
  outline-offset: 2px;
}

.hk-login-sent,
.hk-login-progress {
  padding: 18px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--hk-border);
  border-radius: 10px;
  background: var(--hk-bg);
  text-align: center;
}

.hk-login-sent:focus { outline: 2px solid var(--hk-primary); outline-offset: 2px; }

.hk-login-sent-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--hk-primary);
  color: #fff;
  font-size: 1.25rem;
}

.hk-login-sent h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.hk-login-sent p,
.hk-login-progress p {
  margin: 0;
  color: var(--hk-text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.hk-login-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  border: 3px solid var(--hk-border);
  border-top-color: var(--hk-primary);
  border-radius: 50%;
  animation: hk-login-spin 0.8s linear infinite;
}

@keyframes hk-login-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .hk-login-spinner { animation: none; }
}

.hk-field {
  margin-bottom: 14px;
}

.hk-field label {
  display: block;
  font-size: 0.8rem;
  color: var(--hk-text-muted);
  margin-bottom: 4px;
}

.hk-field input, .hk-field textarea, .hk-field select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--hk-border);
  border-radius: 8px;
  background: var(--hk-bg);
  color: var(--hk-text);
  font-size: 1rem;
}

.hk-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 8px;
  background: var(--hk-primary);
  color: var(--hk-on-primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px; /* touch target floor — no per-context rule may go below */
}

.hk-btn:active { background: var(--hk-primary-dark); }
.hk-btn.hk-btn-success { background: var(--hk-success); }
.hk-btn.hk-btn-danger { background: var(--hk-danger); }
.hk-btn.hk-btn-secondary { background: transparent; color: var(--hk-primary); border: 1px solid var(--hk-primary); }
.hk-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.hk-error {
  color: var(--hk-danger);
  font-size: 0.85rem;
  margin-top: 8px;
}

@media (prefers-color-scheme: dark) {
  .hk-login-feedback.is-error { color: #fca5a5; background: #450a0a; }
  .hk-login-feedback:focus { outline-color: #fca5a5; }
  .hk-login-switch { color: var(--hk-primary); }
  .hk-login-switch:focus-visible,
  .hk-login-lang:focus-visible,
  .hk-login-sent:focus { outline-color: var(--hk-primary); }
  .hk-login-card .hk-btn-secondary { color: var(--hk-primary); border-color: var(--hk-primary); }
}

/* ---- App shell ---- */

.hk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--hk-surface);
  border-bottom: 1px solid var(--hk-border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.hk-header h1 {
  font-size: 1.1rem;
  margin: 0;
}

.hk-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.hk-lang-toggle, .hk-logout {
  background: none;
  border: 1px solid var(--hk-border);
  border-radius: 6px;
  padding: 6px 12px;
  min-height: 44px;
  min-width: 44px;
  font-size: 0.85rem;
  color: var(--hk-text);
  cursor: pointer;
}

main#hk-view {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 90px;
}

/* ---- Bottom tabs ---- */

.hk-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--hk-surface);
  border-top: 1px solid var(--hk-border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 10;
}

.hk-tab {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.72rem;
  color: var(--hk-text-muted);
  cursor: pointer;
}

.hk-tab .hk-tab-icon { font-size: 1.3rem; }
.hk-tab.active { color: var(--hk-primary); font-weight: 600; }

/* ---- Cards / lists ---- */

.hk-card {
  background: var(--hk-surface);
  border-radius: var(--hk-radius);
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--hk-border);
}

.hk-task-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
}

.hk-task-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hk-bed-code { font-size: 1.05rem; font-weight: 700; }

.hk-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--hk-border);
  color: var(--hk-text);
}

.hk-badge.state-assigned { background: #e5e7eb; color: #374151; }
.hk-badge.state-started { background: var(--hk-primary-soft); color: var(--hk-primary-dark); }
.hk-badge.state-cleaned { background: #fef3c7; color: #92400e; }
.hk-badge.state-photographed { background: #ede9fe; color: #6d28d9; }
.hk-badge.state-inspected { background: #d1fae5; color: #065f46; }
.hk-badge.state-ready_for_sale { background: #16a34a; color: #fff; }
.hk-badge.state-blocked { background: #fee2e2; color: #991b1b; }
.hk-badge.state-cancelled { background: #e5e7eb; color: #6b7280; text-decoration: line-through; }
.hk-badge.state-not_required { background: #e5e7eb; color: #6b7280; }

.hk-priority-badge.priority-high { background: #ffedd5; color: #9a3412; }
.hk-priority-badge.priority-urgent { background: #fecaca; color: #991b1b; }
.hk-priority-badge.priority-hold { background: #e5e7eb; color: #4b5563; }

.hk-overdue-flag {
  color: var(--hk-danger);
  font-weight: 700;
  font-size: 0.72rem;
}

.hk-meta { color: var(--hk-text-muted); font-size: 0.82rem; }

.hk-empty {
  text-align: center;
  color: var(--hk-text-muted);
  padding: 40px 12px;
}

/* ---- Checklist ---- */

.hk-checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--hk-border);
  cursor: pointer;
}

.hk-checklist-item:last-child { border-bottom: none; }

.hk-checkbox {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--hk-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
}

.hk-checklist-item.done .hk-checkbox {
  background: var(--hk-success);
  border-color: var(--hk-success);
  color: #fff;
}

.hk-checklist-item.done span.hk-item-label {
  text-decoration: line-through;
  color: var(--hk-text-muted);
}

/* ---- Photos ---- */

.hk-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0;
}

.hk-photo-slot {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px dashed var(--hk-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  font-size: 0.68rem;
  color: var(--hk-text-muted);
  text-align: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.hk-photo-slot.filled {
  border-style: solid;
  border-color: var(--hk-success);
  color: var(--hk-success);
}

.hk-photo-slot input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ---- Stat grid (ops dashboard) ---- */

.hk-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.hk-stat {
  background: var(--hk-surface);
  border: 1px solid var(--hk-border);
  border-radius: var(--hk-radius);
  padding: 14px;
}

.hk-stat-value { font-size: 1.6rem; font-weight: 700; }
.hk-stat-label { font-size: 0.78rem; color: var(--hk-text-muted); margin-top: 2px; }

/* ---- Points ---- */

.hk-points-total {
  text-align: center;
  padding: 20px;
}

.hk-points-total .hk-stat-value { font-size: 2.4rem; color: var(--hk-primary); }

.hk-tx-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--hk-border);
}

.hk-tx-points { font-weight: 700; }
.hk-tx-points.positive { color: var(--hk-success); }
.hk-tx-points.negative { color: var(--hk-danger); }

.hk-toast {
  position: fixed;
  bottom: 76px;
  left: 12px;
  right: 12px;
  background: var(--hk-text);
  color: var(--hk-bg);
  padding: 12px 16px;
  border-radius: 10px;
  text-align: center;
  z-index: 20;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
/* B9: sticky toast with an action button ("Nouvelle version — recharger") */
.hk-toast-sticky { z-index: 40; }
.hk-toast-action {
  flex-shrink: 0;
  border: 1px solid var(--hk-bg);
  background: transparent;
  color: var(--hk-bg);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.9rem;
  font-weight: 600;
}
/* B8: inline "session expired" notice on the login card */
.hk-login-notice {
  background: #fff4e0;
  color: #8a5a00;
  border: 1px solid #f0c36d;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  text-align: center;
}
@media (prefers-color-scheme: dark) {
  .hk-login-notice {
    background: #3a2e12;
    color: #fbd38d;
    border-color: #8a5a00;
  }
}

/* ---- v0.2: shift header / next-then block ---- */

.hk-shift-card .hk-shift-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--hk-border);
  font-size: 0.88rem;
}
.hk-shift-card .hk-shift-row:last-of-type { border-bottom: none; }
.hk-online-status {
  margin: 8px 0;
  font-size: 0.78rem;
  color: var(--hk-text-muted);
}

.hk-next-card { border-left: 4px solid var(--hk-primary); }
.hk-next-row { font-size: 0.95rem; padding: 4px 0; }
.hk-next-row.hk-then { color: var(--hk-text-muted); font-size: 0.85rem; }

/* ---- v0.2: exception flags/actions ---- */

.hk-flag-banner {
  border-left: 4px solid var(--hk-warning);
  font-size: 0.88rem;
}
.hk-flag-text { color: var(--hk-warning); font-weight: 600; }

.hk-exception-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hk-exception-actions .hk-btn { width: auto; flex: 1 1 auto; padding: 10px 12px; font-size: 0.85rem; }

.hk-inspect-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.hk-inspect-actions .hk-btn { width: auto; flex: 1 1 calc(50% - 4px); padding: 10px 8px; font-size: 0.82rem; }

.hk-imported-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 0.7rem;
}
.hk-imported-note {
  display: block;
  color: var(--hk-warning);
  font-size: 0.68rem;
}

/* ---- v0.2: room/bed table ---- */

.hk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  margin-top: 8px;
}
.hk-table th, .hk-table td {
  text-align: left;
  padding: 6px 4px;
  border-bottom: 1px solid var(--hk-border);
}

/* ---- v0.2: alerts banner ---- */

.hk-alerts-banner .hk-alert-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 6px;
  border-radius: 8px;
  margin-top: 6px;
  font-size: 0.85rem;
  cursor: pointer;
}
.hk-alert-row.severity-critical { background: #fee2e2; color: #991b1b; }
.hk-alert-row.severity-warning { background: #fef3c7; color: #92400e; }
.hk-alert-row.severity-info { background: var(--hk-primary-soft); color: var(--hk-primary-dark); }

/* ---- Wave 3: messages tab badge / thread / bubbles ---- */

.hk-tab-icon { position: relative; }

.hk-tab-badge {
  position: absolute;
  top: -4px;
  right: -10px;
  background: var(--hk-danger);
  color: #fff;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  line-height: 1.3;
}

.hk-message-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hk-message-bubble {
  align-self: flex-start;
  max-width: 85%;
  background: var(--hk-bg);
  border: 1px solid var(--hk-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

.hk-message-bubble.mine {
  align-self: flex-end;
  background: var(--hk-primary);
  color: #fff;
  border-color: var(--hk-primary);
}
.hk-message-bubble.mine .hk-meta { color: rgba(255, 255, 255, 0.8); }

.hk-message-task-link { cursor: pointer; text-decoration: underline; }

.hk-thread-row { cursor: pointer; }

.hk-handover-section { margin-top: 8px; }

/* ---- Wave 3: inventory low-stock row ---- */
.hk-low-stock-row td:first-child { color: var(--hk-danger); font-weight: 600; }

/* ---- v0.2: control tower / employee cards ---- */

.hk-employee-card .hk-reassign-select {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--hk-border);
  border-radius: 8px;
  background: var(--hk-bg);
  color: var(--hk-text);
}

.hk-tx-row[data-task-id] { cursor: pointer; }

/* ---- Wave 4: tape chart (Calendrier) -------------------------------- */

.hk-tape-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.hk-tape-nav .hk-btn { width: auto; padding: 8px 14px; }

.hk-tape-tray-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.hk-tape-tray-item {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--hk-bg);
  border: 1px solid var(--hk-primary);
  color: var(--hk-primary);
  font-size: 0.8rem;
  cursor: grab;
}
.hk-tape-tray-item.selected { background: var(--hk-primary); color: #fff; }

.hk-tape-scroll {
  overflow-x: auto;
  border: 1px solid var(--hk-border);
  border-radius: var(--hk-radius);
  background: var(--hk-surface);
}

.hk-tape-grid { display: table; width: 100%; }

.hk-tape-header, .hk-tape-row { display: flex; align-items: stretch; }

.hk-tape-row-label {
  flex: 0 0 84px;
  min-width: 84px;
  padding: 6px 8px;
  font-size: 0.78rem;
  border-right: 1px solid var(--hk-border);
  border-bottom: 1px solid var(--hk-border);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  position: sticky;
  left: 0;
  background: var(--hk-surface);
  z-index: 1;
}

.hk-tape-group-label {
  padding: 4px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--hk-text-muted);
  background: var(--hk-bg);
  border-bottom: 1px solid var(--hk-border);
  position: sticky;
  left: 0;
}

.hk-tape-track {
  position: relative;
  display: flex;
  border-bottom: 1px solid var(--hk-border);
  min-height: var(--tape-row-h, 44px);
}

.hk-tape-header-track { min-height: 32px; }

.hk-tape-cell {
  flex: 0 0 var(--tape-cell, 64px);
  width: var(--tape-cell, 64px);
  border-right: 1px dashed var(--hk-border);
  box-sizing: border-box;
}

.hk-tape-day-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  color: var(--hk-text-muted);
  border-right: 1px solid var(--hk-border);
}

.hk-tape-track.drag-over { background: rgba(37, 99, 235, 0.08); }
.hk-tape-track-blocked {
  background-image: repeating-linear-gradient(45deg, rgba(220, 38, 38, 0.08), rgba(220, 38, 38, 0.08) 6px, transparent 6px, transparent 12px);
}

.hk-tape-muted .hk-tape-row-label { color: var(--hk-text-muted); font-style: italic; }
.hk-tape-muted .hk-tape-track { opacity: 0.75; }

.hk-tape-block {
  position: absolute;
  top: 4px;
  bottom: 4px;
  border-radius: 6px;
  background: var(--hk-primary);
  color: #fff;
  font-size: 0.72rem;
  padding: 2px 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: grab;
  z-index: 2;
}
.hk-tape-block.selected { outline: 3px solid var(--hk-warning); }
.hk-tape-block-guest { pointer-events: none; }

/* ---- Wave 4: confirmation sheet (move confirm / etc.) --------------- */

.hk-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
}
.hk-sheet {
  width: 100%;
  max-width: 420px;
  background: var(--hk-surface);
  border-radius: 16px 16px 0 0;
  padding: 20px;
}
.hk-sheet h3 { margin: 0 0 8px; }
.hk-sheet-actions { display: flex; gap: 10px; margin-top: 14px; }
.hk-sheet-actions .hk-btn { width: auto; flex: 1; }

/* ---- Wave 4: guest requests (Tour de contrôle section) --------------- */

.hk-guest-request-row { align-items: flex-start; }
.hk-guest-request-row .hk-btn { width: auto; padding: 8px 12px; font-size: 0.82rem; }
/* Setup console: horizontal section switcher inside the Setup tab. Scrolls
   rather than wraps so the three sections stay on one line on a phone. */
.hk-subtabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

.hk-subtab {
  flex: 0 0 auto;
  border: 1px solid var(--hk-border);
  background: var(--hk-surface);
  color: var(--hk-text-muted);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.hk-subtab.active {
  background: var(--hk-primary);
  border-color: var(--hk-primary);
  color: #fff;
  font-weight: 600;
}

/* Bed codes listed under a room in the Setup inventory section. Deliberately
   NOT .hk-bed-code — that class is the large bold code on task cards, and
   redefining it here would shrink it everywhere. */
.hk-bed-chip {
  display: inline-block;
  background: var(--hk-bg);
  border: 1px solid var(--hk-border);
  border-radius: 6px;
  padding: 1px 6px;
  margin: 2px 2px 0 0;
  font-size: 0.78rem;
}

/* Checkbox + label row in Setup forms. Deliberately NOT .hk-checkbox — that
   is the 24x24 tick indicator on checklist items, and reusing it here
   squeezes the label into a 24px column. */
.hk-check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: 0.9rem;
  cursor: pointer;
}

.hk-check-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin: 0;
}

/* ---- Wave 7: Accountability & Evidence (docs/V07-ACCOUNTABILITY-SPEC.md) ---- */

.hk-btn-xl { padding: 18px; font-size: 1.15rem; margin-top: 10px; }
.hk-shift-actions { display: flex; gap: 10px; margin-top: 12px; }
.hk-shift-actions .hk-btn { width: auto; flex: 1; }
.hk-shift-card.hk-shift-active { border-left: 4px solid var(--hk-primary); }
.hk-shift-card.hk-shift-break { border-left: 4px solid var(--hk-warning); }
.hk-shift-card.hk-shift-finishing { border-left: 4px solid var(--hk-success); }
.hk-shift-card.hk-shift-not_started { border-left: 4px solid var(--hk-danger); }
.hk-shift-card.hk-shift-complete { border-left: 4px solid var(--hk-border); }

/* step indicator */
.hk-steps {
  list-style: none; margin: 0 0 12px; padding: 0;
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px;
}
.hk-steps li { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 0.62rem; color: var(--hk-text-muted); text-align: center; position: relative; }
.hk-steps li::before { content: ''; position: absolute; top: 11px; left: -50%; width: 100%; height: 2px; background: var(--hk-border); z-index: 0; }
.hk-steps li:first-child::before { display: none; }
.hk-steps li.done::before { background: var(--hk-success); }
.hk-step-dot {
  width: 22px; height: 22px; border-radius: 50%; background: var(--hk-surface); border: 2px solid var(--hk-border);
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.68rem; font-weight: 700; z-index: 1;
}
.hk-steps li.done .hk-step-dot { background: var(--hk-success); border-color: var(--hk-success); color: #fff; }
.hk-steps li.active .hk-step-dot { border-color: var(--hk-primary); color: var(--hk-primary); }
.hk-steps li.active { color: var(--hk-primary); font-weight: 600; }

/* evidence / gates */
.hk-evidence-pending { border-left: 4px solid var(--hk-warning); }
.hk-evidence-done { border-left: 4px solid var(--hk-success); }
.hk-photo-slot.required:not(.filled) { border-color: var(--hk-warning); color: var(--hk-warning); }
.hk-shared-note { font-size: 0.58rem; color: var(--hk-success); }
.hk-locked #hk-checklist { opacity: 0.45; pointer-events: none; }
.hk-mode-banner { border-left: 4px solid var(--hk-primary); }
.hk-timeline-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--hk-border); font-size: 0.85rem; color: var(--hk-text-muted); }
.hk-timeline-row.done { color: var(--hk-text); }
.hk-timeline-row:last-child { border-bottom: none; }

/* thumbnails */
.hk-thumb-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.hk-thumb { margin: 0; width: 96px; cursor: pointer; }
.hk-thumb.small { width: 72px; }
.hk-thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--hk-bg); display: block; }
.hk-thumb figcaption { font-size: 0.62rem; color: var(--hk-text-muted); text-align: center; margin-top: 2px; }
.hk-lightbox { align-items: center; background: rgba(0, 0, 0, 0.85); }
.hk-lightbox img { max-width: 96vw; max-height: 90vh; border-radius: 8px; }
.hk-file-btn { position: relative; overflow: hidden; }
.hk-file-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* incidents */
.hk-incident-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.hk-incident-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px;
  border: 1px solid var(--hk-border); border-radius: 10px; background: var(--hk-bg); color: var(--hk-text);
  font-size: 0.8rem; font-weight: 600; cursor: pointer; min-height: 64px;
}
.hk-incident-btn:active { background: var(--hk-border); }
.hk-incident-icon { font-size: 1.3rem; }
.hk-incident-btn.type-biohazard, .hk-incident-btn.type-security { border-color: var(--hk-danger); }
.hk-incident-btn.type-guest_belongings, .hk-incident-btn.type-bed_occupied, .hk-incident-btn.type-guest_still_present { border-color: var(--hk-warning); }
.hk-incident-card { cursor: pointer; }
.hk-incident-card.stopped { border-left: 4px solid var(--hk-danger); }
.hk-incident-sheet .hk-photo-slot { aspect-ratio: auto; height: 72px; margin: 10px 0; }
.hk-section-title { display: block; margin: 14px 0 6px; }
.hk-thread { margin: 8px 0; }
.hk-thread-entry { padding: 8px 10px; border-radius: 10px; margin: 6px 0; background: var(--hk-bg); border-left: 3px solid var(--hk-border); }
.hk-thread-entry.kind-housekeeper { border-left-color: var(--hk-primary); }
.hk-thread-entry.kind-manager { border-left-color: #6d28d9; }
.hk-thread-entry.kind-leo { border-left-color: var(--hk-warning); }
.hk-thread-entry.kind-guest { border-left-color: var(--hk-success); background: #ecfdf5; color: #064e3b; }
.hk-thread-entry.kind-system { border-left-color: var(--hk-border); font-style: italic; color: var(--hk-text-muted); }
@media (prefers-color-scheme: dark) { .hk-thread-entry.kind-guest { background: #064e3b; color: #d1fae5; } }
.hk-guest-status { padding: 8px 10px; border-radius: 8px; background: var(--hk-bg); margin: 8px 0; }
.hk-guest-status.status-pending { border-left: 3px solid var(--hk-warning); }
.hk-guest-status.status-relayed { border-left: 3px solid var(--hk-primary); }
.hk-guest-status.status-replied { border-left: 3px solid var(--hk-success); }

/* manager dashboard */
.hk-dash-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--hk-border); font-size: 0.9rem; }
.hk-dash-row:last-of-type { border-bottom: none; }
.hk-exc-row { display: flex; align-items: center; gap: 8px; padding: 8px 6px; border-radius: 8px; margin: 4px 0; cursor: pointer; font-size: 0.88rem; }
.hk-exc-row.sev-red { background: #fee2e2; color: #991b1b; }
.hk-exc-row.sev-amber { background: #fef3c7; color: #92400e; }
.hk-exc-row.sev-green { background: #d1fae5; color: #065f46; }
@media (prefers-color-scheme: dark) {
  .hk-exc-row.sev-red { background: #7f1d1d; color: #fee2e2; }
  .hk-exc-row.sev-amber { background: #78350f; color: #fef3c7; }
  .hk-exc-row.sev-green { background: #064e3b; color: #d1fae5; }
}
.hk-exc-main { flex: 1; }
.hk-exc-main .hk-meta { color: inherit; opacity: 0.8; }
.hk-exc-min { font-weight: 700; white-space: nowrap; }
.hk-cleaner-row { align-items: flex-start; }
.hk-cleaner-row .hk-btn { width: auto; padding: 8px 12px; font-size: 0.82rem; }
.hk-bed-row { display: grid; grid-template-columns: auto auto 1fr; gap: 6px 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--hk-border); cursor: pointer; }
.hk-bed-row:last-child { border-bottom: none; }
.hk-bed-row.stopped { background: #fee2e2; color: #991b1b; margin: 0 -8px; padding: 8px; border-radius: 6px; }
.hk-bed-row.overdue .hk-bed-code { color: var(--hk-danger); }
.hk-bed-chain { grid-column: 1 / -1; font-size: 0.7rem; color: var(--hk-text-muted); font-variant-numeric: tabular-nums; }
.hk-badge.bed-stayover { background: #e0f2fe; color: #075985; }
.hk-badge.bed-empty { background: #f3f4f6; color: #6b7280; }
@media (prefers-color-scheme: dark) {
  .hk-badge.state-assigned, .hk-badge.state-cancelled, .hk-badge.state-not_required, .hk-priority-badge.priority-hold { background: #374151; color: #e5e7eb; }
  .hk-badge.state-started { background: var(--hk-primary-soft); color: var(--hk-primary); }
  .hk-badge.state-cleaned { background: #78350f; color: #fef3c7; }
  .hk-badge.state-photographed { background: #4c1d95; color: #ede9fe; }
  .hk-badge.state-inspected { background: #064e3b; color: #d1fae5; }
  .hk-badge.state-blocked, .hk-priority-badge.priority-urgent { background: #7f1d1d; color: #fee2e2; }
  .hk-priority-badge.priority-high { background: #7c2d12; color: #ffedd5; }
  .hk-bed-row.stopped { background: #7f1d1d; color: #fee2e2; }
  .hk-badge.bed-stayover { background: #0c4a6e; color: #e0f2fe; }
  .hk-badge.bed-empty { background: #374151; color: #d1d5db; }
}
.hk-details summary { cursor: pointer; font-weight: 600; }
.hk-details[open] summary { margin-bottom: 8px; }

/* KPI table */
.hk-kpi-table td, .hk-kpi-table th { white-space: nowrap; font-size: 0.78rem; }
.hk-kpi-flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.hk-delta-good { color: var(--hk-success); font-size: 0.72rem; }
.hk-delta-bad { color: var(--hk-danger); font-size: 0.72rem; }

/* Wave 7: keep evidence slots phone-sized on wide screens */
.hk-photo-slot { max-height: 150px; }

/* Wave 7.5: build identity */
.hk-version { font-size: 0.62rem; color: var(--hk-text-muted); font-variant-numeric: tabular-nums; align-self: center; }
.hk-version-login { text-align: center; margin-top: 14px; }

/* ---- Wave 7.6: production reliability ---- */
/* Contrast fix for --hk-warning moved to the :root block at the top (Wave 7.8 consolidation). */
.hk-more-menu { position: fixed; left: 0; right: 0; bottom: 64px; background: var(--hk-surface); border-top: 1px solid var(--hk-border); box-shadow: 0 -6px 20px rgba(0,0,0,.12); display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; padding: 10px; z-index: 25; }
.hk-more-item { display: flex; align-items: center; gap: 8px; padding: 14px 12px; border: 1px solid var(--hk-border); border-radius: 10px; background: var(--hk-bg); color: var(--hk-text); font-size: 0.9rem; font-weight: 600; min-height: 48px; }
.hk-more-item.active { border-color: var(--hk-primary); color: var(--hk-primary); }
.hk-upload-bar { position: fixed; left: 10px; right: 10px; bottom: 74px; z-index: 26; background: var(--hk-primary); color: #fff; border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.85rem; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
.hk-upload-bar.failed { background: var(--hk-danger); }
.hk-upload-bar.offline { background: var(--hk-warning); }
.hk-upload-bar .hk-btn { width: auto; padding: 8px 12px; font-size: 0.85rem; background: #fff; color: var(--hk-text); border: none; flex: 0 0 auto; }
.hk-photo-slot.uploading { border-style: solid; border-color: var(--hk-primary); color: var(--hk-primary); animation: hk-pulse 1s infinite; }
.hk-photo-slot.queued { border-style: solid; border-color: var(--hk-warning); color: var(--hk-warning); }
.hk-photo-slot.failed { border-style: solid; border-color: var(--hk-danger); color: var(--hk-danger); }
.hk-photo-slot.uploading .hk-slot-icon { display: inline-block; animation: hk-spin 1.2s linear infinite; }
@keyframes hk-spin { to { transform: rotate(360deg); } }
.hk-slot-state { font-size: 0.6rem; line-height: 1.1; }
.hk-slot-state:empty { display: none; }
@keyframes hk-pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }
.hk-exc-row.urgent { font-weight: 700; border: 2px solid var(--hk-danger); }
.hk-tab { min-width: 44px; }

/* ---- Wave 7.7: reliability / a11y ---- */
:focus-visible { outline: 3px solid var(--hk-primary); outline-offset: 2px; }

/* Wave 7.8: pilot-only footer controls (rendered only when PILOT_TELEMETRY is on) */
.hk-pilot-footer { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.hk-pilot-footer .hk-pilot-btn { width: auto; flex: 1 1 45%; padding: 10px 12px; font-size: 0.85rem; border-style: dashed; }

/* ============================================================
   Wave 7.9 — "Etiquette": the sign-in screen reads as a tag
   ------------------------------------------------------------
   Housekeepers handle tags all day — the hanger on the door
   handle, the label sewn into the linen. The sign-in card takes
   that form: a punched hanging slot at the top, a perforated
   footer, and stencilled monospace field labels. One idea, spent
   once; everything around it stays quiet.
   Styles are scoped to .hk-login-card so the rest of the app's
   forms are untouched. CSS only — no markup or i18n changes.
   ============================================================ */

.hk-login {
  padding: 28px 20px calc(28px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(15, 76, 92, 0.07), transparent 70%),
    var(--hk-bg);
}

.hk-login-card {
  max-width: 396px;
  padding: 48px 26px 24px;
  border: 1px solid var(--hk-border);
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(21, 24, 26, 0.05),
    0 20px 44px -20px rgba(21, 24, 26, 0.38);
}

/* The punched hole. Offset left like a real door hanger or luggage tag —
   centred it reads as a bottom-sheet drag handle, which is a different and
   misleading affordance. Small, round, and genuinely recessed. */
.hk-login-card::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 27px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--hk-bg);
  box-shadow:
    inset 0 2px 3px rgba(21, 24, 26, 0.34),
    0 1px 0 rgba(255, 255, 255, 0.9);
}

/* Hairline from the hole to the card edge: the fold a tag takes when it hangs. */
.hk-login-card::after {
  content: "";
  position: absolute;
  top: 25px;
  left: 52px;
  right: 26px;
  height: 1px;
  background: var(--hk-border);
}

/* Quiet, not a chip. It sits on the hole's line as a peer of the tag edge. */
.hk-login-lang {
  top: 15px;
  right: 20px;
  min-height: 22px;
  padding: 0;
  background: transparent;
  border: 0;
  color: var(--hk-text-muted);
  font-family: var(--hk-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: underline;
  text-underline-offset: 3px;
  z-index: 1;
}

.hk-login-card h1 {
  margin: 0 0 6px;
  padding-right: 0;
  font-size: 1.72rem;
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.021em;
}

.hk-login-subtitle {
  margin: 0 0 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--hk-border);
  font-size: 0.92rem;
}

/* Stencilled labels — the voice of a stamped linen tag. Scoped to the login
   card on purpose: the in-app forms keep their quieter sentence-case labels. */
.hk-login-card .hk-field { margin-bottom: 16px; }

.hk-login-card .hk-field label {
  font-family: var(--hk-mono);
  font-size: 0.67rem;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 7px;
}

.hk-login-card .hk-field input {
  min-height: 52px;
  padding: 14px;
  background: var(--hk-surface);
  border: 1.5px solid var(--hk-border);
  border-radius: 10px;
}

.hk-login-card .hk-field input:focus-visible {
  border-color: var(--hk-primary);
  outline: 3px solid var(--hk-primary-soft);
  outline-offset: 0;
}

.hk-login-card .hk-btn {
  min-height: 54px;
  margin-top: 4px;
  border-radius: 10px;
  font-weight: 650;
}

.hk-login-card .hk-btn-secondary { background: transparent; }

.hk-login-sent-icon { color: var(--hk-on-primary); }

/* Perforated footer: the build stamp reads like the printed detail on the
   bottom of a tag rather than debug output left on screen. */
.hk-version-login {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px dashed var(--hk-border);
  font-family: var(--hk-mono);
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  opacity: 0.8;
}

/* Dark mode: the previous rules pinned #93c5fd, which was tied to the old
   framework blue. Route everything through the token instead. */
@media (prefers-color-scheme: dark) {
  .hk-login-switch { color: var(--hk-primary); }
  .hk-login-card .hk-btn-secondary { color: var(--hk-primary); border-color: var(--hk-primary); }
  .hk-login-switch:focus-visible,
  .hk-login-lang:focus-visible,
  .hk-login-sent:focus { outline-color: var(--hk-primary); }
  .hk-login-feedback.is-error { color: #f09189; background: #2a100c; }
  .hk-login-feedback:focus { outline-color: #f09189; }
  .hk-login-card {
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.5),
      0 20px 44px -20px rgba(0, 0, 0, 0.8);
  }
}

/* The card is a physical object; on a coarse pointer it should not animate
   under the finger, and reduced-motion users get nothing extra anywhere. */
@media (prefers-reduced-motion: reduce) {
  .hk-login-card { transition: none; }
}
