/* Phase 4: the installable app. Panels and rows, switches, rings, swipe rows, banners,
   dialogs, the pair screen, Alerts/Settings/Devices. Phone tweaks are at the end. */

.col { display: flex; flex-direction: column; gap: 12px; }
.pad-s { padding: 14px 16px; }
.plain { display: flex; flex-direction: column; gap: 6px; }
.break { overflow-wrap: anywhere; }
.status-ok { color: var(--ok-ink); }
.status-warn { color: var(--needs-ink); }
.danger { color: var(--failed); }
code { font-family: var(--mono); font-size: 0.92em; background: var(--hair-soft); padding: 1px 5px; border-radius: 4px; }

/* ---- buttons and links ------------------------------------------------------------ */
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btn-wide { width: 100%; }
.btn-danger { color: var(--failed); border-color: var(--failed); }
.btn-amber { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.linkish.amber { color: var(--accent); }
.tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; border: 1px solid var(--hair); border-radius: 6px; padding: 1px 6px; margin-left: 8px; color: var(--muted); }
.highlight { box-shadow: 0 0 0 2px var(--accent); }

/* ---- panels and rows ---------------------------------------------------------------- */
.panel { background: var(--panel); border: 1px solid var(--hair); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.panel.col, .panel.pad-s { gap: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--hair-soft); min-width: 0; }
.row:first-child { border-top: 0; }
.row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-value { text-align: right; overflow-wrap: anywhere; }
.panel > .col > .row, .panel.pad-s > .row { padding-left: 0; padding-right: 0; }
.kv-row { padding: 6px 0; border-top: 0; }
.cards-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 14px; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.col-field { display: flex; flex-direction: column; align-items: stretch; gap: 4px; color: var(--ink); }
.col-field input { width: 100%; }
input[type="time"], input[type="text"][readonly] { border: 1px solid var(--btn-border); border-radius: 8px; background: var(--panel); padding: 6px 8px; min-height: 36px; }
input[readonly] { color: var(--muted); }

/* ---- switches ------------------------------------------------------------------------ */
.switch-row { display: flex; flex: 1; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; min-width: 0; }
.switch-row.is-disabled { cursor: default; opacity: 0.7; }
.switch-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
input.sw { appearance: none; -webkit-appearance: none; flex: none; width: 44px; height: 26px; border-radius: 13px; background: var(--track); border: 1px solid var(--btn-border); position: relative; cursor: pointer; margin: 0; transition: background 0.15s; }
input.sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--panel); box-shadow: 0 1px 2px rgb(0 0 0 / 0.35); transition: transform 0.15s; }
input.sw:checked { background: var(--accent); border-color: var(--accent); }
input.sw:checked::after { transform: translateX(18px); background: #fff; }
input.sw:disabled { cursor: default; }
.quiet { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.quiet-times { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.rule-row .field, .rule-row select { flex: none; }

/* ---- pills (More sub-navigation) ----------------------------------------------------------- */
/* One row; it scrolls sideways when too wide, with a fade on the side that has more (R12). */
.pills { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; scrollbar-width: none; max-width: 100%; padding: 2px 0; }
.pills::-webkit-scrollbar { display: none; }
.pills.fade-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
.pills.fade-l { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); }
.pills.fade-l.fade-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); }
.pill { flex: none; border: 1px solid var(--btn-border); border-radius: 18px; padding: 6px 14px; min-height: 36px; display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); background: var(--panel); white-space: nowrap; font-size: 14px; }
.pill[aria-current="page"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }

/* ---- More -------------------------------------------------------------------------------- */
.more-list { overflow: hidden; }
.more-list li { border-top: 1px solid var(--hair-soft); }
.more-list li:first-child { border-top: 0; }
.more-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; color: var(--ink); text-decoration: none; min-height: 56px; }
.more-link:hover { background: var(--hair-soft); }
.more-link.is-disabled { color: var(--muted); }
.more-link.is-disabled:hover { background: transparent; }
.more-text { display: flex; flex-direction: column; gap: 2px; }
.chev { color: var(--muted); font-size: 22px; }

