/* TagBook ops — the fleet console's one stylesheet. It starts from
   TagBook's app.css (internal/server/static/app.css): the same tokens,
   fonts and pieces, copied where the console uses them, so the console
   reads as TagBook's without sharing a file with a district's app.
   Every size is a target (CLAUDE.md rule 9): phone ~390, iPad 820 and
   1180, desktop 1920 — where the table uses the width. Body text stays at
   16px so no input triggers iOS focus zoom. */

@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/barlow-400.woff2) format("woff2");
}
@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/fonts/barlow-600.woff2) format("woff2");
}
@font-face {
  font-family: "Barlow";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/static/fonts/barlow-700.woff2) format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/plexmono-400.woff2) format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/static/fonts/plexmono-600.woff2) format("woff2");
}

:root {
  --ink: #1b2440;      /* text, header bar, primary buttons */
  --muted: #5a6379;
  --ground: #eef0f4;   /* page background */
  --label: #ffffff;    /* panels */
  --line: #d9dde5;
  --tag: #ffc91f;      /* brand yellow: mark, active nav, highlights only */
  --ok: #166534;
  --ok-soft: #e6f3ea;
  --out: #1d4ed8;
  --out-soft: #e8eefc;
  --warn: #92400e;
  --warn-soft: #f8eee1;
  --err: #b91c1c;
  --err-soft: #faeaea;
  --sans: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  background: var(--ground);
  color: var(--ink);
}

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

