/* RTO web client - the GoosViewer look: a dark-first control-room palette,
   cards on a normalized board, quiet quality and loud alarms. Tokens are
   the viewer's (Viewer.UI.pas), dark then light. */
:root {
  --bg: #0B0E14; --card: #131820; --card-hi: #18202A; --border: #1F2733; --track: #1A222D; --griddot: #253040;
  --text: #E6EDF5; --muted: #7D8A9C; --accent: #2FD3E0; --good: #46D07A; --warn: #F6A93B; --bad: #FF5A6E; --nocomm: #5A6675;
  --alarm-hi: #8C1A1A; --alarm-hi-fg: #F0F0F0; --alarm-lo: #E0B020; --alarm-lo-fg: #121212;
  --rad-card: 14px; --rad-ctl: 8px; --pad: 14px; --gutter: 12px; --hdr: 42px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
body[data-theme="light"] {
  --bg: #F2F5F9; --card: #FFFFFF; --card-hi: #F7F9FC; --border: #DDE3EC; --track: #E7ECF3; --griddot: #CFD7E2;
  --text: #10151C; --muted: #64707E; --accent: #0E8C99; --good: #1E9E56; --warn: #C67714; --bad: #D63B4E; --nocomm: #8A94A0;
  --alarm-hi: #961E1E; --alarm-hi-fg: #FFFFFF; --alarm-lo: #F0C43C; --alarm-lo-fg: #1F1F1F;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 13px/1.35 var(--font); overflow: hidden; }
button, select, input { font: inherit; }

/* ---- login ---- */
body.login { display: grid; place-items: center; overflow: auto; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--rad-card); }
.login .card { padding: 28px 32px; width: 320px; display: grid; gap: 14px; }
.login h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: 2px; }
.login label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.login input { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--rad-ctl); padding: 8px; font-size: 14px; }
.login button { background: var(--accent); color: #0B0E14; border: 0; border-radius: var(--rad-ctl); padding: 9px; font-size: 14px; font-weight: 600; cursor: pointer; }
.msg { color: var(--bad); margin: 0; }

/* ---- header strip: 60 px, accent rail on the left, hairline at the foot ---- */
body.app { display: grid; grid-template-rows: auto 1fr; }
/* the header wraps onto a second row when the window is too narrow for
   the tabs and the buttons side by side, instead of squeezing their text */
#top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-height: 60px; padding: 6px 14px 6px 18px; background: var(--card); border-bottom: 1px solid var(--border); box-shadow: inset 3px 0 0 var(--accent); }
.brand .title { font-size: 16px; font-weight: 700; letter-spacing: 1px; line-height: 1.1; }
.brand .sub { color: var(--muted); font-size: 11px; }
.field { display: grid; gap: 1px; }
.field span { color: var(--muted); font-size: 9px; letter-spacing: 1px; font-weight: 700; }
select, .dlg input, .dlg select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--rad-ctl); padding: 4px 8px; height: 28px; }
.seg { display: flex; border: 1px solid var(--border); border-radius: var(--rad-ctl); overflow: hidden; }
.seg button { background: transparent; color: var(--muted); border: 0; padding: 0 12px; height: 28px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--track); color: var(--text); }
.actions { display: flex; gap: 6px; }
.btn { height: 28px; padding: 0 12px; border-radius: var(--rad-ctl); border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; white-space: nowrap; }
.btn.ghost:hover { background: var(--card-hi); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0B0E14; font-weight: 600; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: .4; cursor: default; }
.pills { margin-left: auto; display: flex; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 11px; background: color-mix(in srgb, var(--nocomm) 12%, transparent); border: 1px solid color-mix(in srgb, var(--nocomm) 45%, transparent); }
.pill i { width: 6px; height: 6px; border-radius: 3px; background: var(--nocomm); }
.pill.good { background: color-mix(in srgb, var(--good) 12%, transparent); border-color: color-mix(in srgb, var(--good) 45%, transparent); }
.pill.good i { background: var(--good); }
.pill.warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.pill.warn i { background: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.pill.bad i { background: var(--bad); }
.logout { margin: 0; }

/* ---- views ---- */
.view { min-height: 0; overflow: hidden; }
.view[hidden] { display: none !important; }

/* ---- the board: normalized cells, never scrolls ---- */
.board { position: relative; width: 100%; height: 100%; overflow: hidden; }
.board.edit { background-image: radial-gradient(var(--griddot) 1px, transparent 1.2px); }
.wcard { position: absolute; background: linear-gradient(color-mix(in srgb, var(--card) 97%, var(--text)), var(--card)); border: 1px solid var(--border); border-radius: var(--rad-card); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .12s, background .12s; }
.wcard:hover { background: var(--card-hi); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.board.edit .wcard { box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--accent) 75%, transparent); cursor: move; user-select: none; }
.board.edit .wcard.moving { opacity: .85; z-index: 5; }
.chead { padding: 8px var(--pad) 0; height: var(--hdr); flex: 0 0 auto; }
.wcard.short .chead { height: 26px; }
.wcard.short .csub { display: none; }
.ctitle { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 64px; }
.csub { font-size: 9.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cbody { flex: 1; min-height: 0; position: relative; padding: 0 var(--pad) 10px; }
.cbody canvas { display: block; width: 100%; height: 100%; }
.qrail { position: absolute; left: 4px; top: var(--hdr); bottom: 12px; width: 3px; border-radius: 2px; display: none; }
.qword { position: absolute; right: 12px; bottom: 6px; font-size: 9.5px; font-weight: 700; display: none; }
.wcard[data-q="stale"] .qrail, .wcard[data-q="stale"] .qword { display: block; background: var(--warn); color: var(--warn); }
.wcard[data-q="bad"] .qrail, .wcard[data-q="bad"] .qword { display: block; background: var(--bad); color: var(--bad); }
.wcard[data-q="nocomm"] .qrail, .wcard[data-q="nocomm"] .qword { display: block; background: var(--nocomm); color: var(--nocomm); }
.wcard[data-q] .qword { background: transparent; }
/* alarm: the whole card in the alarm colour on the lit half-period; the left
   strip holds the colour through the dark half so a photo still shows it */
.wcard.alarm-hi { box-shadow: inset 4px 0 0 var(--alarm-hi); }
.wcard.alarm-lo { box-shadow: inset 4px 0 0 var(--alarm-lo); }
.wcard.alarm-hi.lit { background: var(--alarm-hi); color: var(--alarm-hi-fg); }
.wcard.alarm-lo.lit { background: var(--alarm-lo); color: var(--alarm-lo-fg); }
.wcard.lit .csub, .wcard.lit .vunit { color: inherit; opacity: .8; }
.wcard.lit .qword { display: block; color: inherit; }
/* chips in edit mode */
.chip { position: absolute; top: 8px; width: 22px; height: 22px; border-radius: 11px; display: none; place-items: center; cursor: pointer; font-size: 12px; line-height: 1; }
.chip.del { right: 8px; background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.chip.props { right: 34px; background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); }
.board.edit .chip { display: grid; }
.grip { position: absolute; right: 4px; bottom: 4px; width: 18px; height: 18px; cursor: nwse-resize; display: none; background: linear-gradient(135deg, transparent 50%, var(--muted) 50%, var(--muted) 56%, transparent 56%, transparent 68%, var(--muted) 68%, var(--muted) 74%, transparent 74%, transparent 86%, var(--muted) 86%, var(--muted) 92%, transparent 92%); opacity: .7; }
.board.edit .grip { display: block; }
.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty b { font-size: 12px; display: block; }
.empty small { font-size: 9.5px; opacity: .6; }

/* value card */
.vwrap { position: absolute; inset: 0 var(--pad) 16px; display: flex; align-items: baseline; justify-content: flex-start; gap: 6px; overflow: hidden; }
.vnum { font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap; }
.vunit { font-size: 12px; color: var(--muted); }
/* state banner */
.banner { position: absolute; inset: 4px var(--pad) 12px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; color: var(--card); text-align: center; padding: 6px; overflow: hidden; }
/* plot card */
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; height: 20px; overflow: hidden; font-size: 9.5px; color: var(--muted); padding: 2px 0; }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; background: currentColor; margin-right: 4px; vertical-align: -1px; }
.legend span { color: var(--muted); }
.legend span b { color: inherit; font-weight: 600; }
.plotarea { position: absolute; left: var(--pad); right: var(--pad); top: 24px; bottom: 8px; }
.readout { position: absolute; right: 8px; top: 8px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 10px; pointer-events: none; display: none; z-index: 2; }
.readout div { white-space: nowrap; }
.readout i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; vertical-align: -1px; }
.u-legend { display: none; }
.uplot, .u-wrap { background: transparent; }
.u-select { background: transparent; }
/* activity tooltip */
.tip { position: absolute; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 10px; pointer-events: none; display: none; box-shadow: inset 6px 0 0 var(--accent); z-index: 3; white-space: nowrap; }

