/* og-watcher additions on top of app.css */
.topbar .sp, .hist-head .sp { flex: 1; }
.top-actions { display: flex; gap: 8px; }
.foot { margin-top: 24px; font-size: 12px; text-align: center; }
.alerts-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; padding: 10px 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--line)); color: var(--text-2); font-size: 13.5px; }
.alerts-banner > i { color: var(--warn); font-size: 20px; }
.alerts-banner > span { flex: 1; min-width: 220px; }
.alerts-banner b { color: var(--text); }
.alerts-banner .ghost-btn { margin: 0; }
.hist-modal { width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column; gap: 12px; }
.hist-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hist-head h3 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.hist-range { grid-template-columns: repeat(5, auto); }
.hist-stats { font-size: 13px; }
.hist-stats b { color: var(--text); }
.hist-chart { min-height: 260px; width: 100%; overflow: hidden; }
.hist-chart .u-legend { color: var(--text-2); font-size: 12px; }
.hist-table-wrap { overflow: auto; min-height: 120px; border: 1px solid var(--line); border-radius: 10px; }
.hist-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.hist-table th { position: sticky; top: 0; background: var(--card-2); text-align: left; color: var(--text-3); font-weight: 600; padding: 6px 10px; }
.hist-table td { padding: 5px 10px; border-top: 1px solid var(--line); color: var(--text-2); vertical-align: top; }
.hist-table td:nth-child(1), .hist-table td:nth-child(4) { white-space: nowrap; font-family: var(--mono); font-size: 11.5px; }
.hist-table tr.bad td:nth-child(2) { color: var(--warn); }
.groups { display: grid; gap: 14px; margin-bottom: 28px; }
.group-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.group-card.off { opacity: .65; }
.group-card .w-top b { font-size: 16px; }
.warn-text { color: var(--warn); }
.g-filters { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12.5px; }
.g-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; max-height: 70vh; }
.g-showall { display: block; padding: 8px 10px; font-size: 12.5px; }
.g-table td:nth-child(n+3) { white-space: nowrap; }
.g-table td:nth-child(1) { white-space: normal; font-family: inherit; font-size: 13px; min-width: 140px; }
.g-table td:nth-child(4) { font-family: var(--mono); font-size: 11.5px; }
.g-table tr.bad td:nth-child(2) { color: var(--text-2); }
.g-table td a { color: var(--text); }
.g-table tr.nomatch td { opacity: .55; }
.g-table s { color: var(--text-3); }
.g-table .down { color: var(--good); }
.g-table .up { color: var(--crit); }
.g-table .sub { display: block; font-size: 11px; color: var(--text-3); white-space: nowrap; }
.g-table .conf { font-size: 10.5px; padding: 0 5px; border-radius: 6px; border: 1px solid var(--line); color: var(--text-2); font-family: inherit; }
.g-table .conf-high { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.g-table .conf-low { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.g-table .tcg-none { color: var(--text-3); font-style: italic; }
.mtg-table .ph-only { display: none; }
.g-table .tcg-fix { padding: 0 3px; opacity: .6; }
.g-table .tcg-fix:hover { opacity: 1; }
.g-table td a .mdi { font-size: 11px; margin-left: 2px; color: var(--text-3); }
.t-now { font-size: 13px; color: var(--text-2); }
.t-now ul { margin: 6px 0 0; padding-left: 18px; }
.t-now a { color: var(--text); }
.t-actions { flex-wrap: wrap; }
.t-actions .sp { flex: 1; }
.g-modal { width: min(640px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; }
.g-modal label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.g-modal label.chk { flex-direction: row; align-items: center; gap: 6px; }
.g-row { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.g-row > label { flex: 1; min-width: 180px; }
.g-types { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.g-modal input.tiny { width: 52px; }
@media (max-width: 640px) {
  .watches { grid-template-columns: 1fr; }
  .hist-table:not(.g-table) td:nth-child(5), .hist-table:not(.g-table) th:nth-child(5) { display: none; }
  .g-table:not(.mtg-table) td:nth-child(2), .g-table:not(.mtg-table) th:nth-child(2), .g-table:not(.mtg-table) td:nth-child(6), .g-table:not(.mtg-table) th:nth-child(6) { display: none; }
  .mtg-table td:nth-child(2), .mtg-table th:nth-child(2), .mtg-table td:nth-child(3), .mtg-table th:nth-child(3), .mtg-table td:nth-child(5), .mtg-table th:nth-child(5), .mtg-table td:nth-child(7), .mtg-table th:nth-child(7), .mtg-table td:nth-child(9), .mtg-table th:nth-child(9) { display: none; }
  .mtg-table td:nth-child(1) { min-width: 90px; }
  .mtg-table td, .mtg-table th { padding-left: 6px; padding-right: 6px; }
  .mtg-table .ph-only { display: block; }
  .mtg-table .sub { white-space: normal; }
  .mtg-table td:nth-child(6) { min-width: 86px; white-space: normal; }
}
/* price trackers (lineups) */
.l-sources { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.l-src { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 2px 4px 2px 8px; color: var(--text-2); background: var(--bg-2); }
.l-src.bad { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.l-src.off { opacity: .55; }
.l-src .link-btn { padding: 0 4px; }
.l-table td { white-space: normal !important; font-family: inherit !important; font-size: 12.5px !important; min-width: 96px; }
.l-table td:first-child { min-width: 0; text-align: center; }
.l-table td:nth-child(2) { min-width: 150px; }
.l-table .pr { font-family: var(--mono); font-size: 13px; color: var(--text); font-weight: 600; }
.l-table .pr.best { color: var(--good); }
.l-table .sub { display: block; color: var(--text-3); font-size: 11px; line-height: 1.3; max-width: 180px; }
.l-table s { color: var(--text-3); }
.l-table .down { color: var(--good); }
.l-table a { color: inherit; text-decoration: none; }
.l-table a:hover .pr { text-decoration: underline; }
.l-table tr.noalert td:nth-child(2) b { color: var(--text-2); font-weight: 500; }
.l-table .tier { font-size: 10.5px; }
/* OG-Host sign-in (header) */
.signin-btn { padding: 7px 12px; font-size: 13px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.account-btn { width: auto; display: flex; gap: 6px; padding: 0 10px; font-size: 13px; font-weight: 600; }
.account-btn i { font-size: 18px; }
.account-btn span { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) { .account-btn span { display: none; } }
/* catalog trackers (iPad): model filter + one header row per model */
.l-fams { display: flex; flex-wrap: wrap; gap: 6px; }
.l-fams .chip { cursor: pointer; font-size: 12px; padding: 2px 8px; }
.l-fams .chip.on { color: var(--text); border-color: var(--accent, var(--good)); }
.l-table tr.l-fam td { background: var(--bg-2); text-align: left !important; font-size: 13px !important; }
/* IronWolf drive tracker (task #169): per-TB summary per shop, target chips */
.l-fams .sp { flex: 1; }
.l-table.d-sum td:first-child { text-align: left; min-width: 110px; }
.l-table.d-sum td { min-width: 120px; }
@media (max-width: 640px) {
  /* the generic g-table phone rule hides columns 2 and 6; tracker tables need them (they scroll sideways) */
  .g-table.l-table td:nth-child(2), .g-table.l-table th:nth-child(2), .g-table.l-table td:nth-child(6), .g-table.l-table th:nth-child(6) { display: table-cell; }
}
/* sortable columns (task #175): the whole header is a button; arrow = current order */
.hist-table th.sorted { color: var(--text); }
.th-sort { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 3px; cursor: pointer; color: inherit; font: inherit; min-height: 28px; padding: 2px 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.th-sort:hover { color: var(--text); }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sort-ind { font-size: 13px; line-height: 1; opacity: .35; }
th.sorted .sort-ind, .w-sortbar .chip.on .sort-ind { opacity: 1; color: var(--accent); }
.w-sortbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 10px; font-size: 12px; }
.w-sortbar .chip { cursor: pointer; font-size: 12px; padding: 4px 9px; display: inline-flex; align-items: center; gap: 3px; }
.w-sortbar .chip.on { color: var(--text); border-color: var(--accent); }
.w-sortbar .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* task #184: alert rules */


.w-extra { display: flex; flex-wrap: wrap; gap: .35rem .9rem; align-items: center; font-size: .9em; grid-column: 1 / -1; }
.r-modal { max-width: 640px; }
.r-modal h4 { margin: .8rem 0 .3rem; }
.g-modal.r-modal input.time { width: 76px; text-align: center; }
.r-log { max-height: 40vh; overflow: auto; display: grid; gap: .25rem; }
.r-vkey { display: flex; gap: .5rem; margin-top: .5rem; flex-wrap: wrap; }
.r-vkey input { flex: 1 1 14rem; min-width: 0; }
.r-entry summary { cursor: pointer; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.r-when { font-variant-numeric: tabular-nums; opacity: .75; }
.r-entry pre { white-space: pre-wrap; word-break: break-word; font-size: .82em; margin: .3rem 0 .5rem; padding: .5rem; border-radius: 8px; background: var(--card-2, rgba(127,127,127,.08)); }
.rules-note { display: block; }
.rules-note > .mdi { margin-right: .3rem; }
.r-quiet { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; margin-top: .4rem; }
.r-times { display: inline-flex; gap: .4rem; align-items: center; }
.r-sub { margin: .2rem 0 .6rem; font-size: .88em; }
/* installable app (task #203): safe areas (notch in landscape, home bar,
   status bar) */
.topbar {
  padding-top: max(12px, env(safe-area-inset-top));
  padding-left: max(16px, calc((100vw - 1320px) / 2), env(safe-area-inset-left));
  padding-right: max(16px, calc((100vw - 1320px) / 2), env(safe-area-inset-right));
}
main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.toast { bottom: calc(20px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); }
.palette-backdrop { padding-top: max(12vh, calc(env(safe-area-inset-top) + 16px)); padding-bottom: env(safe-area-inset-bottom); overflow-y: auto; }

/* task #213: unit prices (price each, $/Ah, $/Wh, $/TB …) */
.w-unit { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; margin-top: 2px; }
.w-unit b { color: var(--text); font-weight: 600; }
.w-unit .prim b { color: var(--good); }
.w-unit .muted { font-size: 11.5px; }
.b-pin { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); border-radius: 6px; padding: 0 5px; white-space: nowrap; }

/* connect screen of the hosted web app (task #645, conn.js) */
.ogv-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.ogv-card { width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px 22px; box-shadow: var(--shadow); }
.ogv-card h1 { margin: 0; font-size: 20px; }
.ogv-icon { border-radius: 16px; }
.ogv-form { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.ogv-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.ogv-label[hidden] { display: none; }
.ogv-label input { font: inherit; font-size: 15px; color: var(--text); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; }
.ogv-go { justify-content: center; padding: 10px; }
.ogv-out { margin: 0; min-height: 1em; color: var(--red, #f87171); font-size: 13px; text-align: center; }
.ogv-out:empty { display: none; }
