/* Cards, meters, tables, chips, forms. */

.card {
  background: var(--panel); border: 1px solid var(--hair); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.calm { color: var(--muted); background: var(--panel); border: 1px dashed var(--hair); border-radius: var(--radius); padding: 18px; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; flex: none; }
.meta-line { display: flex; align-items: center; font-size: 13px; color: var(--muted); }
.meta-line .dot { width: 8px; height: 8px; }

/* needs-you cards */
.card-top { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.badge { font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.badge-needs { background: var(--needs-bg); color: var(--needs-ink); }
.badge-failed { background: var(--failed-bg); color: var(--failed); }
.needs-card { border-left: 4px solid var(--needs); }
.needs-card.needs-failed { border-left-color: var(--failed); }
.ask { font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; background: var(--panel); color: var(--ink);
  border: 1px solid var(--btn-border); border-radius: 8px; padding: 9px 14px; min-height: 40px;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--hair-soft); }
.btn-primary { background: var(--ink); color: var(--ground); border-color: var(--ink); font-weight: 600; }
.btn-primary:hover { background: var(--ink); opacity: 0.88; }
.btn:disabled { opacity: 0.6; cursor: default; }
.linkish { background: none; border: 0; padding: 4px 0; color: var(--link); text-align: left; cursor: pointer; text-decoration: underline; font-size: 13px; }

/* seat cards */
.seat-card { border-top: 3px solid var(--seat, var(--hair)); }
.seat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.seat-name { font-weight: 600; font-size: 16px; }
.seat-sub { margin-top: -8px; overflow-wrap: anywhere; }

.win { display: flex; flex-direction: column; gap: 4px; }
/* The window name stays on one line; the figure moves under it when both do not fit. */
.win-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 8px; font-size: 13px; }
.win-head > :first-child { white-space: nowrap; }
.win-head > :last-child { white-space: nowrap; margin-left: auto; }
.win-sub { font-size: 12px; color: var(--muted); }
.win-pace { font-size: 12px; font-weight: 500; }
.pace-ok { color: var(--ok-ink); } .pace-warn { color: var(--warn-ink); } .pace-bad { color: var(--needs-ink); }
.hot { color: var(--failed); font-weight: 600; }
.hot-tag { font-family: var(--sans); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }

.meter { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; display: block; }
.meter-fill { display: block; height: 100%; background: var(--seat, var(--muted)); border-radius: 4px; min-width: 2px; }
.meter-s { width: 54px; height: 6px; flex: none; }
.ctx { display: inline-flex; align-items: center; gap: 8px; }
.ctx.hot .meter-fill { background: var(--failed); }

.chip { font-size: 13px; padding: 4px 8px; border-radius: 6px; align-self: flex-start; }
.chip-ok { color: var(--ok-ink); background: var(--ok-bg); }
.chip-warn { color: var(--warn-ink); background: var(--warn-bg); }
.chip-bad { color: var(--needs-ink); background: var(--needs-bg); }

.extra summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; margin-top: 4px; }
.kv dt { color: var(--muted); }
.kv dd { overflow-wrap: anywhere; min-width: 0; }
.kv dd .dot { margin-right: 6px; }

/* machines */
.machine-mini { flex-direction: row; justify-content: space-between; align-items: center; padding: 14px 16px; gap: 10px; color: var(--ink); text-decoration: none; }
.machine-mini:hover { border-color: var(--btn-border); background: var(--hair-soft); }
.mini-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mini-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.machine-mini > .small { flex: none; white-space: nowrap; }
.machine-name { overflow-wrap: anywhere; }
.status-ok { color: var(--ok-ink); font-weight: 600; } .status-warn { color: var(--needs-ink); font-weight: 600; } .status-muted { color: var(--muted); }
.slots { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; font-size: 14px; }
.machine h3 { margin-top: 4px; }
.status-bad { color: var(--failed); font-weight: 600; }
.machine-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 2px 0 4px; }
.machine-chips .chip { align-self: auto; padding: 2px 8px; font-size: 12px; }
.reach-chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; border: 1px solid var(--hair); color: var(--muted); }
.reach-chip.reach-direct { color: var(--ok-ink); background: var(--ok-bg); border-color: transparent; }
.reach-chip.reach-forward, .reach-chip.reach-pull { color: var(--ink); background: var(--panel); }
.machine-alert, .pull-line { margin: 6px 0 0; overflow-wrap: anywhere; }
.machine-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--hair-soft); }
.machine-actions button:disabled { opacity: 0.5; cursor: not-allowed; }
.machine.is-removed { opacity: 0.72; }
.removed-machines { margin-top: 28px; }
.removed-machines .section-title { font-size: 16px; margin: 0 0 10px; }
.page-head .actions { align-items: center; }

