/* Dark mode for the whole app. Loaded after app.css; only active when <html data-mode="dark"> (the person chose Dark, or chose "Same as my computer"
   and the computer is dark). Screens only: printing and the PDFs stay light.
   Most of the app uses the colour variables below, so changing them turns the whole app dark; the rest of this file fixes the few places that
   have a fixed colour of their own. */
@media screen {
html[data-mode="dark"] {
  color-scheme: dark;
  --bg: #0e1522; --surface: #162033; --raise: #1b2740; --ink: #e5ebf5; --muted: #a0adc2; --faint: #75849c; --line: #2a3750;
  --accent: #5d9de4; --accent-ink: #8dbdf3; --accent-tint: #1a2d4b; --logo-blue: #5d9de4;
  --ok-ink: #7fd3a8; --ok-bg: #14301f; --warn-ink: #e6c06d; --warn-bg: #352a12; --danger-ink: #f39d94; --danger-bg: #3b1d1c; --info-ink: #8fbde6; --info-bg: #15293f;
  --shadow: 0 1px 2px #0007, 0 8px 24px -12px #000b;
}

/* buttons, fields, drop-downs */
html[data-mode="dark"] .btn { color: var(--ink); background: var(--raise); border-color: var(--line); }
html[data-mode="dark"] .btn:hover { background: #22304d; }
html[data-mode="dark"] .btn.soft { color: #cfe0f7; background: #26385a; border-color: #3a557f; }
html[data-mode="dark"] .btn.soft:hover { background: #2d436b; }
html[data-mode="dark"] .btn.primary { color: #fff; background: #2f6cb5; border-color: #2f6cb5; }
html[data-mode="dark"] .btn.primary:hover { background: #3a7ccb; }
html[data-mode="dark"] input, html[data-mode="dark"] select, html[data-mode="dark"] textarea { background: var(--raise); color: var(--ink); border-color: var(--line); }
html[data-mode="dark"] input::placeholder, html[data-mode="dark"] textarea::placeholder { color: var(--faint); }
html[data-mode="dark"] input:disabled, html[data-mode="dark"] select:disabled, html[data-mode="dark"] textarea:disabled { background: var(--surface); color: var(--faint); }
html[data-mode="dark"] option { background: var(--surface); color: var(--ink); }
html[data-mode="dark"] .ss-input { background-color: var(--raise); }
html[data-mode="dark"] .ss-list { background: var(--surface); border-color: var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, .55); }
html[data-mode="dark"] .ss-item { border-bottom-color: var(--line); }
html[data-mode="dark"] .ss-item.active { background: #243659; }

/* cards, rows, tables */
html[data-mode="dark"] a.card:hover { border-color: #3a4c6e; }
html[data-mode="dark"] .card .ico-box, html[data-mode="dark"] .rowlink .ico-box { background: var(--raise); color: var(--accent-ink); }
html[data-mode="dark"] .card.attn { border-color: #6b5524; }
html[data-mode="dark"] .card.alarm { border-color: #7a3a35; }
html[data-mode="dark"] .panel-head, html[data-mode="dark"] .rowlink { border-bottom-color: var(--line); }
html[data-mode="dark"] table.data th { color: var(--muted); background: var(--raise); }
html[data-mode="dark"] table.data td { border-bottom-color: var(--line); }
html[data-mode="dark"] table.data td .t { color: var(--ink); }
html[data-mode="dark"] .cal-day { border-right-color: var(--line); }
html[data-mode="dark"] .cal-ev.cancelled { background: var(--raise); }
html[data-mode="dark"] .crumbs .sep { color: var(--faint); }
html[data-mode="dark"] .badge.neutral { background: #232f45; color: var(--muted); }
html[data-mode="dark"] .confirm-box.danger { border-color: #7a3a35; }
html[data-mode="dark"] .flash.success { border-color: #2c5a41; }
html[data-mode="dark"] .flash.error { border-color: #7a3a35; }
html[data-mode="dark"] .flash.renewal-warn { background: #3a2f12; border-color: #7a6226; color: #f0d79a; }
html[data-mode="dark"] .chart-tip { background: #0a101b; border: 1px solid var(--line); color: var(--ink); }
html[data-mode="dark"] .reader-box.reading, html[data-mode="dark"] .ai-filling { background: #1f3a63 !important; }
html[data-mode="dark"] tr.ai-reading input[name$="-expiry_date"], html[data-mode="dark"] tr.ai-reading input[name$="-lot_number"] { background: #1f3a63 !important; }

/* the System health pages have their own greys */
html[data-mode="dark"] .health table.data th { color: var(--ink); background: var(--raise); }
html[data-mode="dark"] .health table.data td, html[data-mode="dark"] .health table.data td .t { color: var(--ink); }
html[data-mode="dark"] .health table.data td small, html[data-mode="dark"] .health .hintline, html[data-mode="dark"] .health .muted { color: var(--muted); }
html[data-mode="dark"] .health table.data tbody tr:nth-child(even) td { background: var(--raise); }
html[data-mode="dark"] .health table.data tbody tr:hover td { background: #22304d; }
html[data-mode="dark"] .health .subhead, html[data-mode="dark"] .health .health-card .foot, html[data-mode="dark"] .health .legend { color: var(--ink); }
html[data-mode="dark"] .health .health-card .detail { color: var(--ink); }
html[data-mode="dark"] .health .health-card .bar { background: #2a3750; }
html[data-mode="dark"] .health .stat.ok { background: #1a4128; color: #b8f0cf; }
html[data-mode="dark"] .health .stat.warn { background: #4a3a14; color: #f5dda0; }
html[data-mode="dark"] .health .stat.danger { background: #4d2320; color: #f8c0b9; }
html[data-mode="dark"] .health .stat.neutral { background: #26334a; color: var(--ink); }
html[data-mode="dark"] .health .health-chart .grid { stroke: #2a3750; }
html[data-mode="dark"] .health .health-chart .axis { stroke: var(--muted); }
html[data-mode="dark"] .health .health-chart text, html[data-mode="dark"] .health .health-chart .val { fill: var(--ink); }
html[data-mode="dark"] .health .health-chart .axis-title { fill: var(--muted); }
html[data-mode="dark"] .health .health-chart .val-halo { fill: var(--surface); stroke: var(--surface); }
html[data-mode="dark"] .health .health-chart .avg.cpu, html[data-mode="dark"] .health .health-chart .cmp-avg.this { stroke: #7fb2ee; }
html[data-mode="dark"] .health .health-chart .avg-label.cpu, html[data-mode="dark"] .health .health-chart .cmp-avg-label.this { fill: #7fb2ee; }
html[data-mode="dark"] .health .health-chart .avg.mem { stroke: #b3c0cc; }
html[data-mode="dark"] .health .health-chart .avg-label.mem { fill: #b3c0cc; }
html[data-mode="dark"] .health .legend .sw.avgline { border-top-color: var(--muted); }
html[data-mode="dark"] .health .health-chart .cmp-dot.this, html[data-mode="dark"] .health .health-chart .cmp-dot.prev { stroke: var(--surface); }

/* a few templates write a colour straight on the element */
html[data-mode="dark"] [style*="background:#fff;"], html[data-mode="dark"] [style*="background: #fff;"], html[data-mode="dark"] [style*="background:#fff\""] { background: var(--surface) !important; }
html[data-mode="dark"] [style*="color:#1e2a3a"] { color: var(--ink) !important; }
html[data-mode="dark"] [style*="background:#fef2f2"], html[data-mode="dark"] [style*="background:#f6d6d2"], html[data-mode="dark"] [style*="background: #f6d6d2"] { background: var(--danger-bg) !important; }
html[data-mode="dark"] [style*="color:#b91c1c"], html[data-mode="dark"] [style*="color:#b42318"], html[data-mode="dark"] [style*="color: #b42318"] { color: var(--danger-ink) !important; }
html[data-mode="dark"] [style*="color:#7f1d1d"] { color: var(--danger-ink) !important; }
html[data-mode="dark"] [style*="color:#15803d"] { color: var(--ok-ink) !important; }
html[data-mode="dark"] [style*="border-color:#e7c1bc"] { border-color: #7a3a35 !important; }

/* pictures that are drawn for a white page (documents, signatures, stamps) keep a white sheet behind them */
html[data-mode="dark"] .doc-sheet, html[data-mode="dark"] .signature-box, html[data-mode="dark"] img.paper { background: #fff; }
}
