:root {
  --ink: #1a2422;
  --muted: #5d6b66;
  --paper: #f3efe4;
  --card: #fffaf2;
  --line: #d9d0c0;
  --lagoon: #1d6a64;
  --lagoon-deep: #14332f;
  --sand: #e7c98a;
  --ok: #1d7a4a;
  --warn: #9a4b22;
  --bad: #8d2d2d;
  --shadow: 0 12px 30px rgba(20, 51, 47, 0.08);
  color-scheme: light;
  font-family: "Segoe UI", "Avenir Next", "Nunito Sans", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(900px 280px at 10% -10%, rgba(231, 201, 138, 0.55), transparent 60%),
    linear-gradient(180deg, #efe6d4 0%, var(--paper) 220px);
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  align-items: end;
  padding: 22px 28px 8px;
}

.brand { margin-right: auto; }

.eyebrow {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.74rem;
  color: var(--lagoon);
}

h1, h2, h3 { font-family: Palatino, "Iowan Old Style", Georgia, serif; font-weight: 600; }

h1 { margin: 2px 0 0; font-size: 1.8rem; }

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

.tabs button, .refresh {
  border: 1px solid transparent;
  background: transparent;
  color: var(--lagoon-deep);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.tabs button[aria-current="page"] {
  background: var(--lagoon-deep);
  color: #f6f1e6;
}

.refresh {
  border-color: var(--line);
  background: var(--card);
}

.wrap { padding: 8px 28px 40px; max-width: 1180px; }

.banner, .card, .table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.banner {
  padding: 16px 18px;
  margin-bottom: 16px;
  border-left: 6px solid var(--sand);
}

.banner h2 { margin: 0 0 6px; font-size: 1.15rem; }
.banner p, .note { margin: 0; color: var(--muted); line-height: 1.45; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat { padding: 14px 16px; }
.stat span { display: block; color: var(--muted); font-size: 0.82rem; }
.stat strong { display: block; margin-top: 4px; font-size: 1.45rem; }

.section { margin-top: 18px; }
.section h2 { margin: 0 0 10px; font-size: 1.3rem; }

.ports {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.port { padding: 12px; }
.port b,
.port .mono,
.port em { display: block; }
.port em { color: var(--muted); font-style: normal; font-size: 0.86rem; margin-top: 2px; }

.toolbar { display: flex; gap: 10px; margin: 8px 0 12px; }
.toolbar input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: white;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
  background: #efe6d4;
}
.badge.ok { background: #d9f0e3; color: var(--ok); }
.badge.warn { background: #f8e4d4; color: var(--warn); }
.badge.bad { background: #f6dcdc; color: var(--bad); }
.badge.muted { color: var(--muted); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.equip, .vlan { padding: 14px 16px; }
.equip p, .vlan p { margin: 6px 0; }
.equip ul, .notes { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
code, .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.92em; }

.phase { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.empty { padding: 16px; color: var(--muted); }

.equip-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
  margin: 12px 0;
}
.equip-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}
.equip-form input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}
.equip-form button, .row-delete {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--lagoon);
  color: #f6f1e6;
  cursor: pointer;
}
.row-delete {
  background: transparent;
  color: var(--bad);
  border: 1px solid var(--line);
  padding: 6px 10px;
}
.form-error { color: var(--bad); margin: 8px 0; }
.form-error:empty { display: none; }
.form-ok { color: var(--ok); margin: 8px 0; }
.section h3 { margin: 16px 0 8px; font-size: 1.05rem; }

button, input, select { font: inherit; }
.session { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: 0.9rem; }

.equip-form select, .login-form input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}
.equip-form .check { flex-direction: row; align-items: center; gap: 8px; }
.form-actions { display: flex; gap: 8px; }
.equip-form .ghost { background: transparent; color: var(--lagoon-deep); border: 1px solid var(--line); }

.login { display: flex; justify-content: center; }
.login-card { padding: 22px 24px; width: min(420px, 100%); }
.login-card h2 { margin-top: 0; }
.login-form { display: grid; gap: 12px; margin: 14px 0 8px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 0.82rem; }
.login-form button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--lagoon);
  color: #f6f1e6;
  cursor: pointer;
}
.link { border: 0; background: none; color: var(--lagoon); cursor: pointer; padding: 4px 0; text-decoration: underline; }

.update-box .form-actions { align-items: center; flex-wrap: wrap; margin: 8px 0; }
.update-log {
  max-height: 220px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px 12px;
  background: #0e1f1e;
  color: #e7f4f2;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
}

.subtabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.subtabs button {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--lagoon-deep);
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
}
.subtabs button[aria-current="page"] { background: var(--lagoon); color: #f6f1e6; border-color: var(--lagoon); }

.row-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.row-action {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--lagoon-deep);
  border-radius: 999px;
  padding: 6px 10px;
  cursor: pointer;
}
td select { border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; background: #fff; }

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

.home { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-top: 8px; }
.home-group {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.home-group.wide { grid-column: 1 / -1; }
.home-group header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.home-group h2 { margin: 0; font-size: 1.15rem; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.home-group.wide .tiles { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.tile {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.tile.down { border-color: #e7b9b9; background: #fdf3f3; }
.tile-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-ip { color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #c9c1b2; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px #d9f0e3; }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 3px #f6dcdc; }
.home-links { margin-top: 14px; }
.card.down { border-left: 6px solid var(--bad); }
a { color: var(--lagoon); }

.notify-form { display: grid; gap: 14px; margin-top: 12px; max-width: 760px; }
.notify-form fieldset {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.notify-form legend { padding: 0 6px; font-weight: 600; color: var(--lagoon-deep); }
.notify-form fieldset > .note, .notify-form fieldset > .check { grid-column: 1 / -1; }
.notify-form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 0.82rem; }
.notify-form .check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 0.92rem; }
.notify-form input:not([type="checkbox"]), .notify-form select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}
.notify-form button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--lagoon);
  color: #f6f1e6;
  cursor: pointer;
}
.notify-form .ghost { background: transparent; color: var(--lagoon-deep); border: 1px solid var(--line); }

.equip-form .access-checks {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.equip-form .access-checks legend { padding: 0 6px; color: var(--muted); font-size: 0.82rem; }
.equip-form .access-checks .check { margin: 0; }
.access-badges { display: flex; flex-wrap: wrap; gap: 6px; }

.term-panel {
  position: sticky;
  bottom: 0;
  margin: 18px 0 0;
  padding: 12px 14px 14px;
  background: #142e2c;
  color: #e7f4f2;
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.term-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.term-status { font-size: 0.88rem; color: #7dcec6; }
.term-panel .ghost { background: transparent; color: #e7c98a; border: 1px solid #2f5653; }
.term-out {
  margin: 0;
  min-height: 140px;
  max-height: 42vh;
  overflow: auto;
  padding: 10px 12px;
  background: #0e1f1e;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.85rem;
}
.term-in {
  width: 100%;
  margin-top: 8px;
  box-sizing: border-box;
  border: 1px solid #2f5653;
  border-radius: 10px;
  padding: 10px 12px;
  background: #0e1f1e;
  color: #e7f4f2;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

/* --- Téléphone --------------------------------------------------------------- */
@media (max-width: 720px) {
  body { -webkit-text-size-adjust: 100%; }
  .top {
    position: sticky;
    top: 0;
    z-index: 5;
    gap: 8px 12px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
    background: rgba(243, 239, 228, 0.96);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line);
    align-items: center;
  }
  .brand { order: 1; }
  .session { order: 2; gap: 6px; }
  .who { display: none; }
  .eyebrow { font-size: 0.66rem; }
  h1 { font-size: 1.2rem; }
  .tabs {
    order: 3;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    margin: 0 -14px;
    padding: 0 14px 2px;
    width: calc(100% + 28px);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex: 0 0 auto; padding: 9px 13px; }
  .refresh { padding: 8px 11px; }
  .wrap { padding: 10px 12px calc(28px + env(safe-area-inset-bottom)); }
  .section h2 { font-size: 1.15rem; }

  .home { grid-template-columns: 1fr; gap: 10px; }
  .home-group { padding: 12px; border-radius: 14px; }
  .home-group.wide .tiles { grid-template-columns: 1fr; }
  .tile { grid-template-columns: 12px minmax(0, 1fr) auto; padding: 11px 10px; }
  .tile .badge { grid-column: 2 / -1; justify-self: start; }

  .table-wrap { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  table { min-width: 0; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    margin-bottom: 10px;
    padding: 6px 12px;
  }
  td { border: 0; padding: 6px 0; display: grid; grid-template-columns: 38% 1fr; gap: 8px; align-items: start; }
  td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 2px; }
  td:empty { display: none; }
  td:not([data-label]) { grid-template-columns: 1fr; }

  .equip-form, .notify-form fieldset { grid-template-columns: 1fr; }
  .equip-form input, .equip-form select, .notify-form input:not([type="checkbox"]), .notify-form select, .toolbar input, .login-form input { font-size: 16px; }
  .equip-form button, .notify-form button, .row-action, .row-delete { min-height: 40px; }
  .cards, .grid, .ports { grid-template-columns: 1fr; }
}