/* live badge */
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #2E8540; }
/* Connecting or reconnecting is normal for a moment: neutral grey, not red (G5). */
.live-idle { color: var(--muted); }
.live-idle .live-dot { background: var(--muted); }
.live-warn .live-dot { background: var(--needs); }
.live-warn { color: var(--needs-ink); }

/* state tags */
.state { white-space: nowrap; font-weight: 600; }
.state-needs { color: var(--needs-ink); }
.state-working { color: var(--working-ink); font-weight: 500; }
.state-done { color: var(--muted); font-weight: 500; }
.state-failed { color: var(--failed); }
.state-ended { color: var(--ended-ink); font-weight: 500; }
.flag { font-size: 12px; color: var(--warn-ink); background: var(--warn-bg); padding: 1px 6px; border-radius: 4px; margin-left: 4px; white-space: nowrap; }

/* compact session lines (Now) */
.lines { background: var(--panel); border: 1px solid var(--hair); border-radius: var(--radius); }
.line { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 12px; align-items: baseline; padding: 11px 16px; border-top: 1px solid var(--hair-soft); }
.line:first-child { border-top: 0; }
.line-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-meta { display: inline-flex; align-items: center; white-space: nowrap; }
.line-meta .dot { width: 8px; height: 8px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { border: 1px solid var(--btn-border); background: var(--panel); border-radius: 18px; padding: 6px 14px; min-height: 36px; cursor: pointer; font-size: 14px; }
.chip-btn[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.chip-btn.chip-needs[aria-pressed="true"] { background: var(--needs-bg); color: var(--needs-ink); border-color: var(--needs); font-weight: 600; }
.chip-n { opacity: 0.8; }
.field { font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
select, input[type="password"], input[type="text"] { border: 1px solid var(--btn-border); border-radius: 8px; background: var(--panel); padding: 6px 8px; min-height: 36px; }

/* sessions table */
.table-wrap { background: var(--panel); border: 1px solid var(--hair); border-radius: var(--radius); overflow-x: auto; }
.sessions-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sessions-table thead th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; padding: 12px 8px; }
.sessions-table thead th:first-child { padding-left: 16px; }
.group-row th { text-align: left; background: var(--group); padding: 9px 16px; border-top: 1px solid var(--hair); font-weight: 600; }
.srow { border-top: 1px solid var(--hair-soft); cursor: pointer; }
.srow:hover { background: var(--hair-soft); }
.srow td { padding: 11px 8px; vertical-align: top; }
.srow td:first-child { padding-left: 16px; white-space: nowrap; }
.srow td:last-child { padding-right: 16px; white-space: nowrap; }
.srow-needs td:first-child { box-shadow: inset 3px 0 0 var(--needs); }
.c-session a { color: var(--ink); text-decoration: none; }
.c-session a:hover { text-decoration: underline; }
.c-last { max-width: 380px; color: var(--ink); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.machine-chip { font-size: 12px; border: 1px solid var(--hair); border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.foot-note { max-width: 70ch; }

/* session detail */
.back { font-size: 14px; }
.quote { border-left: 4px solid var(--needs); }
.quote.needs-done, .quote.needs-working, .quote.needs-ended { border-left-color: var(--hair); }
.quote.needs-failed { border-left-color: var(--failed); }
.quote-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.quote p { font-size: 16px; overflow-wrap: anywhere; white-space: pre-wrap; }
.timeline { display: flex; flex-direction: column; gap: 0; margin-top: 4px; border-left: 2px solid var(--hair); padding-left: 14px; }
.tl-item { position: relative; padding: 6px 0 10px; display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; }
.tl-item::before { content: ''; position: absolute; left: -20px; top: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--panel); border: 2px solid var(--muted); }
.tl-time { color: var(--muted); }
.tl-msg { flex-basis: 100%; overflow-wrap: anywhere; }
.tok { margin-top: 4px; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); gap: 10px; padding: 24px; }
.login-card label { font-weight: 600; margin-top: 6px; }
.login-card input { width: 100%; min-height: 44px; font-family: var(--mono); }
.login-card .btn { margin-top: 6px; }
.login-col { width: min(440px, 100%); display: flex; flex-direction: column; gap: 18px; }
.login-col .login-card { width: 100%; }
.login-token { gap: 8px; padding-top: 10px; }
.login-more summary { cursor: pointer; color: var(--link); font-size: 14px; }
.brand-row svg { color: var(--ink); }
.form-error { color: var(--failed); background: var(--failed-bg); padding: 8px 10px; border-radius: 8px; font-size: 14px; }
.form-error[hidden] { display: none; }


/* ---- phone: table rows become cards ------------------------------------------- */
/* ---- Peers: kill switch, account grid, audit ------------------------------------------------ */
.kill .panel { border-left: 4px solid var(--hair); }
.kill-on .panel { border-left-color: var(--failed); background: var(--failed-bg); }
.btn-big { min-height: 48px; font-size: 16px; font-weight: 600; }
.mx-wrap {
  overflow-x: auto; max-width: 100%;
  /* Edge fades that show only while there is more to scroll to (R5). */
  background:
    linear-gradient(to right, var(--panel) 30%, transparent) left center / 28px 100% no-repeat local,
    linear-gradient(to left, var(--panel) 30%, transparent) right center / 28px 100% no-repeat local,
    linear-gradient(to right, var(--hair), transparent) left center / 10px 100% no-repeat scroll,
    linear-gradient(to left, var(--hair), transparent) right center / 10px 100% no-repeat scroll;
}
.mx-hint { margin-top: 4px; }
.mx .mx-row, .mx .mx-corner { position: sticky; left: 0; z-index: 1; background: var(--panel); }
@media (max-width: 520px) { .mx-row .mx-name, .mx-col .mx-name { max-width: 6.5em; } }
.mx { border-collapse: collapse; }
.mx th, .mx td { padding: 4px; text-align: center; font-weight: 500; }
.mx-corner { font-size: 12px; color: var(--muted); text-align: left; }
/* Seat names on one line, cut with an ellipsis (the full name is the title), never broken
   mid-word (PE2). */
.mx-col, .mx-row { font-size: 13px; max-width: 9em; }
.mx .mx-row { text-align: left; padding-right: 10px; }
.mx-name { display: block; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; word-break: keep-all; }
.mx-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.mx-legend li { display: inline-flex; align-items: baseline; gap: 4px; }
.mx-glyph { display: inline-block; min-width: 1.2em; text-align: center; font-weight: 600; color: var(--ink); }
.mx-cell { min-width: 48px; }
.mx-self { color: var(--muted); }
.mx-btn { width: 44px; height: 44px; border: 1px solid var(--btn-border); border-radius: 8px; background: var(--panel); color: var(--muted); font-size: 18px; cursor: pointer; }
.mx-btn.mx-out, .mx-btn.mx-in, .mx-btn.mx-both { color: var(--ok-ink); background: var(--ok-bg); }
.mx-btn[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 1px; }
.mx-edit { gap: 8px; }
.audit-list { list-style: none; margin: 0; padding: 0; overflow: hidden; }
.audit-list .audit-row:first-child { border-top: 0; }
.audit-row time { white-space: nowrap; flex: none; }

@media (max-width: 820px) {
  .page-head { align-items: flex-start; }
  .line { grid-template-columns: auto minmax(0, 1fr); }
  .line-meta { grid-column: 1 / -1; white-space: normal; overflow-wrap: anywhere; min-width: 0; }
  .line-main { white-space: normal; }

  .table-wrap { background: transparent; border: 0; overflow: visible; }
  .sessions-table, .sessions-table tbody { display: block; }
  .sessions-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .sessions-table tbody { margin-bottom: 14px; }
  .group-row, .group-row th { display: block; }
  .group-row th { border: 1px solid var(--hair); border-radius: var(--radius) var(--radius) 0 0; }
  .srow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; background: var(--panel); border: 1px solid var(--hair); border-top: 0; padding: 12px 14px; }
  .tbody-last, .srow:last-child { border-radius: 0 0 var(--radius) var(--radius); }
  .srow td { display: block; padding: 0 !important; }
  .srow td:first-child { box-shadow: none; }
  .srow-needs { border-left: 4px solid var(--needs); }
  .c-state { grid-column: 1; grid-row: 1; }
  .c-state .flag { display: none; }
  .c-session { grid-column: 2; grid-row: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .c-age { grid-column: 3; grid-row: 1; font-size: 13px; }
  .c-last { grid-column: 1 / -1; grid-row: 2; max-width: none; font-size: 14px; }
  .c-machine { grid-column: 1 / 3; grid-row: 3; }
  .c-ctx { grid-column: 3; grid-row: 3; justify-self: end; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dt { margin-top: 8px; font-size: 12px; }
  .machine .kv { grid-template-columns: max-content 1fr; gap: 6px 16px; }
  .machine .kv dt { margin-top: 0; font-size: inherit; }
  .cols { grid-template-columns: 1fr; }
}

/* Analytics (views/analytics.js) */
.ana-controls { align-items: center; flex-wrap: wrap; }
.ana-controls select { border: 1px solid var(--btn-border); background: var(--panel); border-radius: 18px; padding: 6px 12px; min-height: 36px; }
.ana-body.is-loading { opacity: 0.55; }
.ana-body { display: flex; flex-direction: column; gap: 24px; }
.ana-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 12px; }
.ana-tile { display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--hair); border-radius: var(--radius); padding: 12px 14px; }
.ana-tile-v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ana-bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; background: var(--panel); border: 1px solid var(--hair); border-radius: var(--radius); padding: 10px 10px 0; }
.ana-bar { flex: 1 1 0; min-width: 1px; background: var(--accent); border-radius: 2px 2px 0 0; border: 0; padding: 0; cursor: pointer; }
.ana-bar:hover, .ana-bar.is-picked { background: var(--needs); }
.ana-bars-wrap { display: flex; flex-direction: column; gap: 2px; }
.ana-ymax { align-self: flex-start; }
.ana-picked { min-height: 1.45em; margin-top: 6px; }
.ana-legend { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.ana-legend .ana-cell { width: 12px; height: 12px; min-height: 0; aspect-ratio: auto; }
.ana-bar.is-history { background: var(--track); }
.ana-axis { display: flex; justify-content: space-between; margin-top: 4px; }
.ana-list { list-style: none; padding: 0; margin: 0; }
.ana-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--hair-soft); }
.ana-row:first-child { border-top: 0; }
.ana-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--selected); border-radius: 0 6px 6px 0; }
.ana-name { position: relative; display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.ana-val { position: relative; font-variant-numeric: tabular-nums; font-weight: 600; }
.ana-heat { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 2px; align-items: center; }
.ana-hr, .ana-wd { font-size: 11px; color: var(--muted); }
.ana-cell { aspect-ratio: 1; min-height: 10px; border-radius: 2px; background: var(--track); }
.ana-cell.lvl-1 { background: color-mix(in srgb, var(--accent) 30%, var(--track)); }
.ana-cell.lvl-2 { background: color-mix(in srgb, var(--accent) 55%, var(--track)); }
.ana-cell.lvl-3 { background: color-mix(in srgb, var(--accent) 80%, var(--track)); }
.ana-cell.lvl-4 { background: var(--accent); }

/* ---- shared pieces added with the UI audit fixes ------------------------------------------- */
/* A title block: h1, the More pills, a line under them. */
.head-title { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; width: 100%; }
.help { cursor: help; }
.nav-seat-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-what { font-weight: 500; }

/* Technical details behind a disclosure (versions, ids, hashes). */
.tech > summary { cursor: pointer; font-size: 13px; color: var(--muted); width: fit-content; }
.tech > summary:hover { color: var(--ink); }
.tech-body { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; min-width: 0; }
.advanced > summary { font-size: 15px; font-weight: 600; color: var(--ink); }
.advanced .tech-body { gap: 18px; padding-top: 14px; }
.sub-block { display: flex; flex-direction: column; gap: 10px; }

/* A one-line status above a page's sections. */
.notice { background: var(--panel); border: 1px solid var(--hair); border-radius: var(--radius); padding: 11px 14px; font-size: 14px; }
.notice-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.notice-warn a { color: inherit; font-weight: 600; }
.section-help { max-width: 72ch; margin-top: -4px; }
.status-row { align-items: center; }
.status-row .btn { flex: none; white-space: nowrap; }
.status-row .row-text b { font-weight: 600; }
.receivers .row { padding-left: 0; padding-right: 0; }
.no-usage { overflow-wrap: anywhere; }

/* Sessions: imported history folded into one line. */
.history { display: flex; flex-direction: column; gap: 10px; }
.history-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; background: var(--panel); border: 1px dashed var(--hair); border-radius: var(--radius); padding: 12px 16px; font-size: 14px; }