/* ---- dialogs: dfm-less, accent rule along the top edge and nothing else ---- */
.dlg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; z-index: 10; }
.dlg[hidden] { display: none; }
.dlg-box { background: var(--bg); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: 10px; width: 520px; max-width: 95vw; max-height: 90vh; overflow: auto; padding: 16px 18px; display: grid; gap: 10px; }
.dlg-box h2 { margin: 0 0 4px; font-size: 14px; }
.dlg-box .section { font-size: 9.5px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.dlg-box .row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 8px; }
.dlg-box .row label { color: var(--muted); font-size: 12px; }
.dlg-box .row .sw { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--border); cursor: pointer; vertical-align: middle; color: var(--muted); font-size: 11px; }
.dlg-box .btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.dlg-box .hint { color: var(--muted); font-size: 11px; }
.dlg-box .err { color: var(--bad); font-size: 12px; min-height: 1.2em; }
.kinds { display: grid; gap: 6px; }
.kinds button { text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: var(--rad-ctl); padding: 8px 12px; color: var(--text); cursor: pointer; }
.kinds button:hover { background: var(--card-hi); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.kinds button small { display: block; color: var(--muted); font-size: 11px; }
.picker { display: grid; gap: 6px; }
.picker .list { max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: var(--rad-ctl); background: var(--card); }
.picker .list div { padding: 5px 10px; cursor: pointer; font-size: 12px; }
.picker .list div:hover, .picker .list div.sel { background: var(--track); }
.picker .list div small { color: var(--muted); margin-left: 6px; }
.traces { display: grid; gap: 4px; }
.traces .trow { display: grid; grid-template-columns: 1fr 66px 66px 58px 78px 40px 84px 24px; gap: 4px; align-items: center; }
.traces .trow label.lg { display: inline-flex; align-items: center; gap: 2px; font-size: 10px; color: var(--muted); cursor: pointer; }
.traces .trow input { min-width: 0; height: 26px; padding: 2px 6px; }
.traces .trow .sw { width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--border); cursor: pointer; }

