/* Theme: light is the default; data-theme="dark" forces dark; data-theme="auto" (or none) follows the system.
   Every colour is a variable defined here, once per theme. The dark set appears twice only because CSS cannot
   share it between the explicit choice and the system preference: keep the two blocks identical (a test checks). */
:root {
  color-scheme: light;
  --bg: #ffffff; --fg: #15171a; --muted: #5f6670; --card: #f5f6f8; --line: #e3e6ea;
  --brand: #d71920; --brand-fg: #ffffff; --ok: #2e9e5b; --warn: #b7791f; --bad: #c53030; --warn-bar: #e0a800;
  --radius: 10px; --max: 1040px;
  --banner-light: #f3f3f3; --banner-dark: #202020;
  --on-fg: #146c3a; --on-bg: #dcf3e5; --off-fg: #a61b1b; --off-bg: #fde3e3; --mid-fg: #8a5a00; --mid-bg: #fff0c2; --plain-fg: #4a515b; --plain-bg: #e8eaee;
  --start-bg: #1d7a43; --start-fg: #ffffff; --stop-bg: #c53030; --stop-fg: #ffffff; --restart-bg: #2563eb; --restart-fg: #ffffff;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111317; --fg: #eceef1; --muted: #a2a9b3; --card: #1b1e24; --line: #2c3038; --brand: #ff3b42; --ok: #3fb675; --warn: #e0a83a; --bad: #f06a6a;
  --on-fg: #6fdc9b; --on-bg: #12341f; --off-fg: #ff8e8e; --off-bg: #3d1517; --mid-fg: #f3c64f; --mid-bg: #3a2d0a; --plain-fg: #c3c9d2; --plain-bg: #2a2e36;
  --start-bg: #3fb675; --start-fg: #04170c; --stop-bg: #f06a6a; --stop-fg: #1c0505; --restart-bg: #6aa5ff; --restart-fg: #04122b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --bg: #111317; --fg: #eceef1; --muted: #a2a9b3; --card: #1b1e24; --line: #2c3038; --brand: #ff3b42; --ok: #3fb675; --warn: #e0a83a; --bad: #f06a6a;
    --on-fg: #6fdc9b; --on-bg: #12341f; --off-fg: #ff8e8e; --off-bg: #3d1517; --mid-fg: #f3c64f; --mid-bg: #3a2d0a; --plain-fg: #c3c9d2; --plain-bg: #2a2e36;
    --start-bg: #3fb675; --start-fg: #04170c; --stop-bg: #f06a6a; --stop-fg: #1c0505; --restart-bg: #6aa5ff; --restart-fg: #04122b;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.55 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }
a { color: var(--brand); }
main { max-width: var(--max); margin: 0 auto; padding: 24px 16px 48px; }
h1, h2, h3 { line-height: 1.2; }
.muted { color: var(--muted); font-size: .92em; }
.banner { display: flex; gap: 16px; justify-content: center; align-items: center; padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); font-size: .95em; flex-wrap: wrap; }
.top { display: flex; align-items: center; justify-content: space-between; max-width: var(--max); margin: 0 auto; padding: 12px 16px; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25em; color: var(--fg); text-decoration: none; }
.top nav { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.top nav form { display: inline; margin: 0; }
.top nav .linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--fg); cursor: pointer; }
.top nav .linkbtn:hover { color: var(--brand); }
.top nav a { color: var(--fg); text-decoration: none; }
.top nav a:hover { color: var(--brand); }
.top nav .lang { border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; line-height: 1.4; }
.top nav .theme-toggle { border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; line-height: 1.4; background: none; color: var(--fg); font: inherit; cursor: pointer; }
.top nav .theme-toggle:hover { color: var(--brand); }
.top nav .theme-toggle[hidden] { display: none; }
.hero { text-align: center; padding: 32px 0 16px; }
.hero h1 { font-size: 2.6em; margin: 8px 0 0; }
.hero .lead { font-size: 1.35em; margin: 4px 0 12px; }
.btn { display: inline-block; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 18px; background: var(--card); color: var(--fg); text-decoration: none; font: inherit; cursor: pointer; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }
.btn.danger { background: var(--stop-bg); border-color: var(--stop-bg); color: var(--stop-fg); }
.btn.big { font-size: 1.15em; padding: 14px 28px; margin-top: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin-top: 0; }
.shot { display: block; max-width: 100%; margin: 16px auto; border-radius: var(--radius); border: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.doc { max-width: 760px; margin: 0 auto; }
.bottom { max-width: var(--max); margin: 0 auto; padding: 24px 16px; border-top: 1px solid var(--line); display: grid; gap: 6px; text-align: center; font-size: .92em; }
.bottom img { vertical-align: middle; }
form.stack { display: grid; gap: 12px; max-width: 420px; }
form.stack label { display: grid; gap: 4px; font-weight: 600; }
/* admin list filters: one row of fields, the button last */
form.stack.filters { max-width: none; align-items: end; }
form.stack.filters-2 { grid-template-columns: 2fr 1fr auto; }
form.stack.filters-4 { grid-template-columns: 2fr 1fr 1fr 1fr auto; }
form.inline { display: inline; }
.qr { max-width: 220px; }
input[type=email], input[type=password], input[type=text], select { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); }
/* "form.stack label" is a grid; a checkbox label must stay one row: box, then text */
form.stack label.check, .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin: 4px 0 0; flex: none; width: 18px; height: 18px; accent-color: var(--brand); }
.msg { border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--line); background: var(--card); }
.msg.ok { border-color: var(--ok); }
.msg.bad { border-color: var(--bad); }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list td.sample { overflow-wrap: anywhere; font-family: ui-monospace, Consolas, monospace; font-size: .85em; }
.tag { display: inline-block; border-radius: 999px; padding: 0 8px; font-size: .85em; border: 1px solid var(--line); }
.tag.ok { border-color: var(--ok); color: var(--ok); }
.tag.bad { border-color: var(--bad); color: var(--bad); }
.tag.warn { border-color: var(--warn); color: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.stat b { display: block; font-size: 1.6em; }
.chart { width: 100%; height: auto; }
.chart .a { stroke: var(--brand); }
.chart .b { stroke: var(--muted); }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid line { stroke: var(--line); }

/* Meus drives */
.wide { max-width: var(--max); margin: 0 auto; }
.msg.warn { border-color: var(--warn); }
.msg.notice { white-space: pre-line; margin-bottom: 16px; }
.pc { margin: 16px 0; }
.pc h2 { margin: 0 0 4px; font-size: 1.3em; }
.pc .presence { margin: 4px 0 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
table.drives td { vertical-align: middle; }
/* Status pills: green = on, red = off or a problem, yellow = in between (see Site/StatePill.cs) */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 1px 10px; font-size: .9em; font-weight: 600; line-height: 1.5; white-space: nowrap; color: var(--plain-fg); background: var(--plain-bg); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.pill.on { color: var(--on-fg); background: var(--on-bg); }
.pill.off { color: var(--off-fg); background: var(--off-bg); }
.pill.mid { color: var(--mid-fg); background: var(--mid-bg); }
.cmd { margin-top: 4px; }
.space { width: 120px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
/* the bar is an SVG rect sized by its width attribute: no inline style, so style-src stays 'self' */
.space svg { display: block; width: 100%; height: 100%; }
.space rect { fill: var(--ok); }
.space.warn rect { fill: var(--warn-bar); }
.space.bad rect { fill: var(--bad); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { margin: 0; }
.actions .btn { padding: 6px 12px; }
.actions .btn-start { background: var(--start-bg); border-color: var(--start-bg); color: var(--start-fg); }
.actions .btn-stop { background: var(--stop-bg); border-color: var(--stop-bg); color: var(--stop-fg); }
.actions .btn-restart { background: var(--restart-bg); border-color: var(--restart-bg); color: var(--restart-fg); }
/* A disabled command drops its colour: muted, "not allowed" cursor; the title still gives the reason */
.actions .btn:disabled { background: var(--card); border-color: var(--line); color: var(--muted); opacity: .75; cursor: not-allowed; }
.small { font-size: .85em; max-width: 260px; }
@media (max-width: 640px) {
  table.drives, table.drives tbody, table.drives tr, table.drives td { display: block; width: 100%; }
  table.drives thead { display: none; }
  table.drives tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin: 10px 0; background: var(--bg); }
  table.drives td { border: 0; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.drives td::before { content: attr(data-label); color: var(--muted); text-align: left; flex: none; }
  .actions .btn { padding: 10px 16px; }
}

/* Status page (status.pooldrive.win, /status) */
.status-page .top, .status-page .bottom, main.status { max-width: 760px; }
.status-title { margin: 8px 0 12px; }
.status-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 20px; }
.status-summary .pill { font-size: 1.05em; padding: 4px 14px; white-space: normal; }
.component { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0 0 14px; }
.component-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.component-head h2 { margin: 0; font-size: 1.15em; }
.component-head p { margin: 2px 0 0; }
.component-head .pill { flex: none; }
.status-refresh { text-align: center; }
/* Day bars: one block per day, oldest first (see Site/DayBars.cs) */
.daybar { display: flex; gap: 1px; width: 100%; }
.daybar .d { flex: 1; min-width: 0; height: 28px; border-radius: 2px; background: var(--line); }
.daybar .d.ok { background: var(--ok); }
.daybar .d.mid { background: var(--warn-bar); }
.daybar .d.off { background: var(--bad); }
.daybar-labels { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: .8em; }

/* Availability history (Meus drives, admin user page) */
.history h2 { margin-bottom: 4px; }
.history-pc { margin: 12px 0; }
.history-drive { padding: 12px 0; border-top: 1px solid var(--line); }
.history-drive:first-of-type { border-top: 0; padding-top: 0; }
.history-drive h4 { margin: 0 0 4px; }
.history-up { margin: 0 0 8px; font-weight: 600; }
table.outages { margin-top: 10px; }
table.outages caption { text-align: left; padding: 0 0 4px; }
.history-cell { min-width: 220px; }
@media (max-width: 640px) {
  table.outages, table.outages tbody, table.outages tr, table.outages td { display: block; width: 100%; }
  table.outages thead { display: none; }
  table.outages caption { display: block; width: 100%; }
  table.outages tr { border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; margin: 8px 0; background: var(--bg); }
  table.outages td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.outages td::before { content: attr(data-label); color: var(--muted); text-align: left; flex: none; }
}

/* release notes tables: alignment as classes (the CSP forbids style attributes) */
.ta-left { text-align: left; }
.ta-center { text-align: center; }
.ta-right { text-align: right; }

/* Drive-type icons (Site/DriveIcons.cs): self-drawn SVGs that carry their own chip, so they read on both themes */
.drive-icon { width: 22px; height: 22px; vertical-align: -5px; margin-right: 4px; border-radius: 5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
table.drives th.ico, table.drives td.ico { width: 1%; padding-right: 0; }
table.drives td.ico .drive-icon { margin: 0; }
.history-drive h4 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.history-drive h4 .drive-icon { margin: 0; }
@media (max-width: 640px) {
  table.drives tr { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
  table.drives td { grid-column: 1 / -1; }
  table.drives td.ico { grid-column: 1; grid-row: 1; width: auto; padding: 4px 0; }
  table.drives td.ico + td { grid-column: 2; grid-row: 1; text-align: left; }
  table.drives td.ico + td::before { display: none; }
}
.banner-card { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.banner-card.on { border-color: var(--ok); border-width: 2px; }
.banner-preview { padding: 8px; border-radius: var(--radius); }
.banner-preview.light { background: var(--banner-light); }
.banner-preview.dark { background: var(--banner-dark); }
.banner-preview img { display: block; height: 64px; max-width: 420px; object-fit: contain; }