@media (max-width: 820px) {
  /* Empty cells leave no orphan dashes in the phone card rows (S6). */
  .srow td.is-empty { display: none; }
  /* A long machine name is cut, never drawn over the context figure (S5). */
  .c-machine { min-width: 0; overflow: hidden; }
  .c-machine .machine-chip { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
  /* The machine card fits 320 px (M4). */
  .machine .kv { grid-template-columns: minmax(0, max-content) minmax(0, 1fr); }
  .machine .kv dd, .machine .kv dt { min-width: 0; overflow-wrap: anywhere; }
  .ana-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ana-tile { padding: 10px 12px; min-width: 0; }
  .ana-tile-v { font-size: 20px; overflow-wrap: anywhere; }
  .ana-tile .small { overflow-wrap: anywhere; }
  .chips.ana-controls { flex-wrap: wrap; overflow: visible; }
  .head-row .actions { width: 100%; }
}
/* A card's or form's main button keeps its own width on a computer. */
@media (min-width: 821px) {
  .card > .btn, .override-form > .btn, .kill .btn { align-self: flex-start; }
}
/* Long account and machine names never widen the sidebar, a select or a table column (LN2). */
@media (min-width: 821px) { .nav { min-width: 0; max-width: 232px; } }
.nav-accounts a { min-width: 0; }
.filters select { max-width: 14em; text-overflow: ellipsis; }
.machine-chip { display: inline-block; max-width: 16em; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
