/* Loquela Remote: shared styles for the customer site and the owner dashboard. */

/* Atkinson Hyperlegible Next, variable weight, split like Google Fonts serves it. */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next-latin-ext.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope-variable.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #fffaf6;
  --surface: #ffffff;
  --surface-muted: #eef3f3;
  --ink: #1b2233;
  --ink-soft: #496a70;
  --line: #cdd9db;
  --line-strong: #93aab0;
  --orange: #ee7b4f;
  --orange-deep: #b84b25;
  --orange-wash: #fde8dc;
  --on-primary: #ffffff;
  --ok: #2f7d4f;
  --ok-wash: #e1f1e7;
  --warn: #9a6400;
  --warn-wash: #fbefd6;
  --bad: #b3261e;
  --bad-wash: #f9dedc;
  --chart: #d9653a;
  --radius: 2px;
  --cut: 14px;
  --font-sans: "Atkinson Hyperlegible Next", Verdana, Arial, sans-serif;
  --font-display: "Manrope", "Atkinson Hyperlegible Next", Verdana, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f141d;
    --surface: #171e2a;
    --surface-muted: #131c27;
    --ink: #edf2f7;
    --ink-soft: #abc2c7;
    --line: #2a3644;
    --line-strong: #536575;
    --orange: #f08a60;
    --orange-deep: #ffad86;
    --orange-wash: #3a241b;
    --on-primary: #1b2233;
    --ok: #6cc391;
    --ok-wash: #16301f;
    --warn: #e3b25a;
    --warn-wash: #33280f;
    --bad: #f2948d;
    --bad-wash: #3a1a18;
    --chart: #dc7045;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141d;
  --surface: #171e2a;
  --surface-muted: #131c27;
  --ink: #edf2f7;
  --ink-soft: #abc2c7;
  --line: #2a3644;
  --line-strong: #536575;
  --orange: #f08a60;
  --orange-deep: #ffad86;
  --orange-wash: #3a241b;
  --on-primary: #1b2233;
  --ok: #6cc391;
  --ok-wash: #16301f;
  --warn: #e3b25a;
  --warn-wash: #33280f;
  --bad: #f2948d;
  --bad-wash: #3a1a18;
  --chart: #dc7045;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
}

a { color: var(--orange-deep); text-underline-offset: 3px; }
a:hover { color: var(--orange); }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); font-weight: 800; }
h2 { font-size: 1.35rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }

code, kbd, pre, .mono { font-family: var(--font-mono); font-size: 0.92em; }
pre {
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius);
  padding: 12px 14px;
  overflow-x: auto;
  line-height: 1.45;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Level-meter motif: thin vertical bars, like a voice meter, under headers. */
.meter {
  height: 10px;
  background:
    repeating-linear-gradient(90deg, var(--orange) 0 3px, transparent 3px 9px) 0 100% / 100% 40% no-repeat,
    repeating-linear-gradient(90deg, var(--line-strong) 0 3px, transparent 3px 9px) 0 100% / 100% 100% no-repeat;
  opacity: 0.55;
  -webkit-mask: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
  mask: linear-gradient(90deg, transparent, #000 15%, #000 85%, transparent);
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 60px;
  flex-wrap: wrap;
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.brand .tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orange-deep);
  border: 1px solid var(--orange);
  padding: 1px 6px;
  border-radius: var(--radius);
}

.nav { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-left: auto; }
.nav a { color: var(--ink-soft); text-decoration: none; font-weight: 700; font-size: 0.95rem; padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--orange); }

/* Theme switch (static/theme.js): a quiet control beside the links, not another button-looking box. */
.theme { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 2px; border: 0; background: none; color: var(--ink-soft); font: inherit; font-weight: 700; font-size: 0.95rem; cursor: pointer; }
.theme:hover { color: var(--ink); }
.theme:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
.theme svg { width: 16px; height: 16px; flex: none; }

main { padding: 28px 0 56px; }

/* Panels: solid border, cut top-right corner. */
.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
}

.panel::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: calc(var(--cut) * 1.42);
  height: 1px;
  background: var(--line-strong);
  transform: rotate(45deg);
  transform-origin: 0 0;
  translate: calc(-1 * var(--cut)) 0;
}

.panel.accent { border-top: 3px solid var(--orange); }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-soft);
  font-weight: 700;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-note { font-size: 0.85rem; color: var(--ink-soft); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.kv dt { color: var(--ink-soft); font-size: 0.9rem; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
}

.state-ok { color: var(--ok); background: var(--ok-wash); }
.state-warn { color: var(--warn); background: var(--warn-wash); }
.state-bad { color: var(--bad); background: var(--bad-wash); }

.bar { height: 8px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--orange); }

