/* H3DataVault - web interface */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #dfe3e9;
  --text: #1a1f26;
  --muted: #5d6877;
  --accent: #2f5fd0;
  --accent-contrast: #ffffff;
  --ok: #1d8348;
  --warn: #a86a12;
  --err: #c0392b;
  --info: #2f5fd0;
  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%);
  --gutter: max(16px, calc((100% - 1200px) / 2));
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1318;
    --surface: #161b22;
    --surface-2: #1d242d;
    --border: #2a323d;
    --text: #e5e9ef;
    --muted: #97a2b0;
    --accent: #7da2ff;
    --accent-contrast: #0f1318;
    --ok: #4cc38a;
    --warn: #e3a94f;
    --err: #f07167;
    --info: #7da2ff;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
code, pre { font-family: var(--mono); }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err-text { color: var(--err); }
.warn-text { color: var(--warn); }
.break { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); margin: 4px 0; }

/* --- Top bar & tabs --- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding-block: 12px;
  padding-inline: var(--gutter);
  background: var(--surface);
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-logo { flex: none; width: 30px; height: 30px; }
.brand-name { font-weight: 700; font-size: 16px; }
.version { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.topbar-side { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.user { color: var(--muted); }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  scrollbar-width: none;
  padding-inline: var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tabs button {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  padding: 10px 12px;
  white-space: nowrap;
  cursor: pointer;
}

.tabs button:hover { color: var(--text); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Layout --- */

main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-block: 20px 48px;
  padding-inline: var(--gutter);
}

.view, .stack { display: flex; flex-direction: column; gap: 16px; }

.card {
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 16px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 12px;
}

.tile {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tile-label, .tile-sub { color: var(--muted); font-size: 12.5px; }
.tile-value { margin-top: 2px; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile.err .tile-value { color: var(--err); }

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.stack p { margin: 6px 0 0; }

/* --- Badges & bars --- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: color-mix(in srgb, currentColor 13%, transparent);
}

.badge.ok { color: var(--ok); }
.badge.err { color: var(--err); }
.badge.warn { color: var(--warn); }
.badge.info { color: var(--info); }
.badge.muted { color: var(--muted); }

.bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-2); }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.bar.warn > span { background: var(--warn); }
.bar.crit > span { background: var(--err); }

/* --- Tables --- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th, td {
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-size: 12.5px; font-weight: 500; white-space: nowrap; }
th.num, td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

/* --- Alerts --- */

.alert { padding: 12px 14px; border: 1px solid; border-radius: var(--radius); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

.alert.warn {
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, var(--surface));
}

.alert.warn strong { color: var(--warn); }

.alert.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  background: color-mix(in srgb, var(--ok) 9%, var(--surface));
}

#config-errors { margin: 12px 0; }

.test-result { margin-top: 14px; padding: 10px 14px; border: 1px solid; border-radius: var(--radius); }
.test-result p { margin: 4px 0 0; }

.test-result.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  background: color-mix(in srgb, var(--ok) 9%, var(--surface));
}

.test-result.err {
  color: var(--err);
  border-color: color-mix(in srgb, var(--err) 40%, transparent);
  background: color-mix(in srgb, var(--err) 9%, var(--surface));
}

.conn {
  padding: 8px 12px;
  color: var(--err);
  border: 1px solid color-mix(in srgb, var(--err) 40%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--err) 10%, var(--surface));
}

/* --- Forms & buttons --- */

.form-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }

label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; }
label.check { flex-direction: row; align-items: center; gap: 8px; padding-bottom: 8px; color: var(--text); font-size: 14px; }

select, textarea, input:not([type]), input[type="password"], input[type="text"],
input[type="url"], input[type="number"] {
  min-width: 0;
  padding: 7px 10px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.form-row select { min-width: 200px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

.config-panel { display: flex; flex-direction: column; gap: 16px; }
.config-raw { margin-top: 10px; }
.config-raw summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.config-raw .code { margin-top: 8px; }

.settings-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px 14px;
  align-items: end;
}
.settings-wide { grid-column: 1 / -1; }
.settings-form textarea { min-width: 0; padding: 7px 10px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; resize: vertical; }
.settings-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; margin-top: 4px; }

