/* Dark theme (owner, 30 Nov 2026: dark by default, light as a per-login choice in Options).
   One layer on top of the old stylesheets: light is the site as it was, and every rule here applies only under
   html[data-theme="dark"]. The live table's status fills (red, orange, green, transition, yellow) keep their exact
   colours with dark text on them, so the table reads the same; only the page around them goes dark.
   Named colours set in the pages or by the live refresh (red, green, orange, brown, black) are lifted so they read on
   a dark page, except inside a status fill, where they keep their light-theme colour. */
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] body,
html[data-theme="dark"] .content,
html[data-theme="dark"] #leftcolumn,
html[data-theme="dark"] #rightcolumn,
html[data-theme="dark"] table.no,
html[data-theme="dark"] table.navbuttons { background: var(--bg); color: var(--text); }
html[data-theme="dark"] a { color: var(--link); }
html[data-theme="dark"] header,
html[data-theme="dark"] #footer { background: var(--surface); color: var(--text-muted); }
html[data-theme="dark"] code { background: var(--surface); border-color: var(--border); color: var(--text); }
html[data-theme="dark"] #container { border-color: var(--border); }
html[data-theme="dark"] .reg_form { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] hr { border-color: var(--border); }

/* Tables: the old see-through grey, lighter on dark; dotted lines kept. */
html[data-theme="dark"] table { background-color: rgba(255, 255, 255, 0.05); }
html[data-theme="dark"] table td { border-color: var(--border-strong); }
html[data-theme="dark"] table td.noborder { border-color: var(--bg); }
html[data-theme="dark"] tr.darker td { background-color: rgba(255, 255, 255, 0.09); }
html[data-theme="dark"] tr.hover:hover { background: var(--surface-3); }

/* Status rows: one solid palette for both themes, in layout.css ("Status rows"). */
/* Named colours lifted for a dark page. */
html[data-theme="dark"] font[color="red"], html[data-theme="dark"] [style*="color: red"] { color: var(--danger) !important; }
html[data-theme="dark"] font[color="green"], html[data-theme="dark"] [style*="color: green"] { color: var(--success) !important; }
html[data-theme="dark"] font[color="orange"], html[data-theme="dark"] [style*="color: orange"] { color: var(--warning) !important; }
html[data-theme="dark"] font[color="#664400"] { color: var(--caution) !important; }
html[data-theme="dark"] font[color="black"] { color: var(--text) !important; }
html[data-theme="dark"] font[color="#e8640c"] { color: #ff8c42 !important; }
html[data-theme="dark"] [style*="color: red; border: 1px solid red"] { border-color: var(--danger) !important; }
html[data-theme="dark"] [style*="color: green; border: 1px solid green"] { border-color: var(--success) !important; }
/* Buttons and boxes the browser draws (green and red buttons keep their own colours). */
/* :where keeps these defaults weak, so the page parts in components.css (cards, .btn-primary, .btn-danger) win. */
html[data-theme="dark"] :where(input[type=submit]:not(.greenButton):not(.redButton)),
html[data-theme="dark"] :where(button:not(.greenButton):not(.redButton):not([class^="events-"])) { background: var(--surface-3); color: var(--text); border: 1px solid var(--border-strong); }
html[data-theme="dark"] :where(input[type=text], input[type=password], select, textarea) { background: var(--field); color: var(--text); border: 1px solid var(--border-strong); }

/* Odd boxes with their own backgrounds. */
html[data-theme="dark"] [style*="background: #fafafa"] { background: var(--surface) !important; border-color: var(--border) !important; }
html[data-theme="dark"] #viewAsBar { color: #111; }
html[data-theme="dark"] #viewAsBar a { color: #002a80; }
html[data-theme="dark"] .back-to-top { background: var(--accent); color: #00212a; }

/* The events bar and timeline (112/events.css). The postbox's per-address tints come from postbox.js,
   which picks dark tints under this theme (owner, 30 Nov 2026: the pale tints with light text were unreadable). */
html[data-theme="dark"] .events-view { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .events-control,
html[data-theme="dark"] .events-control-group,
html[data-theme="dark"] .events-search { background: var(--surface-2); border-color: var(--border); }
html[data-theme="dark"] .events-item { background: var(--surface-2); border-color: var(--border); }
html[data-theme="dark"] .events-chip { background: var(--surface-3); }
html[data-theme="dark"] .events-chip-group { background: var(--surface-3); border-color: var(--border-strong); }
html[data-theme="dark"] .events-bar-filter,
html[data-theme="dark"] .events-chip-group,
html[data-theme="dark"] .events-time,
html[data-theme="dark"] .events-control,
html[data-theme="dark"] .events-live,
html[data-theme="dark"] .events-status-message { color: var(--accent); }
html[data-theme="dark"] .events-ip,
html[data-theme="dark"] .events-progress { color: var(--text); }
html[data-theme="dark"] .events-ip-address,
html[data-theme="dark"] .events-note,
html[data-theme="dark"] .events-empty { color: var(--text-muted); }
html[data-theme="dark"] .events-bar-link,
html[data-theme="dark"] .events-ip-link:hover { color: var(--link); }
html[data-theme="dark"] .events-bar-filter-active,
html[data-theme="dark"] .events-control-active { background: var(--primary); color: #fff; }
html[data-theme="dark"] .events-status-online { background: #12402a; color: var(--success); }
html[data-theme="dark"] .events-status-offline { background: #4a1d1f; color: var(--danger); }
html[data-theme="dark"] .events-status-drop { background: #4a3315; color: var(--warning); }
html[data-theme="dark"] .events-progress-confirmed-online { color: var(--success); }
html[data-theme="dark"] .events-progress-confirmed-offline,
html[data-theme="dark"] .events-status-error { color: var(--danger); }