/* ---- time log ---- */
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--card); }
.bar .spacer { flex: 1; }
.bar label { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
#view-tlog { display: flex; flex-direction: column; }
.tlog-out { overflow: auto; padding: 14px; flex: 1; }
.tlog h2 { margin: 0 0 4px; font-size: 16px; }
.tlog .meta { color: var(--muted); margin: 0 0 10px; }
.tlog table { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 12px; }
.tlog th, .tlog td { border: 1px solid var(--border); padding: 2px 8px; text-align: right; white-space: nowrap; }
.tlog th:first-child, .tlog td:first-child { text-align: left; }
.tlog th small { color: var(--muted); font-weight: 400; }
@media print {
  body.app { display: block; background: #fff; color: #000; }
  #top, #view-log, .bar { display: none !important; }
  #view-tlog { display: block !important; }
  .tlog th, .tlog td { border-color: #999; }
}

/* ---- web-only cards ---- */
.twrap { position: absolute; inset: 0 var(--pad) 12px; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 2px; }
.twrap .tnum { font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap; display: flex; align-items: baseline; gap: 6px; }
.twrap .tnum small { font-size: 11px; color: var(--muted); font-weight: 400; }
.twrap canvas { width: 100%; height: 100%; min-height: 0; }
.twrap .trange { font-size: 9.5px; color: var(--muted); display: flex; justify-content: space-between; }
.barwrap { position: absolute; inset: 2px var(--pad) 10px; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 4px; }
.barwrap canvas { width: 100%; height: 100%; min-height: 0; }
.barwrap .blabels { display: flex; justify-content: space-between; font-size: 9.5px; color: var(--muted); }
.statgrid { position: absolute; inset: 0 var(--pad) 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; align-content: center; }
.statgrid div { display: grid; }
.statgrid b { font-size: 9.5px; color: var(--muted); font-weight: 600; letter-spacing: .5px; }
.statgrid span { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.statgrid span small { font-size: 10px; color: var(--muted); margin-left: 3px; font-weight: 400; }
.textcard { position: absolute; inset: 0 var(--pad) 12px; overflow: auto; white-space: pre-wrap; font-size: 13px; line-height: 1.4; }
.clockwrap { position: absolute; inset: 0 var(--pad) 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.clockwrap .big { font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.clockwrap .small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.chartarea { position: absolute; left: var(--pad); right: var(--pad); top: 24px; bottom: 8px; }
.dlg textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--rad-ctl); padding: 6px 8px; min-height: 70px; font: inherit; }

/* ---- well log card: tracks drawn on one canvas, headers above ---- */
.wlwrap { position: absolute; inset: 0 8px 8px; }
.wlwrap canvas { width: 100%; height: 100%; }
.wlwrap .readout { left: auto; right: 8px; top: auto; bottom: 8px; }
.traces .trow.wl { grid-template-columns: 1fr 52px 62px 62px 42px 70px 78px 76px 24px; }
.traces .trow.wl input[type="checkbox"] { height: 16px; }
.thead { display: grid; gap: 4px; font-size: 9.5px; color: var(--muted); letter-spacing: .5px; }
.thead.wl { grid-template-columns: 1fr 52px 62px 62px 42px 70px 78px 76px 24px; }
/* the depth-scrolled cards' way back to the bottom of the hole */
.follow { position: absolute; right: 12px; top: 4px; z-index: 3; display: none; font-size: 10px; padding: 2px 8px; border-radius: 10px; background: var(--card-hi); color: var(--text); border: 1px solid var(--border); cursor: pointer; }
.follow:hover { border-color: var(--accent); }
.dlg-box.wide { width: 760px; }

/* ---- channels and account pages ---- */
.muted { color: var(--muted); font-size: 12px; }
.filter { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--rad-ctl); padding: 4px 8px; height: 28px; width: 240px; }
table.grid { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
table.grid th { text-align: left; font-size: 9.5px; letter-spacing: .5px; color: var(--muted); font-weight: 700; text-transform: uppercase; padding: 4px 8px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); }
table.grid td { padding: 3px 8px; border-bottom: 1px solid var(--track); white-space: nowrap; }
table.grid tr:hover td { background: var(--card); }
table.grid input, table.grid select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; height: 26px; font: inherit; }
table.grid input.cap { width: 190px; }
table.grid input.num { width: 72px; }
table.grid input.col { width: 76px; text-transform: uppercase; }
table.grid .sw { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border); vertical-align: middle; margin-left: 4px; }
table.grid .key { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }
table.grid .btn { height: 24px; padding: 0 8px; font-size: 11.5px; }
table.grid tr.dirty td { background: color-mix(in srgb, var(--warn) 8%, transparent); }
table.grid .tag { font-size: 10px; padding: 1px 6px; border-radius: 8px; border: 1px solid var(--border); color: var(--muted); }
table.grid .tag.admin { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.acct-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 900px; }
.acct-grid .card { padding: 12px 16px; }
.acct-grid h3 { margin: 0 0 8px; font-size: 13px; }
.colpick { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; max-height: 50vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--rad-ctl); padding: 6px 10px; background: var(--card); }
.colpick label { display: flex; gap: 6px; align-items: center; font-size: 12px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.colpick label small { color: var(--muted); }

/* ---- alarms: the whole card blinks by animation, so a card nobody is
   redrawing still blinks; the left strip holds the colour throughout ---- */
@keyframes rto-blink-hi { 0%, 49.9% { background: var(--alarm-hi); color: var(--alarm-hi-fg); } }
@keyframes rto-blink-lo { 0%, 49.9% { background: var(--alarm-lo); color: var(--alarm-lo-fg); } }
@keyframes rto-pill { 50% { opacity: .45; } }
.wcard.alarm-hi { animation: rto-blink-hi 1s steps(1, end) infinite; box-shadow: inset 5px 0 0 var(--alarm-hi); }
.wcard.alarm-lo { animation: rto-blink-lo 1s steps(1, end) infinite; box-shadow: inset 5px 0 0 var(--alarm-lo); }
.wcard.alarm-hi .qword, .wcard.alarm-lo .qword { display: block; color: inherit; background: transparent; }
.wcard.alarm-hi .csub, .wcard.alarm-lo .csub, .wcard.alarm-hi .vunit, .wcard.alarm-lo .vunit { color: inherit; opacity: .85; }
.pill[hidden] { display: none; }
.pill.alarm { background: var(--alarm-hi); border-color: var(--alarm-hi); color: var(--alarm-hi-fg); font-weight: 700; cursor: pointer; animation: rto-pill 1s steps(1, end) infinite; }
.pill.alarm i { background: var(--alarm-hi-fg); }
.alist { display: grid; gap: 4px; }
.arow { padding: 6px 10px; border-radius: 6px; font-weight: 600; }
.arow.hi { background: var(--alarm-hi); color: var(--alarm-hi-fg); }
.arow.lo { background: var(--alarm-lo); color: var(--alarm-lo-fg); }
.dlg-box .btns .spacer { flex: 1; }
table.grid td.alarmon { color: var(--bad); font-weight: 600; }
table.grid tr.hiddench td { opacity: .55; }

/* ---- geology ---- */
.lsw { display: inline-block; width: 18px; height: 12px; border: 1px solid var(--border); border-radius: 2px; vertical-align: -2px; margin-right: 6px; }
.litholegend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 12px; font-size: 11px; color: var(--muted); }
.cbar { display: inline-flex; width: 120px; height: 12px; border: 1px solid var(--border); border-radius: 2px; overflow: hidden; vertical-align: -2px; background: var(--track); margin-right: 6px; }
.cbar i { display: block; height: 100%; }
table.grid td.desc { white-space: normal; max-width: 420px; font-size: 11.5px; }
.compgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 12px; }
.compgrid label { display: grid; grid-template-columns: 22px 1fr 58px; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.compgrid input { height: 24px; padding: 2px 6px; min-width: 0; }
.section .bad { color: var(--bad); }
.section .good { color: var(--good); }
.tip.wide { white-space: normal; max-width: 280px; }

/* ---- files ---- */
.crumb { display: flex; gap: 2px; align-items: center; font-size: 12px; }
.crumb button { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 2px 4px; font: inherit; }
.crumb span { color: var(--muted); }
.files-drop.over { outline: 2px dashed var(--accent); outline-offset: -8px; }
table.grid tr.folder td:first-child { cursor: pointer; color: var(--accent); font-weight: 600; }
table.grid a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.tlog-out > .muted { margin-bottom: 8px; }


/* ---- board pages: a strip of tabs above the board ---- */
#view-log { display: flex; flex-direction: column; }
#view-log .board { flex: 1; height: auto; min-height: 0; }
.pages { display: flex; gap: 4px; padding: 6px 10px 0; flex: 0 0 auto; overflow-x: auto; }
.pages .page { height: 26px; padding: 0 14px; border: 1px solid var(--border); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--card); color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 12px; }
.pages .page:hover { color: var(--text); background: var(--card-hi); }
.pages .page.on { color: var(--text); font-weight: 700; box-shadow: inset 0 2px 0 var(--accent); background: var(--card-hi); }
.pages .page.add { padding: 0 10px; font-weight: 700; }