.weekday-field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; }
.weekday-boxes { display: flex; flex-wrap: wrap; gap: 4px 12px; }

.btn {
  padding: 7px 14px;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}

.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { color: var(--accent-contrast); background: var(--accent); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, black); }
.btn.danger { color: var(--err); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }

.link { padding: 0; font: inherit; color: var(--accent); background: none; border: 0; cursor: pointer; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* --- Scheduler facts --- */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 12px 20px;
  margin: 0;
}

.facts dt { color: var(--muted); font-size: 12.5px; }
.facts dd { margin: 2px 0 0; font-weight: 500; }

/* --- Logs & code --- */

.logs, .code {
  max-height: 65vh;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.code { margin: 0; padding: 12px; }

.log-row {
  display: grid;
  grid-template-columns: auto 6em auto 1fr;
  gap: 10px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border);
}

.log-row:last-child { border-bottom: 0; }
.log-row time, .log-src { color: var(--muted); white-space: nowrap; }
.log-level { font-weight: 600; }
.lvl-info .log-level { color: var(--info); }
.lvl-warning .log-level { color: var(--warn); }
.lvl-error .log-level, .lvl-critical .log-level { color: var(--err); }
.log-msg { overflow-wrap: anywhere; }
.logs .empty { padding: 8px 10px; }

@media (max-width: 640px) {
  .log-row { grid-template-columns: auto 1fr; gap: 2px 10px; }
  .log-src { display: none; }
  .log-msg { grid-column: 1 / -1; }
}

/* --- Toasts --- */

.toasts {
  position: fixed;
  inset: auto 16px 16px 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: min(420px, 100%);
  padding: 10px 14px;
  color: var(--bg);
  background: var(--text);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 18%);
  pointer-events: auto;
}

.toast.err { color: #fff; background: var(--err); }

/* --- Login --- */

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 28px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.login-brand { margin-bottom: 20px; text-align: center; }
.login-logo { display: block; width: 88px; height: 88px; margin: 0 auto; }
.login-brand h1 { margin-top: 6px; font-size: 20px; }
.login-brand p { margin: 2px 0 0; }

#login-form { display: flex; flex-direction: column; gap: 14px; }
#login-form input { padding: 9px 12px; font-size: 15px; }
.form-error { margin: 0; color: var(--err); font-size: 13px; }

/* --- Top bar: À propos (far right) --- */

.btn.about-btn { font-weight: 600; }
.btn.about-btn.active { color: var(--accent-contrast); background: var(--accent); border-color: var(--accent); }
a.btn { display: inline-block; text-decoration: none; }
.actions-inline { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; white-space: nowrap; }

/* --- Cockpit (instrument panel: dark in both themes) --- */

.cockpit {
  --panel: #1a1a19;
  --well: #10100f;
  --rim: #2f2f2b;
  --ink: #ecebe6;
  --ink-2: #a9a79e;
  --ink-3: #75736c;
  --st-ok: #0ca30c;
  --st-warn: #fab219;
  --st-crit: #d03b3b;
  --st-info: #6cb6ff;
  --st-off: #4a4944;
  --screw: radial-gradient(circle, #5a5953 0 2px, #2b2b28 2.5px 4px, transparent 4.5px);

  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 22px 22px;
  color: var(--ink);
  background:
    var(--screw) 4px 4px / 12px 12px no-repeat,
    var(--screw) calc(100% - 4px) 4px / 12px 12px no-repeat,
    var(--screw) 4px calc(100% - 4px) / 12px 12px no-repeat,
    var(--screw) calc(100% - 4px) calc(100% - 4px) / 12px 12px no-repeat,
    linear-gradient(180deg, #222220 0%, var(--panel) 60%);
  border: 1px solid #0b0b0a;
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 6%), 0 2px 10px rgb(0 0 0 / 22%);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.panel-btn {
  padding: 3px 9px;
  font: inherit;
  color: var(--ink-2);
  background: var(--well);
  border: 1px solid var(--rim);
  border-radius: 5px;
  cursor: pointer;
}

.panel-btn:hover:not(:disabled) { color: var(--ink); }
.panel-btn:disabled { opacity: .5; }

/* Annunciator lamps: icon + label + state text, never color alone */
.annunciator { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 128px), 1fr)); gap: 8px; }