/* --- site header: the mark, Fleet, and who is signed in --- */
header.site {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .55rem max(1rem, env(safe-area-inset-right)) .55rem max(1rem, env(safe-area-inset-left));
  background: var(--ink);
  color: #fff;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .01em;
  white-space: nowrap;
}
.brand svg { display: block; flex: none; }
header.site > nav { display: flex; gap: .1rem; }
header.site > nav a {
  color: #c7cddc;
  text-decoration: none;
  font-weight: 600;
  font-size: .95rem;
  padding: .5rem .7rem;
  white-space: nowrap;
}
header.site > nav a:hover { color: #fff; }
header.site > nav a.current { color: #fff; box-shadow: inset 0 -3px 0 var(--tag); }
/* Who is signed in, then Sign out, at the far end. A phone has no room
   for the address: Sign out's title names it. */
.who {
  margin-left: auto;
  min-width: 0;
  color: #c7cddc;
  font-size: .9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.signout { margin: 0; flex: none; }
.signout button {
  background: none;
  border: 0;
  color: #c7cddc;
  font: inherit;
  font-weight: 600;
  font-size: .95rem;
  padding: .5rem .7rem;
  white-space: nowrap;
  cursor: pointer;
}
.signout button:hover { color: #fff; }
@media (pointer: coarse) {
  header.site > nav a, header.site .signout button { display: inline-flex; align-items: center; min-height: 44px; }
}
@media (max-width: 600px) {
  header.site { gap: .5rem; }
  .who { display: none; }
  .signout { margin-left: auto; }
}

/* --- layout: the console is a desk tool, so the width is used --- */
main {
  max-width: 1360px;
  margin: 1.25rem auto;
  padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
}
@media (min-width: 1600px) {
  main { max-width: 1840px; }
}
.panel {
  background: var(--label);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.panel h2 {
  margin: 0 0 .75rem;
  font-size: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}
.panel h3 { margin: 1.25rem 0 .5rem; font-size: .92rem; }
.panel .sub { color: var(--muted); font-size: .85rem; margin: -.5rem 0 .75rem; }
.count {
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 600;
  background: var(--ground);
  border-radius: 999px;
  padding: .05rem .55rem;
  white-space: nowrap;
}
.panel h2 .json { margin-left: auto; }

/* The head strip: the fleet rolled up — /healthz in words. */
.strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem 1rem;
  margin: 0 0 1rem;
  font-size: .95rem;
}
.strip .checked { margin-left: auto; font-size: .85rem; }

/* Below the fleet: the district panel and the actions side by side
   where there is room. */
.lower { display: grid; gap: 0 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) {
  .lower { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
}

/* --- site footer: the release that's running, and whose it is --- */
footer.site {
  padding: .25rem 1rem max(1.25rem, env(safe-area-inset-bottom));
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
}
footer.site svg { vertical-align: -2px; margin-right: .15rem; }
footer.site .co { white-space: nowrap; }

/* --- controls (16px minimum everywhere: iOS zooms on smaller inputs) --- */
input[type="text"], input[type="email"], select, textarea {
  font: inherit;
  font-size: 16px;
  padding: .5rem .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--label);
  color: var(--ink);
}
button.action {
  font: inherit;
  font-weight: 600;
  padding: .55rem 1.25rem;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}
button.action:hover { background: #2a3557; }
.rowbtn {
  font: inherit;
  font-weight: 600;
  font-size: .85rem;
  min-height: 40px;
  padding: .3rem .8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--label);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
a.rowbtn { display: inline-flex; align-items: center; text-decoration: none; }
.rowbtn:hover { border-color: var(--ink); }
@media (pointer: coarse) { .rowbtn { min-height: 44px; } }

/* The district forms. */
.formgrid { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; }
.formgrid label {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  flex: 1 1 13rem;
}
.formgrid label.wide { flex: 1 1 100%; }
.formgrid input, .formgrid textarea { width: 100%; }
.formgrid label.check {
  flex-direction: row;
  align-items: center;
  gap: .55rem;
  min-height: 44px;
  text-transform: none;
  letter-spacing: 0;
  font-size: .92rem;
  color: var(--ink);
}
.formgrid label.check input { width: 22px; height: 22px; flex: none; }
.formactions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .75rem; }
.stateform { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.stateform label { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .92rem; }
.msg { margin: 0 0 .75rem; overflow-wrap: anywhere; }
/* An Edit scrolls the panel into view below the sticky header. */
#district-panel { scroll-margin-top: 4.5rem; }

/* --- tables --- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
td a { color: var(--out); font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }
td.edit { text-align: right; }
td.short { white-space: nowrap; } /* "2 min ago" and "behind" read as one */
table.fleet td.district { min-width: 14rem; }
/* An error from Azure or an instance is said in its cell, two lines at
   most; the whole text is the cell's. */
.small { font-size: .82rem; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.problems { margin: .35rem 0 0; padding: 0 0 0 1.1rem; color: var(--err); font-size: .85rem; }
/* The provisioning line, ready to paste into PowerShell. */
.cmdrow { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.cmdrow code {
  flex: 1 1 24rem;
  min-width: 0;
  font-family: var(--mono);
  font-size: .85rem;
  background: var(--ground);
  border-radius: 6px;
  padding: .45rem .6rem;
  overflow-wrap: anywhere;
}
.provision p { margin: .35rem 0 0; }

/* identifiers — hostnames, versions and tags are monospace */
.mono { font-family: var(--mono); font-size: .92em; }

/* --- status chips: little tags with a punched hole --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .38rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  padding: .18rem .6rem .18rem .48rem;
  border-radius: 999px;
  background: var(--ground);
  color: var(--muted);
  white-space: nowrap;
  vertical-align: 1px;
}
.badge::before {
  content: "";
  width: .42em;
  height: .42em;
  border-radius: 50%;
  background: var(--label);
  box-shadow: 0 0 0 1.5px currentColor;
  flex: none;
}
.badge.ok, .badge.live          { background: var(--ok-soft);   color: var(--ok); }
.badge.provisioning             { background: var(--out-soft);  color: var(--out); }
.badge.degraded, .badge.behind,
.badge.held, .badge.offboarding { background: var(--warn-soft); color: var(--warn); }
.badge.unreachable              { background: var(--err-soft);  color: var(--err); }
.badge.planned, .badge.offboarded { background: var(--ground);  color: var(--muted); }
/* The fleet's own word in the strip is the loudest thing on the page. */
.strip > .badge { font-size: .85rem; }
.strip > .badge.degraded { background: var(--err-soft); color: var(--err); }

[hidden] { display: none !important; }

.muted { color: var(--muted); }
.err   { color: var(--err); }
.warn  { color: var(--warn); }
.ok    { color: var(--ok); }
.empty { color: var(--muted); padding: .75rem 0; }

/* --- responsive tables: card reflow (cells carry data-th) — app.css's
   table.cards, taken up to 900px here: the fleet table's seven columns
   of versions, tags and states don't fit an iPad held upright. --- */
@media (max-width: 900px) {
  main { margin-top: 1rem; }
  .panel { padding: .85rem 1rem; }
  table.cards, table.cards tbody { display: block; }
  table.cards thead { display: none; }
  table.cards tbody tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: .6rem;
    padding: .35rem .85rem;
  }
  /* Label floats left, value flows right; not flex, so an unbreakable
     token (a hostname) can't force the card wider than the screen. */
  table.cards td {
    display: block;
    text-align: right;
    overflow-wrap: anywhere;
    border-bottom: none;
    padding: .28rem 0;
  }
  table.cards td::before {
    content: attr(data-th);
    float: left;
    margin-right: 1rem;
    color: var(--muted);
    font-family: var(--sans);
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    line-height: 1.8;
  }
  table.cards td:empty { display: none; }
  /* The district cell heads its card; the problems and the script line
     read left to right under it. */
  table.fleet td.district { text-align: left; min-width: 0; }
  table.fleet td.district::before, table.fleet td.provision::before { content: none; }
  table.fleet td.provision { text-align: left; }
  table.fleet td.edit { text-align: right; }
  td.short { white-space: nowrap; } /* "2 min ago" and "behind" read as one */
  .small { display: block; }
}
