/* The signed-in app: shell and views.
   =========================================================================
   A sidebar, a slim top bar, and a page. Every /account/* page and /focus/
   is laid out by this file; the sidebar is the same markup on each of them
   (tests/static-checks.mjs pins the copies to one another), so the app reads
   as one place with several rooms rather than several pages that happen to
   share a logo.

   Everything paints through tokens. The timers are thin, tabular and
   monospace, as they are in the extension and on the phone.
   ========================================================================= */

body.app {
  background-image: none;
  background: var(--bg);
}

.shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
  /* The rail's colour runs the full height of the document, not just the
     sticky viewport-tall box that holds its links. */
  background: linear-gradient(to right, var(--surface) 256px, var(--border) 256px, var(--border) 257px, transparent 257px);
}

/* ---------- sidebar ---------- */

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.9rem 1rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar .brand {
  padding: 0.25rem 0.5rem 0.9rem;
  font-size: 1.2rem;
}

.sidebar .brand-icon { width: 30px; height: 30px; border-radius: 8px; }
.sidebar .brand-icon svg { width: 20px; height: 20px; }

.side-cta {
  margin: 0.2rem 0 1rem;
  width: 100%;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.2;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.side-link svg {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--text-3);
  transition: color var(--transition-fast);
}

.side-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.side-link:hover svg { color: var(--text-2); }

.side-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.side-link.active svg { color: var(--accent); }

.side-label {
  margin: 1.1rem 0 0.35rem;
  padding: 0 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 6px;
  min-width: 0;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.user-lines { min-width: 0; }

.user-email {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-plan {
  font-size: 0.74rem;
  color: var(--text-3);
  margin-top: 1px;
}

.sidebar-links {
  display: flex;
  gap: 0.9rem;
  padding: 0 6px;
  font-size: 0.75rem;
}

.sidebar-links a { color: var(--text-3); }
.sidebar-links a:hover { color: var(--text-2); }

/* ---------- main column ---------- */

.shell-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  height: 60px;
  padding: 0 clamp(1rem, 3vw, 2.5rem);
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-light);
}

.topbar-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.menu-btn {
  display: none;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
}

.page {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.25rem) clamp(1rem, 3vw, 2.5rem) 4rem;
}

/* ---------- the loading screen ----------
   A data room's <main> starts with .is-loading, so its zeros and empty lists
   are never painted before the server answers. The title and any notice stay
   visible; everything else waits. shell.js pageReady() takes it down. */

.page-loading { display: none; }

.page.is-loading > :not(.page-head):not(.greeting):not(#notice):not(.page-loading) {
  display: none !important;
}

.page.is-loading > .page-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  min-height: 42vh;
  color: var(--text-2);
  font-size: 0.92rem;
  text-align: center;
}

.page-loading p { margin: 0; }
.page-loading .small { color: var(--text-3); max-width: 34ch; }

.loader-ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: loader-spin 0.9s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .loader-ring { animation-duration: 2.4s; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.page-head h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.page-head p {
  font-size: 0.95rem;
  margin: 0;
}

.page-head .inline-actions { margin-bottom: 0.2rem; }

/* ---------- tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.tile {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem 1rem;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.tile-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}

.tile-value {
  font-family: var(--mono);
  font-weight: 300;
  font-size: clamp(1.7rem, 2.3vw, 2.2rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text);
  margin: 0.4rem 0 0.15rem;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile.accent .tile-value { color: var(--accent); }
.tile.green .tile-value { color: var(--green); }

.tile-sub {
  font-size: 0.8rem;
  color: var(--text-3);
  line-height: 1.4;
}

/* ---------- panels ---------- */

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  /* Each panel is as tall as its own content. A chart stretched to the
     height of a checklist beside it is mostly blank card. */
  align-items: start;
}

.panel-grid.wide-left { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }

.panel {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.panel + .panel,
.panel-grid + .panel,
.panel + .panel-grid { margin-top: 1.25rem; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.panel-head h2 {
  font-size: 1.08rem;
  margin: 0;
  letter-spacing: -0.01em;
}

.panel-head .pill { font-size: 0.74rem; }

.panel-note {
  font-size: 0.88rem;
  color: var(--text-2);
  line-height: 1.55;
  margin-bottom: 1rem;
}

.panel-foot {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.panel.danger { border-color: var(--red-glow); }
.panel.danger .panel-head h2 { color: var(--red); }

.panel.cta {
  background: var(--accent-soft);
  border-color: var(--border-glow);
}

/* ---------- segmented control (range, period) ---------- */

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.seg button:hover { color: var(--text); }

.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.seg.wrap { flex-wrap: wrap; }

/* ---------- the chart ---------- */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 190px;
}

.chart.small { height: 110px; gap: 6px; }

.chart-col {
  flex: 1 1 0;
  min-width: 2px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1px;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}

.chart-col.is-empty::after {
  content: "";
  display: block;
  height: 2px;
  background: var(--border);
}

.chart-col.is-today { outline: 1px dashed var(--border-glow); outline-offset: 1px; }

.chart-seg { width: 100%; min-height: 2px; }
.chart-seg.extension { background: var(--accent); }
.chart-seg.android   { background: var(--green); }
.chart-seg.web       { background: var(--amber); }
.chart-seg.unknown   { background: var(--text-3); }

.chart-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.74rem;
  color: var(--text-3);
}

.chart-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-2);
}

.chart-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
}

.chart-legend i.extension { background: var(--accent); }
.chart-legend i.android   { background: var(--green); }
.chart-legend i.web       { background: var(--amber); }
.chart-legend i.unknown   { background: var(--text-3); }

/* ---------- the device filter on the history page ---------- */

.history-status { margin-top: 0.35rem !important; min-height: 1.2em; }

.device-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1.25rem;
}

.device-filter[hidden] { display: none; }

.device-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
  max-width: 100%;
}

.device-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-chip:hover { color: var(--text); border-color: var(--accent); }

.device-chip[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.device-chip i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: none;
}

.device-chip i.extension { background: var(--accent); }
.device-chip i.android   { background: var(--green); }
.device-chip i.web       { background: var(--amber); }
.device-chip i.unknown   { background: var(--text-3); }

/* ---------- figures ---------- */

.figures {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
}

.acct-figure {
  padding: 0.95rem 1rem;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  min-width: 0;
}