/* ---- Now: rings, needs cards with Seen / Snooze --------------------------------------------- */
.rings { display: flex; justify-content: space-between; background: var(--panel); border: 1px solid var(--hair); border-radius: 14px; padding: 12px 10px; }
.ring { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 25%; min-width: 0; color: var(--ink); text-decoration: none; }
.ring-track { stroke: var(--track); }
.ring-num { fill: var(--ink); font-family: var(--mono); }
.ring-num.hot { fill: var(--failed); }
/* At most two lines (a told-apart name like "mayank.raj · gmail" needs the second), then cut (LN1). */
.ring-name { font-size: 12px; font-weight: 600; max-width: 100%; text-align: center; overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.ring-text { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; max-width: 100%; }
.ring-reset { font-size: 11px; color: var(--muted); text-align: center; overflow-wrap: anywhere; line-height: 1.3; }
/* Narrow phones: two rings per row, the text beside the ring, so names and reset times never collide (R2). */
@media (max-width: 380px) {
  .rings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
  .ring { width: auto; flex-direction: row; align-items: center; gap: 8px; }
  .ring svg { flex: none; }
  .ring-text { align-items: flex-start; flex: 1 1 0; }
  .ring-name, .ring-reset { text-align: left; }
}
.swipe-note { margin-left: auto; }

.swipe { position: relative; border-radius: var(--radius); min-width: 0; }
.swipe-hint { display: none; }
.needs-card { cursor: pointer; }
/* A seen card fades only its badge and border, so its text keeps full contrast (N8, DK1). */
.needs-card.is-seen { border-left-color: var(--hair); }
.needs-card.is-seen .badge { opacity: 0.6; }
.seen-tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); border: 1px solid var(--hair); border-radius: 6px; padding: 1px 6px; }
.menu-btn { display: none; margin-left: 4px; background: none; border: 0; font-size: 22px; line-height: 1; padding: 2px 8px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.card-top { align-items: center; }
.alert-meta { font-size: 12.5px; font-family: var(--sans); }
.alert-line { font-weight: 500; }
.alert-pending { color: var(--warn-ink); }
.alert-fired { color: var(--ok-ink); }
.alert-snoozed { color: var(--working-ink); }
.alert-seen, .alert-skipped, .alert-cancelled { color: var(--muted); }
.alert-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.is-seen td, .is-seen .ask { color: var(--muted); }

/* ---- banners, toasts, dialog ---------------------------------------------------------------- */
.banners { position: sticky; top: 0; z-index: 30; }
.banner { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 16px; padding-top: calc(8px + env(safe-area-inset-top)); font-size: 14px; }
.banner + .banner { padding-top: 8px; }
.banner-offline { background: var(--warn-bg); color: var(--warn-ink); border-bottom: 1px solid var(--hair); }
.banner-update { background: var(--ink); color: var(--ground); }
.banner-update .btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 60; display: flex; justify-content: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--ground); padding: 10px 14px; border-radius: 10px; font-size: 14px; pointer-events: auto; max-width: 480px; }

