/* SpinStat shared styles: resident app, manager, admin and print pages. */

@font-face {
  font-family: "Archivo";
  src: url("/assets/fonts/archivo-latin.woff2") format("woff2-variations"),
       url("/assets/fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-style: normal;
  font-display: swap;
}

:root {
  --denim: #22406e;
  --enamel: #f2f5f6;
  --surface: #ffffff;
  --steel: #d4dbe0;
  --steel-strong: #9ba7af;
  --ink: #16202a;
  --muted: #59656f;

  --free: #239163;      --free-text: #16724b;  --free-soft: #e1f2e9;
  --busy: #e09a12;      --busy-text: #865300;  --busy-soft: #fbefd6;
  --ended: #7258d0;     --ended-text: #5640a9; --ended-soft: #ece8fa;
  --fault: #d23e33;     --fault-text: #ac2a20; --fault-soft: #fae5e3;
  --track: #e3e8eb;
  --glass: #f6f8f9;

  --accent: var(--denim);
  --accent-ink: #ffffff;
  --accent-text: var(--accent);

  --r-s: 8px;
  --r-m: 12px;
  --r-l: 18px;
  --gutter: 16px;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --enamel: #10161c;
    --surface: #18212a;
    --steel: #2b3742;
    --steel-strong: #566571;
    --ink: #e9eef2;
    --muted: #9eabb5;
    --free: #3fbf86;   --free-text: #7fdcb0;  --free-soft: #12301f;
    --busy: #f0ad2b;   --busy-text: #f6c869;  --busy-soft: #36290b;
    --ended: #9a85ef;  --ended-text: #c0b2ff;  --ended-soft: #251f42;
    --fault: #f0645a;  --fault-text: #ff9a91;  --fault-soft: #3a1714;
    --track: #2a3540;
    --glass: #121a21;
    --accent-text: color-mix(in srgb, var(--accent) 45%, #ffffff);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--enamel);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  font-stretch: 100%;
}
a { color: var(--accent-text); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, white); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.wrap { max-width: 640px; margin: 0 auto; padding: 14px var(--gutter) 56px; }
.wrap.wide { max-width: 980px; }

/* Display type: the wide cut of Archivo, like a machine's nameplate. */
.display { font-stretch: 125%; font-weight: 800; letter-spacing: -0.01em; line-height: 1.08; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }

/* Top bar */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 6px 0 16px; }
.top .where { min-width: 0; }
.top h1 { overflow-wrap: anywhere; }
.top .addr { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.btn-quiet {
  border: 1px solid var(--steel); background: var(--surface); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn-quiet:hover { border-color: var(--steel-strong); }

/* Summary line */
.summary { display: flex; gap: 24px; align-items: baseline; padding: 4px 0 14px; border-bottom: 1px solid var(--steel); margin-bottom: 14px; flex-wrap: wrap; }
.summary .n { font-stretch: 112%; font-weight: 800; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; color: var(--accent-text); }
.summary .n.zero { color: var(--muted); }
.summary .l { color: var(--muted); font-size: 15px; margin-left: 6px; }
.updated { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

.row-label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; margin: 0 0 14px; }
select, input[type=text], input[type=number], input[type=email], input[type=password], textarea {
  background: var(--surface); border: 1px solid var(--steel); border-radius: var(--r-s);
  padding: 9px 11px; color: var(--ink); max-width: 100%;
}
textarea { width: 100%; min-height: 70px; resize: vertical; }
input[type=number] { width: 96px; }

/* Laundry rooms */
.rooms { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.room { background: var(--surface); border: 1px solid var(--steel); border-radius: var(--r-l); padding: 12px 12px 14px; }
.room-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 2px 4px 10px; }
.room-head h2 { font-size: 17px; font-stretch: 110%; font-weight: 750; }
.room-head .dist { color: var(--muted); font-size: 13px; }
.machines { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }

/* Machine tile: a row of doors, like the laundry room itself */
.tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  width: 100%; padding: 14px 8px 12px; border-radius: var(--r-m);
  border: 1px solid transparent; background: var(--enamel); cursor: pointer; color: var(--ink);
}
.tile:hover { border-color: var(--steel); }
.tile .port { width: 76px; }
.tile .txt { display: block; }
.tile .kind { display: block; font-weight: 650; font-size: 15px; line-height: 1.2; }
.tile .st { display: block; font-size: 14px; line-height: 1.3; font-variant-numeric: tabular-nums; font-weight: 600; }
.tile .sub {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 13px; color: var(--muted); line-height: 1.3; margin-top: 1px; font-variant-numeric: tabular-nums;
}
.tile .flag { color: var(--fault-text); }
.s-free .st { color: var(--free-text); }
.s-busy .st { color: var(--busy-text); }
.s-ended .st { color: var(--ended-text); }
.s-out .st { color: var(--fault-text); }

/* The porthole */
.port { display: block; width: 100%; height: auto; overflow: visible; }
.port .bezel { fill: var(--surface); stroke: var(--steel); stroke-width: 1.5; }
.port .track { fill: none; stroke: var(--track); stroke-width: 5; }
.port .arc { fill: none; stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset 0.6s ease; }
.port .glass { stroke: none; }
.port .num { font: 800 15px var(--font); font-stretch: 110%; text-anchor: middle; dominant-baseline: central; font-variant-numeric: tabular-nums; }
.port .word { font: 700 9.5px var(--font); text-anchor: middle; dominant-baseline: central; }
.port .ico { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.port .dot { stroke: var(--surface); stroke-width: 2; }
.p-free .arc { stroke: var(--free); }   .p-free .glass { fill: var(--free-soft); }   .p-free .ico { stroke: var(--free); }
.p-busy .arc { stroke: var(--busy); }   .p-busy .glass { fill: var(--busy-soft); }   .p-busy .num { fill: var(--busy-text); }
.p-ended .arc { stroke: var(--ended); } .p-ended .glass { fill: var(--ended-soft); } .p-ended .word { fill: var(--ended-text); }
.p-out .arc { stroke: var(--fault); }   .p-out .glass { fill: var(--fault-soft); }   .p-out .ico { stroke: var(--fault); }
.p-free .arc, .p-ended .arc, .p-out .arc { stroke-dasharray: none; }
.port .dot { fill: var(--fault); }

/* Machine page */
.back { display: inline-block; border: 0; background: none; color: var(--accent-text); padding: 4px 0; margin: 0 0 10px; cursor: pointer; font-size: 15px; text-decoration: none; }
.machine-hero { display: grid; grid-template-columns: 148px 1fr; gap: 18px; align-items: center; margin: 4px 0 18px; }
.machine-hero .room-name { color: var(--muted); font-size: 15px; margin: 0 0 2px; }
.machine-hero h1 { font-size: 30px; }
.machine-hero .big-st { font-size: 18px; font-weight: 650; margin: 8px 0 0; font-variant-numeric: tabular-nums; }
.machine-hero .big-sub { color: var(--muted); font-size: 15px; margin: 2px 0 0; }
@media (max-width: 380px) { .machine-hero { grid-template-columns: 116px 1fr; gap: 14px; } .machine-hero h1 { font-size: 26px; } }

.notice { border-radius: var(--r-m); padding: 12px 14px; margin: 0 0 16px; font-size: 15px; }
.notice b { display: block; }
.notice.fault { background: var(--fault-soft); color: var(--fault-text); }
.notice.warn { background: var(--busy-soft); color: var(--busy-text); }
.notice.ok { background: var(--free-soft); color: var(--free-text); }

.panel { background: var(--surface); border: 1px solid var(--steel); border-radius: var(--r-l); padding: 16px; margin: 0 0 12px; }
.panel h2 { font-size: 18px; margin: 0 0 4px; }
.panel .note { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 10px; }
.preset {
  border: 1px solid var(--steel); background: var(--surface); border-radius: var(--r-s);
  padding: 12px 2px; cursor: pointer; font-weight: 650; font-variant-numeric: tabular-nums;
}
.preset[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.custom { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin: 0 0 12px; }

.btn {
  display: block; width: 100%; text-align: center; text-decoration: none; cursor: pointer;
  border: 1px solid var(--steel); background: var(--surface); color: var(--ink);
  border-radius: var(--r-m); padding: 13px 14px; font-weight: 650; margin: 0 0 8px;
}
.btn:hover { border-color: var(--steel-strong); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--fault-text); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.inline { display: inline-block; width: auto; padding: 9px 14px; margin: 0; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

details.more { margin: 12px 0 0; border-top: 1px solid var(--steel); padding-top: 12px; }
details.more.quiet { border-top: 0; margin: 18px 4px 0; padding-top: 0; }
.is-machine .top h1 { font-size: 20px; font-stretch: 115%; }
.is-machine .top .addr { display: none; }
#v-machine + .updated { margin-top: 22px; }
details.more summary { cursor: pointer; color: var(--accent-text); font-size: 15px; }
details.more[open] summary { margin-bottom: 10px; }

.foot { margin: 26px 0 0; color: var(--muted); font-size: 13px; }
.foot a { color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 24px); opacity: 0;
  transition: opacity 0.2s, transform 0.2s; background: var(--ink); color: var(--enamel);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: calc(100% - 32px); pointer-events: none; z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { text-align: left; padding: 30px 0; }
.empty h1 { margin: 0 0 8px; }

/* Tables (manager, admin) */
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th, .tbl td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--steel); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 600; font-size: 13px; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.scroll-x { overflow-x: auto; }

/* Status pill (manager/admin lists) */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.s-free { background: var(--free-soft); color: var(--free-text); }
.pill.s-busy { background: var(--busy-soft); color: var(--busy-text); }
.pill.s-ended { background: var(--ended-soft); color: var(--ended-text); }
.pill.s-out { background: var(--fault-soft); color: var(--fault-text); }

/* Brand mark */
.brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 800; font-stretch: 118%; font-size: 18px; }
.brand svg { width: 26px; height: 26px; }