table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); background: var(--surface-muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.table-scroll table th:first-child, .table-scroll table td:first-child { padding-left: 14px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  min-height: 40px;
}

.btn:hover { background: var(--surface-muted); color: var(--ink); }
.btn.primary { background: var(--orange-deep); border-color: var(--orange-deep); color: var(--on-primary); }
.btn.primary:hover { background: var(--orange); border-color: var(--orange); color: #1b2233; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 0.85rem; }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline { display: inline; }

label { display: block; font-weight: 700; font-size: 0.9rem; margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="number"], input[type="search"], input[type="date"], input[type="password"], select {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  min-height: 40px;
}
input[type="file"] { font: inherit; width: 100%; padding: 8px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
input[type="file"]::file-selector-button { font: inherit; font-weight: 700; margin-right: 10px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-muted); color: var(--ink); cursor: pointer; }

.field { margin-bottom: 12px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }

.notice {
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--orange);
  background: var(--orange-wash);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.notice.ok { border-left-color: var(--ok); background: var(--ok-wash); }
.notice.bad { border-left-color: var(--bad); background: var(--bad-wash); }

.secret {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 10px 12px;
  border: 1px dashed var(--orange-deep);
  background: var(--surface-muted);
  overflow-wrap: anywhere;
  user-select: all;
}

.muted { color: var(--ink-soft); }
.small { font-size: 0.86rem; }
.section { margin-top: 28px; }

footer.site {
  border-top: 1px solid var(--line);
  padding: 24px 0 40px;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

footer.site .wrap { display: flex; gap: 20px; flex-wrap: wrap; justify-content: space-between; }

@media (max-width: 600px) {
  .panel { padding: 14px 14px; }
  .stat-value { font-size: 1.4rem; }
  .nav { margin-left: 0; width: 100%; }
}

/* ---- Owner dashboard ------------------------------------------------------------------------ */

.page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.live { font-size: 0.85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.live.lost { color: var(--bad); font-weight: 700; }
main.stale [data-k], main.stale .tiles { opacity: 0.45; }

/* Status tiles: the left edge carries the state, the pill repeats it in words. */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: 92px;
}
.tile[data-state="ok"] { border-left-color: var(--ok); }
.tile[data-state="warn"] { border-left-color: var(--warn); }
.tile[data-state="bad"] { border-left-color: var(--bad); }
.tile .stat-label { margin-bottom: 6px; }
.tile .stat-note { margin-top: 6px; overflow-wrap: anywhere; }

.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 7.5rem 5.5rem 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* Settings sections: a quiet in-page index. */
.subnav { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.subnav a { color: var(--ink-soft); text-decoration: none; font-weight: 700; font-size: 0.9rem; }
.subnav a:hover { color: var(--ink); }
.settings-section { scroll-margin-top: 16px; }
.settings-section + .settings-section { margin-top: 32px; }
.settings-section > h2 { display: flex; align-items: center; gap: 10px; }
.settings-section > h2::before { content: ""; width: 10px; height: 10px; background: var(--orange); clip-path: polygon(0 0, 100% 0, 100% 100%); }

.choice { display: flex; flex-wrap: wrap; gap: 8px; }
.choice label { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; cursor: pointer; }
.choice label:has(input:checked) { border-color: var(--orange-deep); background: var(--orange-wash); font-weight: 700; }
textarea { width: 100%; min-height: 64px; font: inherit; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); }

/* Filters sit in one row above the table. */
.filters { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; margin-bottom: 14px; }
.filters .field { margin: 0; }
.inline-check { display: flex; align-items: center; gap: 8px; font-weight: 400; min-height: 40px; margin: 0; }
.filters .field.wide { grid-column: span 2; }
@media (max-width: 400px) { .filters .field.wide { grid-column: auto; } }
.filters input, .filters select, .filters .btn { height: 40px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; font-size: 0.9rem; }

td a.row-link { font-weight: 700; text-decoration: none; }
td a.row-link:hover { text-decoration: underline; }

details.disclosure > summary { cursor: pointer; font-weight: 700; list-style: none; }
details.disclosure > summary::before { content: "+ "; color: var(--orange-deep); }
details.disclosure[open] > summary::before { content: "- "; }
details.disclosure[open] > summary { margin-bottom: 12px; }

.danger-zone { border: 1px solid var(--bad); border-radius: var(--radius); padding: 14px 16px; }
.danger-zone h2 { color: var(--bad); }

/* Usage columns: one bar per day, square at the baseline, rounded at the value end. */
.columns { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 2px; height: 140px; padding-top: 18px; border-bottom: 1px solid var(--line-strong); }
.columns .col { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; outline: none; }
.columns .col > .col-bar { display: block; width: 100%; max-width: 24px; min-height: 1px; background: var(--chart); border-radius: 4px 4px 0 0; }
.columns .col.zero > .col-bar { background: var(--line); }
.columns .col:hover > .col-bar, .columns .col:focus-visible > .col-bar { filter: brightness(1.12); }
.columns .col .tip { display: none; position: absolute; bottom: calc(100% + 4px); left: 50%; translate: -50% 0; white-space: nowrap; background: var(--ink); color: var(--bg); font-size: 0.8rem; padding: 4px 8px; border-radius: var(--radius); z-index: 2; pointer-events: none; }
.columns .col:hover .tip, .columns .col:focus-visible .tip { display: block; }
.columns .col.start .tip { left: 0; translate: none; }
.columns .col.end .tip { left: auto; right: 0; translate: none; }
.columns .peak { position: absolute; top: -17px; white-space: nowrap; font-size: 0.78rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.columns .col.start .peak { left: 0; }
.columns .col.end .peak { right: 0; }
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.columns-axis { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--ink-soft); margin-top: 4px; }

@media (max-width: 600px) {
  .events li { grid-template-columns: 1fr; gap: 2px; }
}

/* Phones: wide tables marked .stack become labelled rows, and controls are big enough to tap. */
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr { display: block; width: 100%; }
  table.stack tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td, .table-scroll table.stack td:first-child { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  table.stack td::before { content: attr(data-label); flex: none; font-weight: 700; font-size: 0.85rem; color: var(--ink-soft); text-align: left; }
  table.stack td:not([data-label]) { justify-content: flex-end; padding-top: 8px; }
  table.stack td:not([data-label])::before { content: none; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; }
  input[type="text"], input[type="email"], input[type="number"], input[type="search"], input[type="date"], input[type="password"], select { min-height: 44px; }
}
