/* TagBook design system — the one stylesheet every page shares.
   Identity: the asset tag/label world (docs/ui-redesign-plan.md).
   Tokens below are the only place colors and fonts are defined.
   Mobile (~390px, iOS Safari) is a first-class target: CLAUDE.md rule 9.
   Body text stays at 16px so no input ever 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;       /* check-in, in_service */
  --ok-soft: #e6f3ea;
  --out: #1d4ed8;      /* checked out */
  --out-soft: #e8eefc;
  --warn: #92400e;     /* in_repair, warnings */
  --warn-soft: #f8eee1;
  --err: #b91c1c;      /* lost, errors */
  --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 --- */
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;
}
.brand svg { display: block; flex: none; }
header.site nav {
  display: flex;
  gap: .1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
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); }
/* Phones: six nav links (admin) don't fit beside the wordmark, so the
   brand collapses to its tag icon and links tighten — every link stays
   visible instead of hiding in an unhinted scroll strip. */
@media (max-width: 430px) {
  .brand .word { display: none; }
  header.site { gap: .4rem; }
  header.site nav a { padding: .5rem .34rem; font-size: .85rem; }
}

/* --- layout --- */
main {
  max-width: 960px;
  margin: 1.25rem auto;
  padding: 0 max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
}
.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;
  align-items: center;
  gap: .5rem;
}
.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; /* "12 of 14000" stays one chip */
}

/* --- sectioned pages (Reports, Admin): left-hand section picker.
   JS (fragments.html "sectionnav-script") shows one panel at a time,
   named by the URL hash; without JS every panel renders and the nav
   degrades to jump links. Phones swap the sidebar for a horizontally
   scrolling chip row. */
main.sectioned { max-width: 1100px; display: flex; gap: 1.25rem; align-items: flex-start; }
.sectionnav {
  flex: 0 0 10.5rem;
  position: sticky;
  top: 4rem; /* clears the sticky site header */
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.sectionnav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: .92rem;
  padding: .45rem .7rem;
  border-radius: 8px;
}
.sectionnav a:hover { color: var(--ink); }
.sectionnav a.current {
  background: var(--label);
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--tag);
}
.sections { flex: 1 1 auto; min-width: 0; }
/* Wide desktops use the width (design rule 9): the column grows so
   report tables keep every column on one line and panels breathe. */
@media (min-width: 1400px) {
  main { max-width: 1360px; }
  main.sectioned { max-width: 1500px; }
}
@media (max-width: 800px) {
  main.sectioned { display: block; }
  .sectionnav {
    position: static;
    flex-direction: row;
    gap: .3rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: .75rem;
  }
  .sectionnav a {
    flex: none;
    display: inline-flex;
    align-items: center;
    min-height: 40px; /* touch target */
    padding: .3rem .85rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--label);
    white-space: nowrap;
  }
  .sectionnav a.current {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
    box-shadow: none;
  }
}

/* --- controls (16px minimum everywhere: iOS zooms on smaller inputs) --- */
input[type="text"], input[type="search"], input[type="email"], input[type="number"], input[type="password"], input[type="date"], input[type="file"], select, textarea {
  font: inherit;
  font-size: 16px; /* even inside smaller-font labels — iOS zooms below 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; /* touch target */
  border-radius: 8px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
}
button.action:hover { background: #2a3557; }
button.action:disabled { opacity: .5; cursor: default; }

/* --- 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); }
th {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
td input { width: 100%; }
tr.click { cursor: pointer; }
tr.click:active td { background: var(--ground); }
@media (hover: hover) {
  tr.click:hover td { background: var(--ground); }
}
td a { color: var(--out); font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }

/* identifiers — tags and serials are always 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;
}
.badge::before {
  content: "";
  width: .42em;
  height: .42em;
  border-radius: 50%;
  background: var(--label);
  box-shadow: 0 0 0 1.5px currentColor;
  flex: none;
}
.badge.in_service { background: var(--ok-soft);   color: var(--ok); }
.badge.in_repair  { background: var(--warn-soft); color: var(--warn); }
.badge.retired    { background: var(--ground);    color: var(--muted); }
.badge.lost       { background: var(--err-soft);  color: var(--err); }
.badge.out        { background: var(--out-soft);  color: var(--out); }
.badge.expired    { background: var(--err-soft);  color: var(--err); }
.badge.planned    { background: var(--ground);    color: var(--muted); }

.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;
}
.rowbtn:hover { border-color: var(--ink); }
.rowbtn:disabled { opacity: .5; }

[hidden] { display: none !important; } /* the attribute wins over any display rule */
.muted { color: var(--muted); }
.err   { color: var(--err); }
.ok    { color: var(--ok); }
.empty { color: var(--muted); padding: .75rem 0; }

/* --- responsive tables: opt-in card reflow (cells carry data-th) --- */
@media (max-width: 640px) {
  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: a cell's link, badge
     and trailing text would become separate flex items, and an unbreakable
     token (an email) then forces 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); /* .mono cells must not mono their label */
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    line-height: 1.8; /* baseline-match the .9rem value text */
  }
  table.cards td:empty { display: none; }
}