/* ---- trajectory cards ---- */
.card3d { position: absolute; inset: 0 8px 8px; cursor: grab; }
.card3d canvas { display: block; width: 100%; height: 100%; }
.card3d .v3btns { position: absolute; right: 2px; top: 0; display: flex; gap: 3px; }
.card3d .v3btns button { background: var(--card-hi); color: var(--text); border: 1px solid var(--border); border-radius: 6px; font-size: 10px; padding: 1px 6px; cursor: pointer; }
.board.edit .card3d { cursor: move; }

/* ---- the full-page lists scroll: every page is a column, its list the flexible part ---- */
#view-chan, #view-acct, #view-geo, #view-files, #view-cam { display: flex; flex-direction: column; }
.tlog-out { min-height: 0; }

/* ---- survey stations card ---- */
.survwrap { position: absolute; inset: 0 8px 8px; overflow: auto; }
table.grid.survey { width: 100%; font-size: 11px; }
table.grid.survey th, table.grid.survey td { padding: 2px 6px; text-align: right; }
table.grid.survey tr.last td { font-weight: 700; }
table.grid.survey tr.bit td { color: var(--bad); font-style: italic; }

/* ---- roles ---- */
table.grid.roles td, table.grid.roles th { text-align: center; }
table.grid.roles td:first-child, table.grid.roles th:first-child { text-align: left; }
table.grid.roles th { white-space: normal; max-width: 90px; text-transform: none; letter-spacing: 0; font-size: 10px; }
.acct-grid h3 { margin: 14px 0 6px; }