.lamp {
  --tone: var(--st-off);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 58px;
  padding: 8px 10px 8px 14px;
  overflow: hidden;
  background: var(--well);
  border: 1px solid var(--rim);
  border-radius: 6px;
}

/* Un voyant qui navigue est un <button> : on neutralise l'apparence native du
   bouton et on signale qu'il est cliquable */
.lamp.actionable {
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  transition: background-color .12s ease, transform .12s ease;
}

.lamp.actionable:hover {
  background: var(--surface-2);
}

.lamp.actionable:active {
  transform: translateY(1px);
}

.lamp.actionable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lamp.actionable::after {
  content: "›";
  position: absolute;
  top: 6px;
  right: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  opacity: .5;
}

.lamp.actionable:hover::after {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .lamp.actionable { transition: none; }
  .lamp.actionable:active { transform: none; }
}

.lamp::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--tone);
  opacity: .35;
}

.lamp-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.lamp-icon { width: 12px; font-size: 12px; line-height: 1; text-align: center; color: var(--tone); }
.lamp-state { font-size: 12.5px; color: var(--ink-3); }
.lamp.ok { --tone: var(--st-ok); }
.lamp.warn { --tone: var(--st-warn); }
.lamp.crit { --tone: var(--st-crit); }
.lamp.info { --tone: var(--st-info); }

.lamp:not(.off) {
  background: color-mix(in srgb, var(--tone) 12%, var(--well));
  border-color: color-mix(in srgb, var(--tone) 55%, var(--rim));
  box-shadow: 0 0 14px color-mix(in srgb, var(--tone) 28%, transparent),
              inset 0 0 10px color-mix(in srgb, var(--tone) 16%, transparent);
}

.lamp:not(.off)::before { opacity: 1; box-shadow: 0 0 8px var(--tone); }
.lamp:not(.off) .lamp-head { color: var(--ink); }
.lamp:not(.off) .lamp-state { color: var(--ink-2); }
.lamp.master .lamp-head { font-size: 12.5px; }
.lamp.master.crit, .lamp.master.warn { animation: lamp-flash 1.2s steps(1) infinite; }
.lamp.info .lamp-icon { animation: lamp-pulse 1.4s ease-in-out infinite; }

@keyframes lamp-flash {
  50% { background: var(--well); box-shadow: none; }
}

@keyframes lamp-pulse {
  50% { opacity: .3; }
}

/* Gauges */
.instruments { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 176px), 1fr)); gap: 12px; }

.gauge {
  margin: 0;
  padding: 10px 10px 12px;
  text-align: center;
  background: var(--well);
  border: 1px solid var(--rim);
  border-radius: 10px;
}

