/* ==================== Fondations et palette ==================== */

:root {
  color-scheme: dark;
  --bg: #0b1019;
  --panel: #131c29;
  --line: #293548;
  --text: #edf3fc;
  --muted: #a0afc3;
  --green: #58dfb0;
  --orange: #ffc372;
  --red: #ff8b96;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(ellipse at 80% 0, #15253a 0, transparent 55%), var(--bg);
  color: var(--text);
  font:
    14px/1.45 system-ui,
    -apple-system,
    sans-serif;
  font-variant-numeric: tabular-nums;
}
/* ==================== Contrôles et boutons ==================== */

button,
input,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 16px;
  color: var(--text);
  background: #1c293b;
}
button:hover {
  background: #293e54;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}
.primary {
  background: var(--green);
  color: #09251d;
  border-color: var(--green);
  font-weight: 700;
}
.primary:hover {
  background: #91f2cf;
}
/* ==================== Structure du tableau de bord ==================== */

.dashboard {
  max-width: 1560px;
  padding: 28px 36px 16px;
  margin: auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.brand {
  font-weight: 750;
  letter-spacing: 0.02em;
  color: var(--green);
  font-size: 14px;
}
.brand span {
  color: var(--muted);
  font-weight: 400;
}
h1 {
  font-size: 28px;
  letter-spacing: -0.035em;
  margin: 6px 0;
  overflow-wrap: anywhere;
}
p {
  margin: 5px 0;
  color: var(--muted);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.icon {
  width: 44px;
  height: 44px;
  font-size: 25px;
  padding: 0;
  flex-shrink: 0;
}
.status {
  font-size: 14px;
  font-weight: 650;
  padding: 10px 16px;
  border: 1px solid #2d6759;
  border-radius: 30px;
  background: #123b30;
  color: var(--green);
  white-space: nowrap;
}
.status.bad {
  color: var(--red);
  background: #381e2a;
  border-color: #683340;
}
.status.pending {
  color: var(--orange);
  background: #382c1d;
  border-color: #685035;
}
.subline {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  min-height: 18px;
}
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
}
.section-title h2 {
  font-size: 17px;
  margin: 0;
}
.section-title > span,
.eyebrow {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}
/* ==================== Mesures principales et barres ==================== */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.metric,
.app,
.detail {
  background: linear-gradient(130deg, #192435, #121c29);
  border: 1px solid var(--line);
  border-radius: 15px;
}
.metric {
  padding: 18px 20px;
}
.metric-title {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  gap: 5px;
}
.metric strong {
  display: block;
  font-size: 34px;
  letter-spacing: -0.04em;
  margin: 8px 0 12px;
  line-height: 1.1;
}
.metric strong small {
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
}
.metric p {
  font-size: 12px;
  margin-top: 10px;
  min-height: 18px;
}
.bar {
  display: block;
  width: 100%;
  height: 5px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #293548;
  accent-color: var(--green);
}
progress::-webkit-progress-bar {
  background: #293548;
  border-radius: 8px;
}
progress::-webkit-progress-value {
  background: var(--green);
  border-radius: 8px;
}
progress.warn::-webkit-progress-value {
  background: var(--orange);
}
progress.danger::-webkit-progress-value {
  background: var(--red);
}
progress::-moz-progress-bar {
  background: var(--green);
}
progress.warn::-moz-progress-bar {
  background: var(--orange);
}
progress.danger::-moz-progress-bar {
  background: var(--red);
}
/* ==================== Mesures secondaires ==================== */

.details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.detail {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.detail span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.detail strong {
  font-size: 14px;
  white-space: nowrap;
}
/* ==================== Cartes des applications ==================== */

.apps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.app {
  padding: 16px 18px;
  min-width: 0;
}
.app.bad {
  border-color: #74404a;
  background: linear-gradient(130deg, #30202d, #1d1c2b);
}
.app-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.app h3 {
  font-size: 15px;
  margin: 0;
  overflow-wrap: anywhere;
}
.dot {
  color: var(--green);
  font-size: 11px;
  white-space: nowrap;
}
.bad .dot {
  color: var(--red);
}
.app-measure {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin: 10px 0 5px;
  color: var(--muted);
}
.app-measure b {
  color: var(--text);
  font-weight: 600;
}
.app-foot {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.health {
  margin: 8px 0 0;
  color: var(--green);
  font-size: 11px;
}
.health.failed {
  color: var(--red);
}
/* ==================== Pied de page ==================== */

footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  padding-top: 4px;
}
.muted {
  color: var(--muted);
}
/* ==================== Panneau des réglages ==================== */

dialog {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0;
  height: 100dvh;
  max-height: 100dvh;
  width: 560px;
  max-width: 100%;
  border: 0;
  border-left: 1px solid var(--line);
  padding: 26px;
  background: #111b29;
  color: var(--text);
  overflow-y: auto;
}
dialog::backdrop {
  background: #0009;
  backdrop-filter: blur(3px);
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.drawer-head h2 {
  margin: 4px 0 14px;
  font-size: 24px;
}
label {
  display: block;
  font-size: 13px;
  color: #c3cfdf;
  margin: 14px 0;
}
input:not([type='checkbox']),
textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #3e4d63;
  border-radius: 8px;
  background: #0b1421;
  color: var(--text);
}
textarea {
  resize: vertical;
  min-height: 65px;
}
fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 16px 0;
}
legend {
  font-weight: 650;
}
fieldset label {
  margin: 6px 0;
}
.rule-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.rule-toggle {
  display: flex;
  gap: 10px;
  align-items: center;
}
input[type='checkbox'] {
  width: 19px;
  height: 19px;
  accent-color: var(--green);
}
.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  position: sticky;
  bottom: -26px;
  background: #111b29;
  padding: 16px 0;
}
.alert-log {
  max-height: 300px;
  overflow: auto;
  font-size: 12px;
}
.log-entry {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#settings-message,
#login-error {
  color: var(--orange);
  min-height: 20px;
}
/* ==================== Page de connexion ==================== */

.login-body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
}
.login-card {
  max-width: 420px;
  width: 100%;
  padding: 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
}
.login-symbol {
  font-size: 48px;
  color: var(--green);
  margin-top: 26px;
}
.login-card h1 {
  font-size: 34px;
  line-height: 1.15;
  margin: 14px 0;
}
.login-card form {
  margin: 26px 0;
}
.login-card button {
  width: 100%;
}
.login-card small {
  font-size: 11px;
  color: var(--muted);
}
/* ==================== Adaptation aux écrans PC de faible hauteur ==================== */

@media (min-width: 1024px) and (max-height: 800px) {
  .dashboard {
    padding: 20px 28px 12px;
    gap: 14px;
  }
  .metric {
    padding: 14px 18px;
  }
  .metric strong {
    font-size: 30px;
    margin: 7px 0 10px;
  }
  .app {
    padding: 12px 15px;
  }
  .app-head {
    margin-bottom: 8px;
  }
  .app-measure {
    margin-top: 7px;
  }
  .app-foot {
    margin-top: 8px;
    padding-top: 8px;
  }
  .details {
    gap: 8px;
  }
  .section-title {
    margin-bottom: 10px;
  }
  .apps {
    gap: 10px;
  }
}
/* ==================== Adaptation aux petits PC ==================== */

@media (max-width: 1100px) {
  .dashboard {
    padding: 24px;
  }
  .metric {
    padding: 16px;
  }
  .metric strong {
    font-size: 29px;
  }
}
/* ==================== Adaptation aux tablettes ==================== */

@media (max-width: 800px) {
  .metrics,
  .apps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dashboard {
    padding: 24px;
    gap: 20px;
  }
}
/* ==================== Adaptation aux téléphones ==================== */

@media (max-width: 540px) {
  .dashboard {
    padding: 20px 16px 14px;
    gap: 20px;
  }
  header {
    align-items: flex-start;
    position: relative;
  }
  .identity {
    max-width: calc(100% - 52px);
  }
  h1 {
    font-size: 26px;
    margin: 9px 0 5px;
  }
  .identity p {
    font-size: 12px;
  }
  .header-actions {
    display: contents;
  }
  .header-actions .icon {
    position: absolute;
    right: 0;
    top: 0;
  }
  .status {
    position: absolute;
    left: 0;
    top: 115px;
    font-size: 13px;
    padding: 7px 12px;
  }
  .subline {
    margin-top: 40px;
    display: block;
    font-size: 11px;
  }
  .subline span {
    display: block;
  }
  .brand {
    font-size: 12px;
  }
  .section-title h2 {
    font-size: 16px;
  }
  .metrics {
    gap: 10px;
  }
  .metric {
    padding: 14px;
  }
  .metric strong {
    font-size: 28px;
    margin: 9px 0 12px;
  }
  .metric-title {
    font-size: 11px;
  }
  .metric strong small {
    font-size: 12px;
  }
  .metric p {
    font-size: 10px;
    min-height: 15px;
    margin-top: 8px;
  }
  .details {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
  }
  .detail {
    padding: 10px;
    gap: 6px;
  }
  .detail span {
    font-size: 10px;
  }
  .detail strong {
    font-size: 11px;
  }
  .apps {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .app {
    padding: 14px 16px;
  }
  .app-head {
    margin-bottom: 8px;
  }
  .app-measure {
    margin-top: 7px;
  }
  .app-foot {
    margin-top: 10px;
  }
  .app h3 {
    font-size: 14px;
  }
  .section-title > span {
    font-size: 10px;
  }
  footer {
    font-size: 9px;
    padding-top: 4px;
  }
  dialog {
    width: 100%;
    padding: 20px;
  }
  .form-actions {
    bottom: -20px;
  }
  .login-card {
    padding: 26px;
  }
  .drawer-head h2 {
    font-size: 22px;
  }
}
/* Le tiroir mobile utilise le viewport entier, sans réserver le scroll du fond. */
html:has(dialog[open]),
body:has(dialog[open]) {
  overflow: hidden;
}
@media (max-width: 540px) {
  dialog {
    width: 100vw;
    max-width: 100vw;
  }
}
@media (max-width: 540px) {
  header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 14px;
  }
  .identity {
    max-width: 100%;
    min-width: 0;
  }
  .header-actions .icon {
    position: static;
    grid-column: 2;
    grid-row: 1;
    align-self: start;
  }
  .status {
    position: static;
    grid-column: 1/-1;
    justify-self: start;
  }
  .subline {
    margin-top: 0;
  }
}

/* ==================== Historique mémoire : bouton et tiroir ==================== */

.memory-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.memory-open {
  padding: 0;
  width: 24px;
  height: 22px;
  font-size: 16px;
  line-height: 1;
  color: var(--muted);
  border-color: transparent;
  background: transparent;
}
#memory-panel h2 {
  overflow-wrap: anywhere;
}
#memory-panel .drawer-head {
  gap: 12px;
}
.memory-trend {
  margin: 28px 0 22px;
  padding: 22px;
  background: #192838;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.memory-trend strong {
  display: block;
  margin: 9px 0;
  font-size: clamp(26px, 5vw, 36px);
  letter-spacing: -0.04em;
  color: var(--green);
}
.memory-trend strong.rising {
  color: var(--orange);
}
.memory-trend p {
  font-size: 12px;
}
.memory-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.memory-stats > div {
  padding: 14px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.memory-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.memory-stats strong {
  display: block;
  margin-top: 6px;
  font-size: 17px;
}
.memory-chart {
  margin-top: 28px;
}
.memory-chart h3 {
  font-size: 15px;
  margin: 0;
}
.memory-chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}
.memory-chart text {
  fill: var(--muted);
  font-size: 11px;
  font-family: inherit;
}
.memory-grid {
  stroke: var(--line);
  stroke-dasharray: 3 5;
}
.memory-line {
  stroke: var(--green);
  stroke-width: 2;
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
}
.memory-point {
  fill: var(--green);
}
#memory-info,
.memory-note {
  font-size: 12px;
  line-height: 1.6;
  margin-top: 14px;
}
.memory-note {
  color: var(--muted);
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
@media (max-width: 540px) {
  .memory-trend {
    margin-top: 22px;
    padding: 18px;
  }
  .memory-stats strong {
    font-size: 15px;
  }
}
@media (min-width: 541px) {
  #memory-panel .memory-trend {
    margin: 20px 0 16px;
    padding: 16px;
  }
  #memory-panel .memory-trend strong {
    font-size: 30px;
    margin: 8px 0;
  }
  #memory-panel .memory-chart {
    margin-top: 24px;
  }
  .memory-chart svg {
    max-height: 220px;
  }
}
