/* RTSS V3. Light theme, same card language as Parcelsun. */
:root {
  --bg: #f4f1ea;
  --panel: #ffffff;
  --ink: #111111;
  --muted: #5d5850;
  --line: #111111;
  --soft: #e7e2d8;
  --accent: #b84e06;
  --accent-soft: #fdeede;
  --blue: #2f6fa8;
  --hot: #c8102e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; line-height: 1.35; }
[hidden] { display: none !important; }

header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--panel); border-bottom: 2px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: 0.14em; font-weight: 800; }
.badge { border: 2px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 11px; font-weight: 800; background: #f6a04d; }
.sub { flex: 1; min-width: 0; text-align: center; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#status { font-size: 11px; font-weight: 700; color: var(--muted); text-align: right; min-width: 76px; }
#status[data-kind="ok"] { color: #1d6b3a; }
#status[data-kind="warn"], #status[data-kind="busy"] { color: var(--accent); }
#status[data-kind="err"] { color: var(--hot); }

button, select, input, textarea, .btn {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--panel);
  border: 2px solid var(--line); border-radius: 6px; padding: 8px 10px; min-height: 40px;
}
button, .btn { font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-align: center; }
button:active, .btn:active { background: var(--soft); }
button.primary { background: var(--accent); color: #fff; }
button.danger { color: var(--hot); border-color: var(--hot); }
button.wide { width: 100%; }
textarea { width: 100%; resize: vertical; }
input[type=range] { width: 100%; padding: 0; border: 0; min-height: 34px; accent-color: var(--accent); background: transparent; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; padding: 0; accent-color: var(--accent); flex: none; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 1px; }

#sitebar, #newForm { display: flex; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 2px solid var(--line); }
#sitebar select, #newForm input { flex: 1; min-width: 0; }
#tabs { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; background: var(--bg); border-bottom: 2px solid var(--line); position: sticky; top: 0; z-index: 6; }
#tabs button { flex: none; min-height: 36px; padding: 6px 12px; }
#tabs button.on { background: var(--ink); color: #fff; }

main { max-width: 760px; margin: 0 auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
footer { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0 24px; }
.card { background: var(--panel); border: 2px solid var(--line); border-radius: 8px; padding: 10px; }
.card.center { text-align: center; }
.card h2 { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; text-align: center; }
.card.drop > h2 { cursor: pointer; margin: -10px; padding: 14px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; user-select: none; }
.card.drop > h2 > span:first-child { flex: 1; }
.card.drop > h2::after { content: '\25BE'; color: var(--accent); font-size: 18px; line-height: 1; }
.card.drop.open > h2::after { content: '\25B4'; }
.card.drop.open > h2 { margin-bottom: 0; }
.card.drop:not(.open) > .drop-body { display: none; }
.drop-body { display: flex; flex-direction: column; gap: 10px; }
.tag { font-size: 10px; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); text-transform: none; white-space: nowrap; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.progress { height: 10px; border: 2px solid var(--line); border-radius: 6px; background: var(--panel); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
@media (max-width: 420px) { .grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.field > span b { color: var(--ink); font-size: 13px; }
.field select, .field input { width: 100%; }
.full, .subhead { grid-column: 1 / -1; }
.subhead { font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; text-align: center; border-top: 2px solid var(--line); padding-top: 10px; margin-top: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; min-height: 32px; }
.toggle, .counter { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 2px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.toggle span, .counter span { display: flex; flex-direction: column; }
.toggle small, .counter small, .mat small, .drop-row small, .trow small { font-size: 11px; color: var(--muted); font-weight: 400; display: block; }
.counter div { display: flex; align-items: center; gap: 10px; }
.counter div b { min-width: 24px; text-align: center; font-size: 17px; }
.counter button { width: 40px; padding: 0; font-size: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 34px; padding: 4px 10px; font-weight: 600; }
.chips button.on { background: var(--accent); color: #fff; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { border: 2px solid var(--line); border-radius: 6px; }
.item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px; font-weight: 800; font-size: 13px; cursor: pointer; background: var(--accent-soft); border-radius: 4px; }
.item-head i::after { content: '\25BE'; font-style: normal; color: var(--accent); }
.item.open .item-head i::after { content: '\25B4'; }
.item-body { display: none; padding: 10px; flex-direction: column; gap: 10px; }
.item.open .item-body { display: flex; }
.add { border-style: dashed; width: 100%; }
.addbar { display: flex; gap: 8px; }
.addbar select, .addbar input { flex: 1; min-width: 0; }

.readouts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
@media (max-width: 460px) { .readouts { grid-template-columns: 1fr; } }
.ro { border: 2px solid var(--line); border-radius: 6px; padding: 6px 8px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ro b { font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.ro span { font-size: 14px; font-weight: 800; text-align: right; }
.ro.alarm { background: #fde3e6; }
.ro.warn { background: #fff3c4; }

/* drive-thru */
#view { position: relative; height: 46vh; min-height: 280px; padding: 0; overflow: hidden; touch-action: none; }
#view canvas { display: block; width: 100%; height: 100%; }
#view > .hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; text-align: center; }
.hud { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; z-index: 2; }
.hud span { background: rgba(255,255,255,0.92); border: 2px solid var(--line); border-radius: 5px; padding: 2px 6px; font-size: 11px; font-weight: 700; }
.viewbar { position: absolute; bottom: 8px; left: 8px; right: 8px; display: flex; justify-content: center; gap: 8px; z-index: 2; }
.viewbar button, .viewbar label { min-height: 34px; background: rgba(255,255,255,0.94); border: 2px solid var(--line); border-radius: 5px; padding: 3px 10px; font-size: 12px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.timebar { display: grid; grid-template-columns: 1.4fr 0.7fr 1fr; gap: 8px; align-items: center; margin-bottom: 8px; }
.timebar > * { width: 100%; }
.clock { text-align: center; font-size: 22px; font-weight: 800; letter-spacing: 0.04em; margin: 2px 0 4px; }
.table { display: flex; flex-direction: column; }
.trow { display: grid; grid-template-columns: 1.5fr 0.7fr 1.2fr 0.9fr; gap: 6px; padding: 7px 4px; border-top: 1px solid var(--soft); font-size: 13px; font-weight: 700; }
.trow.head { border-top: 0; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.trow.warn { background: #fff3c4; }
.photo, .shots { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.photo img { height: 84px; max-width: 150px; object-fit: cover; border: 2px solid var(--line); border-radius: 6px; }
.shot { display: flex; flex-direction: column; gap: 6px; width: calc(50% - 4px); }
.shot img { width: 100%; height: 110px; object-fit: cover; border: 2px solid var(--line); border-radius: 6px; }

/* topology */
.topo { display: flex; flex-direction: column; gap: 10px; }
.spine { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.spine .node { min-width: 170px; position: relative; }
.spine .node + .node::before { content: ''; position: absolute; left: 50%; top: -16px; height: 14px; border-left: 2px solid var(--line); }
.band { border: 2px solid var(--line); border-radius: 6px; padding: 8px; border-left-width: 8px; }
.band.wired { border-left-color: var(--accent); }
.band.wifi { border-left-color: var(--hot); border-style: dashed; border-left-style: solid; }
.band.tv { border-left-color: #7a4fa0; }
.band-title { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 6px; }
.band-nodes { display: flex; flex-wrap: wrap; gap: 6px; }
.node { border: 2px solid var(--line); border-radius: 5px; padding: 5px 8px; text-align: center; background: var(--accent-soft); }
.node.core { background: var(--ink); color: #fff; }
.node.wifi { background: #fde3e6; border-style: dashed; }
.node.tv { background: #efe6f7; }
.node b { display: block; font-size: 12px; }
.node small { font-size: 10px; opacity: 0.85; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; font-size: 11px; margin-top: 10px; }
.legend i { display: inline-block; width: 14px; height: 8px; border: 1px solid var(--line); vertical-align: middle; margin-right: 4px; }
.k-wired { background: var(--accent); } .k-wifi { background: var(--hot); } .k-tv { background: #7a4fa0; }

/* cabling and profile */
.drops { display: flex; flex-direction: column; margin-bottom: 10px; }
.drop-row { display: grid; grid-template-columns: 1fr 84px; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--soft); font-weight: 700; font-size: 13px; }
.drop-row.head { border-top: 0; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.drop-row input { width: 100%; text-align: center; }
.mats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
@media (max-width: 460px) { .mats { grid-template-columns: 1fr; } }
.mat { display: flex; gap: 10px; align-items: center; border: 2px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 13px; font-weight: 700; }
.mat b { font-size: 20px; min-width: 34px; text-align: center; color: var(--accent); }
.pcard { display: flex; flex-direction: column; gap: 10px; }

/* app menu */
.menu-btn { width: 42px; min-height: 40px; padding: 0; font-size: 20px; flex: none; }
#menuShade { position: fixed; inset: 0; background: rgba(17,17,17,0.35); z-index: 40; display: none; }
#menuShade.open { display: block; }
#drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 84vw); background: var(--panel); border-right: 2px solid var(--line);
  z-index: 41; transform: translateX(-102%); transition: transform 0.2s; padding: 14px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
#drawer.open { transform: none; }
.drawer-head { font-size: 12px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; border-bottom: 2px solid var(--line); padding-bottom: 8px; }
.app-link { display: flex; flex-direction: column; gap: 2px; border: 2px solid var(--line); border-radius: 6px; padding: 10px; color: var(--ink); text-decoration: none; }
.app-link b { font-size: 15px; }
.app-link small { font-size: 12px; color: var(--muted); }
.app-link.here { background: var(--accent-soft); }
a.app-link:active { background: var(--soft); }
.locate { grid-column: 1 / -1; }

/* RDSS */
.score { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-bottom: 8px; }
.score b { font-size: 30px; font-weight: 800; color: var(--accent); }
.score span { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.hint.center { text-align: center; margin-bottom: 8px; }
pre.summary { white-space: pre-wrap; font: 12px/1.45 ui-monospace, monospace; background: var(--bg); border: 2px solid var(--line); border-radius: 6px; padding: 10px; max-height: 50vh; overflow: auto; margin: 0 0 10px; }

/* Field Twin card, shown when RDSS is opened inside Field Twin */
.ft-card { border-color: var(--accent, #0b4ea2); }
.ft-card h2 { margin: 0 0 6px; font-size: 15px; }
.ft-card .hint { margin: 4px 0; }

/* Account box at the bottom of the apps menu */
.acct { display: grid; gap: 8px; margin-top: 18px; }
.acct input { width: 100%; box-sizing: border-box; }
