/* Quotach: shared styles for the admin dashboard and the personal usage page.
   Everything is served by Quotach itself (the font too): people who are cut off can only
   reach this server, so nothing may come from a CDN. Light only, deliberately plain:
   black and grays, with colour reserved for the few things that need attention. */

@font-face {
  font-family: "Inter";
  src: url("/static/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #111111;
  --ink-2: #6b6b6b;
  --ink-3: #a1a1a1;
  --line: #ebebeb;
  --fill: #f5f5f5;
  --fill-2: #ececec;
  --red: #d92d20;
  --amber: #b54708;
  --green: #17b26a;
  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  font-feature-settings: "cv11", "ss03";
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
button, input { font: inherit; color: inherit; }
a { color: inherit; }
code { font-family: var(--mono); font-size: 0.86em; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: 0.86em; }
.muted { color: var(--ink-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.warn { color: var(--amber); }
.bad { color: var(--red); }

/* ------------------------------------------------------------------ layout */
.wrap { max-width: 640px; margin: 0 auto; padding: 0 20px calc(64px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: max(12px, env(safe-area-inset-top)) 0 8px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.brand svg { display: block; flex: none; }
.section { margin-top: 36px; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

.banner { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: #fef3f2; color: var(--red); font-size: 14px; }
.banner svg { flex: none; margin-top: 2px; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 16px; border: 0; border-radius: 12px;
  background: var(--fill); color: var(--ink); font-size: 15px; font-weight: 600;
  text-decoration: none; white-space: nowrap; cursor: pointer; transition: background 0.15s, opacity 0.15s;
}
.btn:hover { background: var(--fill-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn svg { flex: none; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #333; }
.btn.danger { background: transparent; color: var(--red); }
.btn.danger:hover { background: #fef3f2; }
.btn.danger-solid { background: var(--red); color: #fff; }
.btn.danger-solid:hover { background: #b42318; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--fill); color: var(--ink); }
.icon-btn.danger:hover { color: var(--red); background: #fef3f2; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 36px; padding: 0 13px; border: 1px solid var(--line); border-radius: 99px; background: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.chip:hover { background: var(--fill); }
.chip:disabled { opacity: 0.5; }
.chip.end { color: var(--red); }

/* ------------------------------------------------------------------ summary */
.summary { padding-top: 20px; }
.label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.big { margin-top: 2px; font-size: 44px; font-weight: 650; line-height: 1.1; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.big .unit { margin-left: 4px; font-size: 22px; font-weight: 550; letter-spacing: -0.01em; color: var(--ink-2); }
.sub { margin-top: 4px; font-size: 14px; color: var(--ink-2); }
.chart { display: flex; align-items: flex-end; gap: 2px; height: 44px; margin-top: 22px; }
.chart .bar { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.chart .bar i { display: block; width: 100%; min-height: 2px; border-radius: 2px; background: #dcdcdc; }
.chart .bar:hover i { background: #b8b8b8; }
.chart .bar.today i { background: var(--ink); }
.chart .bar.future i { height: 2px !important; background: #f0f0f0; }
.chart-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart-foot .readout { color: var(--ink-2); }
.counts { margin-top: 18px; font-size: 14px; color: var(--ink-2); }
.counts strong { color: var(--ink); font-weight: 600; }
.counts .bad, .counts .bad strong { color: var(--red); }
.plan-line { margin-top: 16px; }
.plan-line .row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 13px; color: var(--ink-2); }

.actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 24px; }

/* ------------------------------------------------------------------ list */
.list { list-style: none; padding: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.row-btn {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 12px; width: 100%;
  padding: 14px 16px; border: 0; background: none; text-align: left; cursor: pointer;
}
.row-btn:hover { background: #fafafa; }
.row-btn:focus-visible { outline-offset: -2px; }
.row-main { min-width: 0; }
.name { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 16px; font-weight: 600; }
.name > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { flex: none; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.tag.warn { color: var(--amber); }
.tag.bad { color: var(--red); }
.meta { display: flex; align-items: center; gap: 6px; margin-top: 1px; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #d4d4d4; }
.dot.on { background: var(--green); }
.row-side { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-side strong { display: block; font-size: 15px; font-weight: 600; }
.row-side > span { display: block; font-size: 13px; color: var(--ink-3); }
.soon .row-side strong { color: var(--red); }
.row-btn .track { grid-column: 1 / -1; margin-top: 10px; }

.track { height: 4px; border-radius: 99px; background: #efefef; overflow: hidden; }
.track > span { display: block; height: 100%; border-radius: inherit; background: var(--ink); transition: width 0.6s var(--ease); }
.track.warning > span { background: #f5a524; }
.track.blocked > span, .track.throttled > span { background: var(--red); }
.track.paused > span, .track.expired > span { background: #c4c4c4; }
.track.time > span { transition: width 1s linear; }
.soon .track.time > span { background: var(--red); }

/* Expanded person */
.detail { padding: 0 16px 16px; }
.detail-section { padding-top: 14px; border-top: 1px solid var(--line); }
.detail-section + .detail-section { margin-top: 14px; }
.detail-label { margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.time-now { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.time-now strong { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.soon .time-now strong { color: var(--red); }
.time-now > span { font-size: 14px; color: var(--ink-2); }
.devices { list-style: none; padding: 0; }
.devices li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.dev-info { flex: 1; min-width: 0; }
.dev-name { display: block; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dev-meta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; }
@media (max-width: 560px) { .dev-meta .ip { display: none; } }
.dev-used { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dev-actions { display: flex; margin-right: -8px; }
.note-line { font-size: 14px; color: var(--ink-2); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 14px; color: var(--ink-2); }
.kv strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.kv small { margin-left: 6px; font-size: 13px; font-weight: 500; color: var(--ink-3); }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.detail-actions .btn { min-height: 42px; font-size: 14.5px; }

.empty { padding: 28px 20px; text-align: center; color: var(--ink-2); font-size: 14px; }
.empty strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: 15px; }

.settings-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border: 0; background: none; text-align: left; cursor: pointer; }
.settings-row:hover { background: #fafafa; }
.settings-row .s-text { flex: 1; min-width: 0; }
.settings-row .s-title { display: block; font-weight: 600; }
.settings-row .s-sub { display: block; font-size: 13.5px; color: var(--ink-2); }
.chev { flex: none; color: var(--ink-3); }

.foot { margin-top: 28px; font-size: 12.5px; color: var(--ink-3); text-align: center; line-height: 1.8; }
.foot span { white-space: nowrap; }

/* ------------------------------------------------------------------ dialogs (bottom sheet on phones) */
dialog {
  width: min(480px, calc(100vw - 32px)); max-width: none; max-height: min(88vh, 860px); padding: 0;
  border: 0; border-radius: 20px; background: #fff; color: var(--ink);
  box-shadow: 0 24px 64px -16px rgba(0, 0, 0, 0.25); overflow: auto; overscroll-behavior: contain;
}
dialog[open] { animation: pop 0.18s var(--ease); }
dialog::backdrop { background: rgba(0, 0, 0, 0.32); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 560px) {
  dialog { width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  dialog[open] { animation: sheet 0.24s var(--ease); }
  @keyframes sheet { from { transform: translateY(24%); } }
}
.dlg { padding: 24px 22px 22px; }
.dlg h2 { font-size: 20px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; }
.dlg .lead { margin-top: 4px; color: var(--ink-2); font-size: 14.5px; }
.dlg-actions { display: flex; gap: 8px; margin-top: 24px; }
.dlg-actions .btn { flex: 1; min-height: 48px; }
.dlg-actions .btn.danger { flex: 0 0 auto; }
.stack > * + * { margin-top: 18px; }

.field { display: block; }
.field-label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 600; }
.field-hint { display: block; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
input[type=text], input[type=number], input[type=password] {
  width: 100%; height: 46px; padding: 0 12px; border: 1px solid #e0e0e0; border-radius: 10px;
  background: #fff; font-size: 16px; transition: border-color 0.15s; -moz-appearance: textfield;
}
input::placeholder { color: var(--ink-3); }
input:focus { outline: none; border-color: var(--ink); }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-unit { position: relative; display: block; }
.input-unit input { padding-right: 56px; }
.input-unit > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: 14px; pointer-events: none; }
.input-unit.after { margin-top: 8px; }

.segmented { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 2px; padding: 3px; border-radius: 11px; background: var(--fill); }
.segmented.grid4 { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: flex; align-items: center; justify-content: center; min-height: 38px; padding: 2px 6px; border-radius: 8px;
  font-size: 14px; font-weight: 550; color: var(--ink-2); text-align: center; line-height: 1.2;
}
.segmented input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 0 0 0.5px rgba(0, 0, 0, 0.05); }
.segmented input:focus-visible + span { outline: 2px solid var(--ink); }
.custom-on .segmented input:checked + span { background: transparent; box-shadow: none; color: var(--ink-2); }

.radio-list { display: grid; gap: 2px; }
.radio-list label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.radio-list input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--ink); }
.radio-list strong { display: block; font-size: 15px; font-weight: 600; }
.radio-list small { display: block; font-size: 13px; color: var(--ink-2); }

.form-error { color: var(--red); font-size: 14px; }
.form-error:empty { display: none; }
.more summary { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; list-style: none; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.more summary::-webkit-details-marker { display: none; }
.more[open] summary .chev { transform: rotate(180deg); }
.more .stack { margin-top: 14px; }

/* Settings form */
.group-title { margin: 22px 0 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.setting { display: grid; grid-template-columns: 1fr 132px; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.s-label { font-weight: 550; font-size: 15px; }
.s-hint { display: block; font-size: 13px; font-weight: 400; color: var(--ink-2); }
.setting input { height: 42px; }
.setting.static { align-items: start; }
.s-value { padding-top: 2px; text-align: right; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.s-value.muted, .s-value.mono { font-weight: 500; }
.setting-block { padding: 10px 0 4px; border-bottom: 1px solid var(--line); }
.setting-block .radio-list { margin-top: 6px; }

/* Setup steps */
.time-line { margin-top: 14px; font-size: 14.5px; color: var(--ink-2); }
.time-line strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.time-line.soon strong { color: var(--red); }
.steps { list-style: none; padding: 0; margin-top: 20px; counter-reset: step; display: grid; gap: 16px; }
.steps > li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; counter-increment: step; }
.steps > li > span { min-width: 0; }
.steps > li::before {
  content: counter(step); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid #d6d6d6; font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.steps .step-title { display: block; font-size: 15px; font-weight: 600; }
.steps p { margin-top: 1px; font-size: 14px; color: var(--ink-2); }
.steps p strong { color: var(--ink); font-weight: 600; }
.qr-frame { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; display: grid; place-items: center; }
.qr-frame img { display: block; width: min(240px, 64vw); height: auto; aspect-ratio: 1; image-rendering: pixelated; }
.steps p + p { margin-top: 6px; }
.file-btn { width: 100%; margin: 10px 0 8px; white-space: normal; text-align: center; }
.small-print { margin-top: 18px; font-size: 13px; color: var(--ink-2); }
.small-print:empty { display: none; }
.small-print + .small-print { margin-top: 8px; }
.small-print strong { color: var(--ink); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50;
  width: max-content; max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 12px;
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 500;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; transition: transform 0.2s var(--ease), opacity 0.2s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ------------------------------------------------------------------ personal page */
.me-wrap { max-width: 440px; }
.hello { padding-top: 20px; }
.hello h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.025em; line-height: 1.2; }
.hello p { margin-top: 2px; font-size: 15px; color: var(--ink-2); }
.ring { position: relative; width: min(220px, 62vw); margin: 32px auto 0; aspect-ratio: 1; }
.ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .bg { stroke: #f0f0f0; }
.ring .fg { stroke: var(--ink); transition: stroke-dashoffset 0.8s var(--ease); }
.ring.warning .fg { stroke: #f5a524; }
.ring.blocked .fg, .ring.throttled .fg, .ring.soon .fg { stroke: var(--red); }
.ring.paused .fg, .ring.expired .fg, .ring.unlimited .fg { stroke: #cfcfcf; }
.ring.time .fg { transition: stroke-dashoffset 1s linear; }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-num { font-size: 42px; font-weight: 650; line-height: 1; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.ring-num .unit { margin-left: 3px; font-size: 18px; font-weight: 550; color: var(--ink-2); }
.ring.soon .ring-num { color: var(--red); }
.ring.over .ring-num { color: var(--ink-3); }
.ring-sub { margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.message { margin: 24px auto 0; max-width: 340px; text-align: center; font-size: 15px; color: var(--ink-2); }
.message.bad { color: var(--red); }
.message.warn { color: var(--amber); }
.facts { margin-top: 28px; border-top: 1px solid var(--line); }
.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.facts dt { color: var(--ink-2); }
.facts dd { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.here { margin-left: 6px; font-size: 13px; font-weight: 500; color: var(--ink-3); }
.me-foot { margin-top: 24px; text-align: center; font-size: 13px; color: var(--ink-3); }
.offline { display: grid; justify-items: center; gap: 6px; padding: 64px 12px; text-align: center; color: var(--ink-2); }
.offline h2 { font-size: 18px; font-weight: 650; color: var(--ink); }
.offline svg { color: var(--ink-3); margin-bottom: 6px; }

/* ------------------------------------------------------------------ join page */
.btn.wide { width: 100%; min-height: 50px; }
.btn.quiet { background: transparent; color: var(--ink-2); font-weight: 500; }
.btn.quiet:hover { background: var(--fill); color: var(--ink); }
.join-form { margin-top: 28px; }
.join-form .btn.wide { margin-top: 4px; }
.invite-name { font-size: 15px; color: var(--ink-2); }
.invite-name strong { color: var(--ink); }
.setting-up { margin-top: 24px; }
.wait { display: flex; gap: 12px; align-items: center; margin-top: 28px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; font-size: 14.5px; color: var(--ink-2); }
.spinner { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #e2e2e2; border-top-color: var(--ink); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.prep { margin-top: 24px; }
.prep .file-btn { margin-top: 0; }
.wait + .prep + .btn.wide, .wait + .btn.wide { margin-top: 20px; }
.file-form { margin: 0; }
.qr-wait { display: grid; place-items: center; width: min(240px, 64vw); aspect-ratio: 1; font-size: 13px; color: var(--ink-3); text-align: center; }
.link-box { display: flex; gap: 8px; align-items: center; margin: 10px 0; padding: 6px 6px 6px 12px; border: 1px solid var(--line); border-radius: 12px; }
.link-box code { flex: 1; min-width: 0; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-box .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }

/* "Add a device" on the personal page */
.add-device { margin-top: 28px; }
.add-device .stack { margin-top: 14px; }

/* ------------------------------------------------------------------ join requests on the dashboard */
.requests { display: grid; gap: 8px; margin-top: 12px; }
.request { padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: #fafafa; }
.request .r-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.request .r-name { font-size: 16px; font-weight: 600; }
.request .r-when { flex: none; font-size: 13px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.request .r-meta { margin-top: 2px; font-size: 13.5px; color: var(--ink-2); }
.request .r-meta .warn { color: var(--amber); }
.request .r-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.request .r-actions .btn { min-height: 38px; padding: 0 14px; font-size: 14px; }
.request .r-guest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.request .r-guest span { font-size: 13px; color: var(--ink-2); margin-right: 4px; }
.request .r-guest .chip { height: 34px; font-size: 13.5px; }
.actions-row.three { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.actions-row.three .btn { padding: 0 8px; font-size: 14px; }
.share-link { display: flex; gap: 8px; margin-top: 16px; }
.share-link input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; }