.gauge-dial { display: block; width: 100%; max-width: 220px; height: auto; margin: 0 auto; }
.g-bezel { fill: #262624; stroke: #3d3d38; stroke-width: 2; }
.g-face { fill: #0b0b0a; }
.g-zone { fill: none; stroke-width: 7; }
.g-zone.ok { stroke: var(--st-ok); }
.g-zone.warn { stroke: var(--st-warn); }
.g-zone.crit { stroke: var(--st-crit); }
.g-tick { stroke: #7d7b73; stroke-width: 1.2; }
.g-tick.major { stroke: #d9d7d0; stroke-width: 2; }
.g-num { font-family: var(--mono); font-size: 10px; text-anchor: middle; fill: var(--ink-2); }
.g-needle { transform-box: view-box; transform-origin: 100px 100px; transition: transform .9s cubic-bezier(.3, 1.35, .5, 1); }
.g-needle path { fill: #f3f2ed; }
.g-needle.parked path { fill: #6f6d66; }
.g-hub { fill: #2c2c29; stroke: #f3f2ed; stroke-width: 2; }
.g-value { font-size: 23px; font-weight: 650; text-anchor: middle; fill: var(--ink); }
.g-unit { font-size: 10.5px; text-anchor: middle; fill: var(--ink-2); }
.g-flag rect { fill: var(--st-crit); }
.g-flag text { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-anchor: middle; fill: #fff; }

.gauge figcaption { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 4px; }
.gauge-label { font-size: 11.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.gauge-status { --tone: var(--st-off); display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-2); }
.gauge-status .dot { color: var(--tone); }
.gauge-status.ok { --tone: var(--st-ok); }
.gauge-status.warn { --tone: var(--st-warn); }
.gauge-status.crit { --tone: var(--st-crit); }

/* Digital readouts */
.readouts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 8px; }

.readout {
  min-width: 0;
  padding: 8px 12px;
  background: #080808;
  border: 1px solid var(--rim);
  border-radius: 6px;
  box-shadow: inset 0 2px 6px rgb(0 0 0 / 60%);
}

.readout-label { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }

.readout-value {
  margin-top: 2px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 21px;
  letter-spacing: .04em;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--st-info);
  text-shadow: 0 0 8px color-mix(in srgb, var(--st-info) 45%, transparent);
}

.readout-sub { overflow: hidden; font-size: 11.5px; white-space: nowrap; text-overflow: ellipsis; color: var(--ink-2); }

@media (max-width: 480px) {
  .readout-value { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .lamp, .lamp-icon { animation: none !important; }
  .g-needle { transition: none; }
}

/* --- Dialogs & forms --- */

dialog {
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgb(0 0 0 / 30%);
}

dialog::backdrop { background: rgb(0 0 0 / 45%); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dialog-head, .dialog-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; }
.dialog-head { justify-content: space-between; border-bottom: 1px solid var(--border); }
.dialog-foot { justify-content: flex-end; border-top: 1px solid var(--border); }
.dialog-body { display: grid; gap: 14px; padding: 16px 18px; overflow: auto; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid label input:not([type="checkbox"]), .form-grid label select, .form-grid label textarea { width: 100%; }
.form-grid label.check { padding-bottom: 0; }
.form-grid .field-action { display: flex; gap: 10px; align-items: center; margin-top: -4px; }
.form-grid .test-result { margin-top: 0; }

.folder-tree {
  max-height: 280px;
  padding: 6px 8px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.folder-tree .node { display: flex; gap: 4px; align-items: center; border-radius: 5px; }
.folder-tree .node:hover { background: var(--surface-2); }

.folder-tree .twisty {
  flex: none;
  width: 20px;
  padding: 2px 0;
  font: inherit;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  background: none;
  border: 0;
  cursor: pointer;
}

.folder-tree .twisty.leaf { color: var(--border); cursor: default; }

.folder-tree .name {
  flex: 1;
  padding: 4px 4px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  background: none;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.folder-tree .node.lib > .name { font-weight: 600; }
.folder-tree .count { flex: none; padding-right: 6px; color: var(--muted); font-size: 11.5px; }

/* Selected: this folder is written in the Inclusions box */
.folder-tree .node.picked { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.folder-tree .node.picked > .name { color: var(--accent); font-weight: 600; }
.folder-tree .node.picked > .name::after { content: " ✓"; }
td .break { display: inline-block; min-width: 14em; }
textarea { min-height: 70px; font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.hint { margin: 0; color: var(--muted); font-size: 12px; }
.fold { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.fold summary { font-weight: 500; cursor: pointer; }
.fold[open] summary { margin-bottom: 10px; }
.fold > .hint { margin-bottom: 10px; }

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
}

/* --- À propos --- */

.about-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.about-logo { flex: none; width: 88px; height: 88px; }
.about-intro { flex: 1; min-width: min(100%, 260px); }
.about-intro h1 { font-size: 22px; }
.about-version { margin-left: 6px; font-size: 14px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.about-desc { max-width: 72ch; margin: 6px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; }

.chip {
  padding: 2px 10px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

/* Les onglets passent à la ligne au lieu de défiler : avec une barre de défilement
   masquée, ceux qui dépassaient devenaient inatteignables à la souris */
.subtabs { display: flex; flex-wrap: wrap; gap: 2px; margin: 16px 0 4px; border-bottom: 1px solid var(--border); }

.subtabs button {
  padding: 8px 10px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.subtabs button:hover { color: var(--text); }
.subtabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.about-panel { max-width: 90ch; }
.about-panel h3 { margin: 18px 0 6px; font-size: 14px; font-weight: 600; }
.about-panel ul, .about-panel ol { margin: 6px 0; padding-left: 22px; }
.about-panel li { margin: 4px 0; }
.about-panel .table-wrap { margin: 6px 0; }
.about-panel a { color: var(--accent); }
.cl-version { padding: 4px 0 10px; border-bottom: 1px solid var(--border); }
.cl-version:last-child { border-bottom: 0; }
.cl-section h4 { margin: 10px 0 2px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* Planning des sources : regroupées par heure de départ effective */
.slot {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 16px;
  padding: 10px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

.slot:last-child { border-bottom: 0; }

.slot-time {
  flex: none;
  min-width: 150px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.slot-time strong { font-size: 16px; }

.slot-sources { display: flex; flex-wrap: wrap; gap: 6px; }

.slot-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

.slot-chip:hover { border-color: var(--accent); color: var(--accent); }
.slot-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Source désactivée : visible, mais clairement hors planning */
.slot-chip.off { color: var(--muted); text-decoration: line-through; opacity: .65; }

.chip-own { font-size: 10px; }

/* Explorateur d'archives : arborescence dense mais lisible */
.tree {
  max-height: 60vh;
  margin-top: 12px;
  overflow: auto;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.ex-row {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 30px;
  padding-right: 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
}

.ex-row:last-child { border-bottom: 0; }
.ex-row:hover { background: var(--surface-2); }

/* Repère vertical par niveau : rattache visuellement un fichier à son dossier */
.ex-guide {
  flex: none;
  align-self: stretch;
  width: 18px;
  border-right: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.ex-twisty {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  font: inherit;
  font-size: 10px;
  line-height: 22px;
  color: var(--muted);
  text-align: center;
  background: none;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

button.ex-twisty:hover { color: var(--text); background: var(--border); }
span.ex-twisty { cursor: default; }

.ex-icon { flex: none; width: 22px; font-size: 13px; text-align: center; }

.ex-name {
  flex: 1;
  min-width: 0;
  padding: 5px 6px;
  overflow: hidden;
  font: inherit;
  color: var(--text);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: 0;
  border-radius: 5px;
  cursor: pointer;
}

.ex-name:hover { color: var(--accent); }
.ex-row.folder > .ex-name { font-weight: 500; }
.ex-row.root > .ex-name { font-weight: 600; }

.ex-count {
  flex: none;
  padding-right: 12px;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}

.ex-size {
  flex: none;
  min-width: 72px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Origine incrémentale : discret, mais la version affichée en dépend */
.ex-tag {
  flex: none;
  margin-right: 8px;
  padding: 1px 6px;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .02em;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px;
}

/* Sélection : barre d'accent à gauche, lisible même sur une longue liste */
.ex-row.picked {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.ex-row.picked > .ex-name { color: var(--accent); font-weight: 600; }

@media (max-width: 720px) {
  .ex-count { display: none; }
  .ex-size { min-width: 58px; }
}

/* Applet de couverture : une cellule par sauvegarde, lisible d'un coup d'oeil */
.cov-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.cov-score strong { font-size: 22px; }

.cov-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-bottom: 10px;
}

.cov-cell {
  width: 18px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  background: var(--tone, var(--st-off));
  transition: transform .1s ease;
}

.cov-cell.ok { --tone: var(--st-ok); }
.cov-cell.crit { --tone: var(--st-crit); }
.cov-cell.muted { --tone: var(--border); }
.cov-cell:hover { transform: translateY(-2px); }
.cov-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cov-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

.cov-key { display: inline-flex; align-items: center; gap: 6px; }

.cov-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--tone, var(--st-off));
}

.cov-dot.ok { --tone: var(--st-ok); }
.cov-dot.crit { --tone: var(--st-crit); }
.cov-dot.muted { --tone: var(--border); }

@media (prefers-reduced-motion: reduce) {
  .cov-cell { transition: none; }
  .cov-cell:hover { transform: none; }
}

/* Mention de bas de page : présente, sans peser visuellement */
.ai-note {
  margin: 20px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
}
