/* The one stylesheet of the web (docs/web.md). Mobile first: the base rules are the phone, the media queries widen.
   The palette is the custom properties of the system mockup v2.1. No inline styles anywhere: the
   Content-Security-Policy forbids them — a page that needs a look of its own adds static/<area>.css and links it
   in {% block head %}. */

:root {
  --bg: #f5f4ef;
  --soft: #faf9f5;
  --card: #fff;
  --line: #e4e1d9;
  --ink: #1a1a19;
  --mut: #67645d;
  --mut2: #8f8b82;
  --blue: #1c5cab;
  --blue2: #14406f;
  --bluebg: #eaf1fa;
  --green: #1d7a4b;
  --greenbg: #e7f4ec;
  --amber: #a66a00;
  --amberbg: #fdf3dc;
  --red: #b42318;
  --redbg: #fdeceb;
  --r: 12px;
  --gap: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
}

a { color: var(--blue); }
a:hover { color: var(--blue2); }

h1 { font-size: 1.35rem; line-height: 1.25; margin: 0 0 var(--gap); }
h2 { font-size: 1.1rem; margin: 20px 0 8px; }
p { margin: 0 0 var(--gap); }
code { background: var(--soft); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

/* ---- frame ---- */

.testbar {
  margin: 0;
  padding: 4px var(--gap);
  background: var(--amberbg);
  color: var(--amber);
  font-size: .8rem;
  text-align: center;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px var(--gap);
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand { color: var(--ink); font-weight: 700; text-decoration: none; }
.who { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.who-name { color: var(--mut); }

/* The menu: on a phone the sections wrap into compact lines — the owner's 13 never scroll sideways (B-169); from
   640 px it is the one scrolling line it was. */
.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px var(--gap);
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.menu a {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--mut);
  font-size: .9rem;
  text-decoration: none;
  white-space: nowrap;
}

.menu a.on { background: var(--bluebg); color: var(--blue2); font-weight: 600; }

.page { padding: var(--gap); max-width: 1100px; margin: 0 auto; }

/* ---- blocks ---- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin: 0 0 var(--gap);
}

.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.muted { color: var(--mut); }
.small { font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stack > * + * { margin-top: var(--gap); }

.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--gap); grid-template-columns: 1fr; }

.tile {
  display: block;
  padding: 18px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.tile:hover { border-color: var(--blue); color: var(--blue2); }

.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }

/* key — value pairs of a card: <dl class="kv"><dt>…</dt><dd>…</dd></dl> */
.kv { display: grid; grid-template-columns: 1fr; gap: 2px 16px; margin: 0 0 var(--gap); }
.kv dt { color: var(--mut); font-size: .85rem; }
.kv dd { margin: 0 0 8px; }
.kv dd.num { text-align: left; }

/* ---- status ---- */

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--mut);
  font-size: .8rem;
  white-space: nowrap;
}

.badge-ok { background: var(--greenbg); border-color: var(--greenbg); color: var(--green); }
.badge-warn { background: var(--amberbg); border-color: var(--amberbg); color: var(--amber); }
.badge-stop { background: var(--redbg); border-color: var(--redbg); color: var(--red); }
.badge-info { background: var(--bluebg); border-color: var(--bluebg); color: var(--blue2); }

.flash { padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--card); }
.flash-ok { background: var(--greenbg); border-color: var(--greenbg); color: var(--green); }
.flash-warn { background: var(--amberbg); border-color: var(--amberbg); color: var(--amber); }
.flash-error, .refusal { background: var(--redbg); border-color: var(--redbg); color: var(--red); }
.refusal { padding: 10px 12px; border-radius: var(--r); }

/* ---- tables: wrap in <div class="table-wrap"> so a wide table scrolls inside the phone screen ---- */

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); margin: 0 0 var(--gap); }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { background: var(--soft); color: var(--mut); font-weight: 600; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data th.num, table.data td.num { text-align: right; }
table.data tfoot td { background: var(--soft); font-weight: 600; }

/* ---- forms ---- */

.field { display: block; margin: 0 0 var(--gap); }
.field > span, .field > label { display: block; margin-bottom: 4px; color: var(--mut); font-size: .85rem; }

input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="search"],
input[type="url"], input[type="tel"], input[type="file"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}

textarea { min-height: 88px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.field-error { color: var(--red); font-size: .85rem; }
.inline { display: inline; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: var(--gap) 0 0; }
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0 0 var(--gap); }

.btn {
  display: inline-block;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { border-color: var(--blue); color: var(--blue2); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue2); border-color: var(--blue2); color: #fff; }
.btn-danger { background: var(--card); border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--redbg); border-color: var(--red); color: var(--red); }
.btn-quiet { min-height: 0; padding: 4px 10px; font-weight: 400; color: var(--mut); }

/* ---- wider screens ---- */

@media (min-width: 640px) {
  .menu { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; }
  .menu a { padding: 8px 12px; font-size: inherit; }
  h1 { font-size: 1.6rem; }
  .page { padding: 20px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .kv { grid-template-columns: max-content 1fr; }
  .kv dd { margin-bottom: 4px; }
  .filters { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 960px) {
  /* the owner's 13 sections are all in sight on a desktop: two lines instead of a scroll bar (B-208) */
  .menu { flex-wrap: wrap; overflow-x: visible; white-space: normal; }
  .menu a { padding: 6px 10px; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: repeat(4, 1fr); }
}