.acct-figure-value {
  font-family: var(--mono);
  font-weight: 300;
  font-size: 1.5rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.acct-figure-label {
  font-size: 0.78rem;
  color: var(--text-3);
  margin-top: 3px;
  line-height: 1.4;
}

/* ---------- checklist ---------- */

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.check-row:first-child { border-top: 0; }

.check-mark {
  width: 22px;
  height: 22px;
  flex: none;
  margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--border);
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.check-mark.done {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.check-row.done .check-title { color: var(--text-3); text-decoration: line-through; }
.check-main { flex: 1 1 auto; min-width: 0; }
.check-title { font-weight: 600; font-size: 0.92rem; color: var(--text); }
.check-sub { font-size: 0.8rem; color: var(--text-3); margin-top: 2px; line-height: 1.45; }
.check-row .btn { flex: none; }

/* ---------- empty states ---------- */

.empty-state {
  text-align: center;
  padding: 2.25rem 1rem;
}

.empty-state h3 { font-size: 1.05rem; margin-bottom: 0.4rem; }
.empty-state p { font-size: 0.9rem; max-width: 480px; margin: 0 auto 1.1rem; }
.empty-state .inline-actions { justify-content: center; }

/* ---------- settings rows ---------- */

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.settings-row:first-of-type { border-top: 0; }
.settings-row .settings-label { font-weight: 600; font-size: 0.92rem; color: var(--text); }
.settings-row .settings-hint { font-size: 0.82rem; color: var(--text-3); margin-top: 2px; line-height: 1.45; }

/* ---------- plan cards ---------- */

.sku-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.sku-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.sku-card.featured { border-color: var(--accent); background: var(--surface-card); }
.sku-card.current { border-color: var(--green); }
.sku-name { font-weight: 700; font-size: 1rem; color: var(--text); display: flex; align-items: center; gap: 8px; }

.sku-price {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.9rem;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}

.sku-price small {
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  letter-spacing: 0;
  margin-left: 4px;
}

.sku-sub { font-size: 0.82rem; color: var(--text-3); flex: 1; }
.sku-card .btn { margin-top: 0.75rem; width: 100%; }

/* ---------- guardwall ---------- */

.wall-add {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.wall-add input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 0.75rem 0.95rem;
  font-size: 0.95rem;
  font-family: var(--mono);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.wall-add input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.wall-add-hint {
  font-size: 0.8rem;
  color: var(--text-3);
  margin-top: 0.6rem;
  min-height: 1.2em;
}

.wall-add-hint.is-app { color: var(--green); }
.wall-add-hint.is-site { color: var(--accent); }

.wall-why {
  display: block;
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.6rem 0.8rem;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.wall-why:focus { outline: none; border-color: var(--accent); }

.wall-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* On is the default state, so it is the plain one. An entry switched off is
   the exception and it says so, rather than relying on colour alone. */
.wall-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.wall-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.wall-chip:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.wall-chip.is-off { color: var(--text-3); text-decoration: line-through; }
.wall-chip.is-off::before { background: var(--text-3); }
/* A suggestion: not walled, one press away. Dashed, and no dot, because the
   dot reads as "on". */
.wall-chip.is-suggest { border-style: dashed; color: var(--text-2); }
.wall-chip.is-suggest::before { display: none; }
.wall-chip:disabled { opacity: 0.5; cursor: not-allowed; }

/* The held confirm. The fill is the hold's own progress, so a person can see
   the two seconds pass rather than wondering whether the button is stuck. */
.wall-hold { position: relative; overflow: hidden; }

/* On a phone a long press selects the label and opens Copy / Share, and the
   browser cancels the pointer to do it: the hold never finished. Nothing to
   select, no callout, and no scroll taking the finger away mid-hold. */
.wall-hold {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.wall-hold::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 0;
  background: var(--red-soft);
  z-index: -1;
  transition: none;
}

.wall-hold.holding::after {
  width: 100%;
  transition: width 2s linear;
}

@media (prefers-reduced-motion: reduce) {
  .wall-hold.holding::after { transition: none; }
}

.wall-hold.holding { border-color: var(--red); }

.wall-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0.75rem;
}

.wall-group-label {
  width: 100%;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-top: 0.75rem;
}

/* ---------- the report card sheet ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(10, 12, 16, 0.6);
  backdrop-filter: blur(8px);
  overflow-y: auto;
}

.sheet[hidden] { display: none; }

.sheet-box {
  width: 100%;
  max-width: 720px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
}

.sheet-box h2 { font-size: 1.2rem; margin-bottom: 0.4rem; }
.sheet-box p { font-size: 0.9rem; margin-bottom: 1rem; }

/* Inside the code sheet, because the page notice sits behind the scrim. */
.otp-status { font-weight: 600; color: var(--red); }
.otp-status[data-tone="grey"] { color: var(--text-2); font-weight: 500; }
.otp-status[hidden] { display: none; }

.sheet-box canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

/* ---------- today band on the overview ---------- */

.greeting {
  margin-bottom: 1.5rem;
}

.greeting h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.greeting p { font-size: 0.95rem; margin: 0; }

.mono { font-family: var(--mono); font-size: 0.85em; }

/* ---------- delete account ---------- */

.delete-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-2);
  font-size: 0.92rem;
  line-height: 1.55;
}

.delete-list li { margin-bottom: 0.45rem; }

.delete-subhead {
  font-size: 1rem;
  margin: 1.5rem 0 0.6rem;
}

/* ---------- strict session, inside the shell ---------- */

.page.focus-page { max-width: 820px; }

.focus-title { font-size: clamp(1.9rem, 4vw, 2.6rem); letter-spacing: -0.02em; }
.focus-title-sm { font-size: clamp(1.6rem, 3.5vw, 2.2rem); }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; background: none; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 1200;
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    box-shadow: none;
  }

  .shell.nav-open .sidebar {
    transform: none;
    box-shadow: var(--shadow-lg);
  }

  .scrim {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(10, 12, 16, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
  }

  .shell.nav-open ~ .scrim,
  .scrim.show {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-btn { display: inline-flex; }
  .panel-grid, .panel-grid.wide-left { grid-template-columns: 1fr; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .tiles { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .tile { padding: 0.9rem 1rem; }
  .figures { grid-template-columns: 1fr; }
  .page-head { margin-bottom: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .scrim { transition: none; }
}