/* ---- row numbers and the pill legend ---- */
table.grid td.num { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
#pills .pill { cursor: help; }
#pills .pill.alarm { cursor: pointer; }
.pilllegend { display: grid; gap: 6px; }
.plrow { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: center; font-size: 12px; }
.plrow .pill { justify-self: start; }

/* the column picker's rows keep their height: a label clips its overflow,
   which lets a height-limited grid squeeze every row to 0 px - the list
   drew as blank white */
.colpick { grid-auto-rows: max-content; align-content: start; }
.colpick label { min-height: 22px; }
.colpick input[type="checkbox"] { height: auto; padding: 0; margin: 0; flex: 0 0 auto; }
.colpick label span { overflow: hidden; text-overflow: ellipsis; }

/* the tenant overview: one card per well */
.wells { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; padding: 14px; overflow: auto; align-content: start; height: 100%; }
.wellcard { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: grid; gap: 8px; cursor: pointer; }
.wellcard:hover { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.wellcard.alarm { border-color: var(--alarm-hi); box-shadow: inset 4px 0 0 var(--alarm-hi); }
.wellcard .wname { font-weight: 700; font-size: 14px; display: flex; align-items: baseline; gap: 8px; }
.wellcard .wname small { color: var(--muted); font-weight: 400; font-size: 11px; }
.wellcard .wact { border-radius: 6px; padding: 6px 8px; font-weight: 700; font-size: 12px; color: var(--card); text-align: center; }
.wellcard .wact.none { background: var(--track); color: var(--muted); font-weight: 400; }
.wellcard .wnums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.wellcard .wnums div { background: var(--bg); border-radius: 6px; padding: 6px 8px; }
.wellcard .wnums b { display: block; font-size: 9.5px; letter-spacing: .5px; color: var(--muted); text-transform: uppercase; }
.wellcard .wnums span { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.wellcard .wnums small { color: var(--muted); font-size: 10px; margin-left: 3px; }
.wellcard .wfoot { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); gap: 8px; }
.wellcard .walarm { color: var(--bad); font-weight: 600; white-space: normal; }
.wellcard .fresh { color: var(--good); }
.wellcard .stale { color: var(--warn); }
.wellcard .silent { color: var(--bad); }

/* the legend of a plot or chart grows to two lines; the plot area is
   pushed down to match from script */
.legend { height: auto; max-height: 42px; }
/* offset wells on the trajectory cards' properties */
.offs .offrow { display: grid; grid-template-columns: 1fr 24px 24px; gap: 6px; align-items: center; margin-bottom: 4px; }
.offs .offrow .sw { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--border); cursor: pointer; }
.offs .offrow .x { width: 22px; height: 22px; border-radius: 4px; border: 1px solid var(--border); background: transparent; color: var(--bad); cursor: pointer; padding: 0; }

/* the depth cards' scrollbar: a native one down the right edge, its
   spacer as tall as the well is against the window; the wheel and the
   bar move the same window */
.dbar { position: absolute; right: 0; top: 0; bottom: 0; width: 14px; overflow-y: scroll; overflow-x: hidden; z-index: 3; opacity: .55; }
.dbar:hover { opacity: 1; }
.dbar > div { width: 1px; }

/* a record's header in the channel lists: a rule and the record's name,
   across both columns of the time log's picker */
.rechead { grid-column: 1 / -1; padding: 8px 10px 3px; margin-top: 2px; border-top: 1px solid var(--border); font-size: 9.5px; letter-spacing: .6px; font-weight: 700; text-transform: uppercase; color: var(--muted); cursor: default; }
.rechead:first-child { border-top: 0; margin-top: 0; }
.picker .list div.rechead:hover { background: transparent; }

/* ---- the History page: a board of strip plots and trend charts over a
   chosen range, the cards the main board's, laid in a grid ---- */
.histwrap { position: relative; height: calc(100% - 45px); overflow: auto; padding: 8px 14px 14px; }
.histhead { font-size: 12px; color: var(--muted); padding: 0 0 8px; }
.histhead b { color: var(--text); }
.histboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 12px; }
.histboard .wcard { position: relative; height: var(--hcard, 480px); }
.histboard .wcard .chip { display: grid; }
.histboard .wcard .grip { display: none; }
.bar .sep { width: 1px; height: 20px; background: var(--border); }
.histquick button { padding: 0 8px; font-size: 12px; }
#hist-empty { padding: 20px 0; }
@media print {
  body[data-print="hist"] #view-tlog { display: none !important; }
  body[data-print="hist"] #view-hist { display: block !important; }
  body[data-print="hist"] .histwrap { height: auto; overflow: visible; }
  body[data-print="hist"] .histboard { display: block; }
  body[data-print="hist"] .histboard .wcard { break-inside: avoid; margin-bottom: 10px; width: 100%; background: #fff; border-color: #999; color: #000; }
  body[data-print="hist"] .histboard .chip, body[data-print="hist"] #hist-empty, body[data-print="hist"] .readout { display: none !important; }
  body[data-print="hist"] .histhead, body[data-print="hist"] .histhead b, body[data-print="hist"] .ctitle, body[data-print="hist"] .csub, body[data-print="hist"] .legend span { color: #000; }
}

/* the plot and chart header in the well log's style: caption · unit over
   a rule in the trace's colour, the scale's ends under it; one column per
   lane (inset to the lanes from script) or one row per trace */
.legend.loghead { display: grid; gap: 2px 10px; height: auto; max-height: 166px; overflow: hidden; padding: 2px 0 3px; align-items: end; }
.loghead span.lh { display: grid; grid-template-columns: 1fr 1fr; grid-template-areas: "cap cap" "rule rule" "lo hi"; min-width: 0; font-size: 9.5px; line-height: 1.2; color: var(--muted); }
.loghead span.lh::before { display: none; }
.loghead span.lh b { grid-area: cap; text-align: center; color: inherit; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loghead span.lh em { grid-area: rule; height: 0; border-top: 2px solid currentColor; margin: 1px 0; }
.loghead span.lh.dash em { border-top-style: dashed; }
.loghead span.lh.dot em { border-top-style: dotted; }
.loghead span.lh i.lo, .loghead span.lh i.hi { color: var(--muted); font-style: normal; font-size: 9px; }
.loghead span.lh i.lo { grid-area: lo; text-align: left; }
.loghead span.lh i.hi { grid-area: hi; text-align: right; }
.histboard .wcard .chip.print { right: 60px; background: color-mix(in srgb, var(--text) 10%, transparent); color: var(--text); font-size: 11px; }
@media print {
  body[data-print="histone"] #view-tlog { display: none !important; }
  body[data-print="histone"] #view-hist { display: block !important; }
  body[data-print="histone"] .histwrap { height: auto; overflow: visible; }
  body[data-print="histone"] .histboard { display: block; }
  body[data-print="histone"] .histboard .wcard { display: none; }
  body[data-print="histone"] .histboard .wcard.printone { display: flex; width: 100%; height: 90vh; background: #fff; border-color: #999; color: #000; }
  body[data-print="histone"] .histboard .chip, body[data-print="histone"] #hist-empty, body[data-print="histone"] .readout { display: none !important; }
  body[data-print="histone"] .histhead, body[data-print="histone"] .histhead b, body[data-print="histone"] .ctitle, body[data-print="histone"] .csub, body[data-print="histone"] .legend span { color: #000; }
  body[data-print] .loghead span.lh i.lo, body[data-print] .loghead span.lh i.hi { color: #333; }
}

/* the print page: each card rendered again at page size as an image under
   its title, the range line and its header; nothing else prints */
#printpage { display: none; }
@media print {
  body[data-print="page"] > *:not(#printpage) { display: none !important; }
  body[data-print="page"] { display: block; background: #fff; color: #000; }
  body[data-print="page"] #printpage { display: block; }
  #printpage section.pp { break-after: page; padding: 0 0 6mm; }
  #printpage section.pp:last-child { break-after: auto; }
  #printpage .pp-head { font-size: 12px; color: #333; margin-bottom: 4px; }
  #printpage .pp-head b { color: #000; font-size: 14px; }
  #printpage .legend.loghead { max-height: none; overflow: visible; margin-bottom: 4px; }
  #printpage .loghead span.lh i.lo, #printpage .loghead span.lh i.hi { color: #333; }
  #printpage img { display: block; width: 100%; height: auto; border: 1px solid #999; }
}

/* the print page's text at paper size */
@media print {
  #printpage .pp-head { font-size: 14px; margin-bottom: 6px; }
  #printpage .pp-head b { font-size: 18px; }
  #printpage .legend.loghead { gap: 4px 14px; margin-bottom: 8px; }
  #printpage .loghead span.lh { font-size: 13px; line-height: 1.3; }
  #printpage .loghead span.lh em { border-top-width: 3px; margin: 2px 0; }
  #printpage .loghead span.lh i.lo, #printpage .loghead span.lh i.hi { font-size: 12px; }
  #printpage img { border-color: #AEB7C2; }
}

/* the header a size up on screen; the print page's header, logo and type larger still */
.loghead span.lh { font-size: 10.5px; }
.loghead span.lh i.lo, .loghead span.lh i.hi { font-size: 10px; }
@media print {
  #printpage .pp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
  #printpage .pp-title b { font-size: 20px; }
  #printpage .pp-sub { font-size: 13px; color: #333; margin-top: 2px; }
  #printpage .pp-logo { height: 40px; width: auto; max-width: 220px; flex: 0 0 auto; }
  #printpage .loghead span.lh { font-size: 16px; }
  #printpage .loghead span.lh em { border-top-width: 3px; }
  #printpage .loghead span.lh i.lo, #printpage .loghead span.lh i.hi { font-size: 13px; }
}

/* a toast: one line at the foot of the page for a few seconds */
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30; background: var(--card-hi); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--warn); border-radius: 8px; padding: 8px 14px; font-size: 12px; box-shadow: 0 4px 18px rgba(0,0,0,.35); transition: opacity .4s; }
.toast.gone { opacity: 0; }
@media print { .toast { display: none; } }

/* ---- the Reports page: sections on a page, printed as they stand ---- */
.report { height: calc(100% - 45px); overflow: auto; padding: 10px 14px 20px; }
.reppage { max-width: 1000px; margin: 0 auto; }
.rephead { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; border-bottom: 2px solid var(--border); padding-bottom: 8px; margin-bottom: 10px; }
.rephead h1 { margin: 0 0 4px; font-size: 20px; }
.rephead .repwell { font-size: 14px; font-weight: 600; }
.rephead .pp-logo { height: 44px; width: auto; max-width: 220px; }
.reppage h2 { font-size: 13px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin: 16px 0 6px; border-bottom: 1px solid var(--border); padding-bottom: 3px; }
table.grid.rep { width: 100%; }
table.grid.rep td.num { text-align: right; color: var(--text); }
table.grid.rep.kv td:first-child { color: var(--muted); width: 40%; }
.repshare { display: flex; height: 18px; border-radius: 6px; overflow: hidden; background: var(--track); }
.repshare span { display: block; height: 100%; }
.repsharelg { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 11px; color: var(--muted); }
.repsharelg i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.repplots { display: grid; gap: 14px; }
.repfig { margin: 0; break-inside: avoid; }
.repfig img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 6px; }
.repfig figcaption { font-size: 11px; color: var(--muted); margin-top: 3px; }
.repfig .legend.loghead { max-height: none; overflow: visible; }
@media print {
  body[data-print="report"] #top, body[data-print="report"] .bar, body[data-print="report"] #dlg, body[data-print="report"] .toast { display: none !important; }
  body[data-print="report"] .view { display: none !important; }
  body[data-print="report"] #view-rep { display: block !important; }
  body[data-print="report"] { display: block; background: #fff; color: #000; }
  body[data-print="report"] .report { height: auto; overflow: visible; padding: 0; }
  body[data-print="report"] .reppage { max-width: none; }
  body[data-print="report"] .reppage h1, body[data-print="report"] .repwell, body[data-print="report"] .reppage h2, body[data-print="report"] table.grid.rep td, body[data-print="report"] table.grid.rep th, body[data-print="report"] .muted, body[data-print="report"] .repsharelg, body[data-print="report"] .repfig figcaption { color: #000; }
  body[data-print="report"] table.grid.rep td, body[data-print="report"] table.grid.rep th { border-color: #999; }
  body[data-print="report"] .rephead { border-color: #000; }
  body[data-print="report"] .repshare { background: #eee; }
  body[data-print="report"] .repfig img { border-color: #999; break-inside: avoid; }
  body[data-print="report"] .reppage h2 { break-after: avoid; }
  body[data-print="report"] .loghead span.lh i.lo, body[data-print="report"] .loghead span.lh i.hi { color: #333; }
}

/* ---- cameras: tiles of live streams ---- */
.camgrid { display: grid; gap: 12px; align-content: start; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.camgrid.cols1 { grid-template-columns: minmax(0, 1fr); }
.camgrid.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.camgrid.cols4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.camtile { background: var(--card); border: 1px solid var(--border); border-radius: var(--rad-card); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.camhead { display: flex; gap: 8px; align-items: center; padding: 6px 10px; font-size: 12px; }
.camname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.camst { margin-left: auto; font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.camst[data-s="ok"] { color: var(--good); }
.camst[data-s="bad"] { color: var(--bad); }
.camview { background: #000; aspect-ratio: 16 / 9; display: grid; place-items: center; cursor: zoom-in; }
.camview img, .camview video { width: 100%; height: 100%; object-fit: contain; display: block; }
.camfoot { display: flex; gap: 6px; align-items: center; padding: 6px 10px; font-size: 11px; }
.camfoot .spacer { flex: 1; }
.camtile:fullscreen { background: #000; border: 0; border-radius: 0; }
.camtile:fullscreen .camview { flex: 1; aspect-ratio: auto; min-height: 0; cursor: zoom-out; }
.camtile:fullscreen .camhead, .camtile:fullscreen .camfoot { color: #ddd; }
.camempty { grid-column: 1 / -1; padding: 24px; text-align: center; }