dialog.dialog { border: 1px solid var(--hair); border-radius: 14px; background: var(--panel); color: var(--ink); padding: 18px; width: min(460px, calc(100vw - 32px)); }
dialog.dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog.dialog[open] { display: flex; flex-direction: column; gap: 14px; }
.dialog-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.pair-box { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.qr { width: 216px; height: 216px; flex: none; border-radius: 10px; border: 1px solid var(--hair); background: #fff; }
.pair-digits { font-size: 30px; letter-spacing: 0.08em; font-weight: 600; margin: 0; }
.pair-digits.big { font-size: 44px; text-align: center; padding: 14px 0; }

/* ---- Alerts log, Devices ---------------------------------------------------------------------- */
.log { overflow: hidden; }
.log-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 11px 16px; border-top: 1px solid var(--hair-soft); font-size: 14px; }
.log-row:first-child { border-top: 0; }
.log-time { color: var(--muted); }
.log-title { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-outcome { color: var(--muted); font-size: 13px; }
.out-cancelled, .out-skipped { font-style: italic; }
.out-seen { color: var(--ok-ink); }
.override-form { padding: 14px 16px; gap: 12px; }
.row-actions { display: flex; gap: 8px; flex: none; flex-wrap: wrap; }
.ov-edit { display: block; }
.override-edit { display: flex; flex-direction: column; gap: 10px; padding: 0; }
.ov-edit-title { margin: 0; font-size: 14px; color: var(--ink); }

.dev-list { overflow: hidden; }
.dev-row { display: flex; justify-content: space-between; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--hair-soft); flex-wrap: wrap; }
.dev-row:first-child { border-top: 0; }
.dev-row.is-revoked { opacity: 0.55; }
.dev-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 260px; }
.dev-targets { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.dev-actions { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.test-cell { display: inline-flex; gap: 4px; align-items: baseline; }

.room { background: var(--ok-bg); color: var(--ok-ink); border-radius: 12px; padding: 10px 14px; }
.cmd { margin: 0; background: #17191B; color: #ECEEEF; border: 1px solid var(--hair); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.session-actions .copy, .session-actions .btn { flex: 0 0 auto; }

/* ---- the pair screen: the same light/dark tokens as every other page (P1, P6) ------------------ */
.pair-screen {
  min-height: 100vh; min-height: 100dvh; background: var(--ground); color: var(--ink);
  padding: calc(22px + env(safe-area-inset-top)) 22px calc(22px + env(safe-area-inset-bottom));
}
.pair-inner { max-width: 440px; margin: 0 auto; min-height: calc(100vh - 44px); display: flex; flex-direction: column; gap: 16px; }
.pair-inner > .col { flex: 1; }
/* On a computer the note follows the form instead of sitting at the bottom of the window. */
@media (min-width: 821px) {
  .pair-inner { min-height: 0; padding-top: 6vh; }
  .pair-inner > .col { flex: none; }
}
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 700; font-size: 18px; }
.pair-screen h1 { font-size: 28px; font-weight: 700; }
.pair-lead { color: var(--muted); font-size: 16px; line-height: 1.5; }
.pair-note { background: var(--panel); border: 1px solid var(--hair); border-radius: 14px; padding: 16px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.pair-alt { text-align: center; font-size: 14px; }
.pair-form label { font-weight: 600; font-size: 14px; }
.pair-form input { width: 100%; min-height: 48px; font-size: 18px; background: var(--panel); color: var(--ink); }
.pair-form .name-row { display: flex; gap: 8px; align-items: stretch; }
.pair-form .name-row input { flex: 1; min-width: 0; width: auto; }
.pair-form .name-row .btn { flex: none; min-height: 48px; }
#pair-code { font-family: var(--mono); letter-spacing: 0.1em; }
.steps { padding-left: 22px; list-style: decimal; display: flex; flex-direction: column; gap: 8px; font-size: 16px; }
.camera { background: var(--panel); border: 1px solid var(--hair); border-radius: 20px; padding: 22px 16px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.camera-frame { width: 208px; height: 208px; border: 3px solid var(--accent); border-radius: 22px; overflow: hidden; position: relative; }
.camera-video { width: 100%; height: 100%; object-fit: cover; display: none; }
.camera-frame.is-live .camera-video { display: block; }
.camera-label { font-size: 13px; color: var(--muted); }

/* ---- phone ----------------------------------------------------------------------------------- */
@media (max-width: 820px) {
  .page-head { flex-wrap: nowrap; align-items: center; }
  .rings { margin-top: -8px; }
  .page-now { gap: 18px; }
  .needs-block { gap: 10px; }
  .block-head h2 { font-size: 18px; font-weight: 600; }
  .grid-needs { grid-template-columns: 1fr; gap: 12px; }
  /* One full-width row per machine (N5). */
  .grid-mini { grid-template-columns: 1fr; gap: 8px; }
  .machine-mini { padding: 12px 14px; }

  .badge { background: none; padding: 0; text-transform: uppercase; font-size: 12px; letter-spacing: 0.04em; }
  .card-age { margin-left: auto; font-size: 13px; }
  .menu-btn { display: inline-block; }
  .needs-card { padding: 14px 16px; gap: 8px; }
  .needs-card .card-links { display: none; }
  .needs-card .alert-actions { display: none; }
  .needs-card.menu-open .alert-actions { display: flex; }
  .needs-card .ask { font-size: 16px; }

  .swipe { overflow: hidden; background: var(--hair-soft); }
  .swipe-hint { display: flex; position: absolute; top: 0; bottom: 0; align-items: center; padding: 0 20px; font-size: 14px; font-weight: 600; width: 50%; }
  .swipe-hint-l { left: 0; background: var(--ok-bg); color: var(--ok-ink); }
  .swipe-hint-r { right: 0; justify-content: flex-end; background: var(--warn-bg); color: var(--warn-ink); }
  .swipe .needs-card { position: relative; touch-action: pan-y; }
  .swipe .needs-card.swipe-settle { transition: transform 0.2s ease; }

  .page-head { flex-direction: column; align-items: stretch; }
  /* Chips wrap, so every filter (Ended too) is in view at 320 px (S2). */
  .filters { flex-wrap: wrap; width: 100%; min-width: 0; max-width: 100%; }
  .chips { flex-wrap: wrap; gap: 6px; }
  .chip-btn { padding: 5px 11px; min-height: 34px; }
  .chip-btn { white-space: nowrap; }

  .session-actions { flex-direction: column; }
  .session-actions .btn { width: 100%; }
  .session-actions .alert-actions { display: flex; width: 100%; }
  .session-actions .alert-actions .btn { flex: 1; }
  .cols { grid-template-columns: 1fr; }
  .cards-2 { grid-template-columns: 1fr; }
  .log-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .banner-update { justify-content: space-between; }
  .row { padding: 12px 14px; }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* A row of text and one control: below 520 px the control goes under the text, full width (R1). */
@media (max-width: 520px) {
  .row-ctl { flex-direction: column; align-items: stretch; gap: 8px; }
  .row-ctl select { width: 100%; min-height: 40px; }
}
.toast-action { color: inherit; margin-left: 10px; font-weight: 600; white-space: nowrap; font-size: 14px; }
@keyframes flash { from { box-shadow: inset 0 0 0 2px var(--accent); } to { box-shadow: inset 0 0 0 2px transparent; } }
.flash { animation: flash 2.4s ease-out; }
