:root {
  --green: #1f9d55;
  --green-dark: #1f7a46;
  --ink: #16301f;
  --muted: #5f7a68;
  --line: #e3eee7;
  --line-strong: #d6e5db;
  --bg: #f6faf7;
  --soft: #e7f5ec;
  --card: #fff;
  --danger: #e2683c;
  --danger-strong: #b4482a;
  --bar: #1b4d33;
  --staging-bg: #f3dfa2;
  --staging-ink: #4a3a08;
  --tile-w: 9.5rem;
  --tile-h: 8.5rem;
  --tile-gap: 0.75rem;
  --control-h: 2.25rem;
  --page-gap: 1.25rem;
  --pad-x: 1.15rem;
  --tile-cols: 7;
  /* Tile area is 7×9.5rem + 6×0.75rem = 71rem (1136px), about 1100px. The column adds the page padding. */
  --content-max: calc(var(--tile-cols) * (var(--tile-w) + var(--tile-gap)) - var(--tile-gap) + 2 * var(--pad-x));
  --tile-shadow: 0 2px 5px #16301f1f;
  --es-list-max-h: min(25rem, 55dvh);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scrollbar-gutter: stable; }

body {
  margin: 0;
  font: 14px/1.4 Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  user-select: none;
}

input, textarea, select, .selectable { user-select: text; }

a, a:visited, a:hover, a:active {
  color: inherit;
  text-decoration: none;
}

button, input, select { font: inherit; color: inherit; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bar);
  color: #fff;
}
/* Header and every page: as many whole tiles as fit, capped at 7, packed to that width. */
.bar-inner,
main {
  width: 100%;
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
  width: min(
    var(--content-max),
    max(
      calc(var(--tile-w) + 2 * var(--pad-x)),
      calc(round(down, 100% - 2 * var(--pad-x) + var(--tile-gap), var(--tile-w) + var(--tile-gap)) - var(--tile-gap) + 2 * var(--pad-x))
    )
  );
}
.bar-inner {
  padding: 0.45rem var(--pad-x);
  /* The height a 44px header button gives, so pages without one (404) keep the same header. */
  min-height: calc(44px + 0.9rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.staging-pill {
  background: var(--staging-bg);
  color: var(--staging-ink);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 20px;
  padding: 0 0.6rem;
  height: 1.4rem;
  display: inline-flex;
  align-items: center;
}

.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 800; font-size: 17px; white-space: nowrap; }
.logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #fff;
  color: var(--green-dark);
  display: grid;
  place-items: center;
}
.tr { display: flex; gap: 0.4rem; align-items: center; }
.ib {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 0.95rem;
}
.ib:hover { background: #ffffff22; }
.av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #d9f2e3;
  color: var(--green-dark);
  font-weight: 800;
  display: grid;
  place-items: center;
}
.av.sm { width: 28px; height: 28px; font-size: 12px; }
.account { position: relative; flex: none; }
.account-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 9rem;
  max-height: var(--es-list-max-h);
  overflow: auto;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--tile-shadow);
  padding: 4px;
}
.account-menu button {
  width: 100%;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  cursor: pointer;
  color: var(--ink);
}
.account-menu button:hover,
.account-menu button:focus-visible { background: var(--soft); }

#app { min-height: 100dvh; display: flex; flex-direction: column; }
main { padding: 1.1rem var(--pad-x) 2rem; flex: 1 0 auto; }
.page-head { display: flex; align-items: center; gap: 0.75rem; min-height: 44px; margin-bottom: var(--page-gap); }
/* Every page has the same gap under its title. A page's message line sits inside that gap instead of adding to it. */
#page { position: relative; }
#page > .msg-slot:first-child { position: absolute; left: 0; right: 0; top: calc(-1 * var(--page-gap)); }
.page-title { font-size: 20px; margin: 0; font-weight: 750; }
.ml { margin-left: auto; }

/* Fixed 9.5rem tiles packed from the left. The gap stays 0.75rem; a short row does not spread. */
.home-grid {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(auto-fill, var(--tile-w));
  grid-auto-rows: var(--tile-h);
  justify-content: start;
  gap: var(--tile-gap);
}
/* HQ tile standard: fixed 9.5rem x 8.5rem, whole tiles, icon in a colored rounded square above a two-line bold label. */
.home-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: var(--tile-w);
  height: var(--tile-h);
  overflow: hidden;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--tile-shadow);
  color: var(--ink);
  font-weight: 750;
  line-height: 1.15;
  text-align: center;
  transition: transform 0.1s ease, filter 0.1s ease, box-shadow 0.1s ease;
}
.home-tile:hover { filter: brightness(0.97); border-color: #b7d7c4; }
.home-tile:active { transform: scale(0.97); box-shadow: 0 1px 1px #16301f24; transition-duration: 0s; }
.home-tile:focus { outline: none; }
.home-tile:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.ti {
  flex: 0 0 3.25rem;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--ink);
}
.ti svg { width: 28px; height: 28px; }
.home-tile span.n {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  height: 2.3em;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.card h2 { font-size: 15px; margin: 0 0 8px; }
.card > p:first-child { margin-top: 0; }
.card + .card { margin-top: 0.75rem; }

.btn {
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  min-height: 44px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
}
.btn.sec { background: #fff; color: var(--green-dark); border: 1px solid #cfe3d6; }
.btn.danger { background: var(--danger-strong); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-row { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; align-items: center; }

.gi {
  background: none;
  border: 0;
  color: var(--muted);
  min-width: 44px;
  min-height: 44px;
  font-size: 0.95rem;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.gi:hover { background: var(--soft); }

.seg, .chips { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.seg { background: var(--soft); border-radius: 20px; padding: 2px; gap: 2px; }
.seg button, .chip {
  border: 0;
  background: transparent;
  border-radius: 20px;
  padding: 0 12px;
  min-height: 44px;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--ink);
}
.seg button.on { background: #fff; font-weight: 700; box-shadow: 0 1px 2px #0001; }
.chip { background: var(--soft); }
.chip.on { background: var(--green); color: #fff; font-weight: 700; }

.lbl {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
}
.field { display: block; min-width: 0; }
/* auto-fill keeps empty tracks, so a short form stays compact instead of stretching across a wide card. */
.fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
}
.add-form, .form-gap { margin-top: 12px; }
.add-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-top: 12px; }
.add-row .grow { flex: 1 1 14rem; }
.check-inline { display: flex; align-items: center; gap: 6px; min-height: 36px; }
/* Users form: four fields across the card, then Temp password and Apps side by side. Popups use two columns. */
.grid4, .user-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: end; }
.user-grid .span2 { grid-column: span 2; }
.modal .user-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Packing item form: Item, Note, Section on the first row; then For, Person (only for One person), and Critical with Add, packed from the left. */
.item-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.item-grid .form-end { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.modal .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 360px) { .fields .span2 { grid-column: span 2; } }
.chips .checkline { margin-right: 10px; }
.fields.end { align-items: end; }
/* Text boxes and dropdowns share one explicit box, so controls in a form row line up exactly in any browser. */
input:not([type="checkbox"]), select {
  box-sizing: border-box;
  width: 100%;
  height: var(--control-h);
  margin: 0;
  padding: 0 9px;
  font-size: inherit;
  line-height: 1.25;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background-color: #fff;
}
input:disabled, select:disabled { background-color: #f3f7f4; color: var(--muted); }
.checkline { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.checkline input { width: auto; }
/* Every checkbox uses the app's green box (same look as the .cb check buttons on lists). */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  padding: 0;
  border: 2px solid var(--green);
  border-radius: 6px;
  background: #fff center / 12px 12px no-repeat;
  cursor: pointer;
  flex: none;
}
input[type="checkbox"]:checked { background-color: var(--green); background-image: url("/assets/check.svg"); }
input[type="checkbox"]:disabled { opacity: 0.55; cursor: default; }

.tip { position: relative; display: inline-flex; }
.info {
  font-style: normal;
  font-size: 10px;
  width: 14px;
  height: 14px;
  border: 1px solid #8aa394;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  cursor: inherit;
  line-height: 1;
}
.tip-bubble {
  display: none;
  position: absolute;
  left: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  padding: 6px 8px;
  border-radius: 8px;
  width: max-content;
  max-width: 220px;
  z-index: 40;
  pointer-events: none;
}
.tip:hover .tip-bubble, .tip:focus-within .tip-bubble { display: block; }

.muted { color: var(--muted); }
.pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--soft);
  color: var(--green-dark);
  font-weight: 700;
  white-space: nowrap;
}
.pill.critical { background: #f1ead2; color: #6b5420; }
.pill.off { background: #fff; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); }

table { width: 100%; border-collapse: collapse; }
td, th { padding: 7px 6px; border-top: 1px solid #edf3ef; text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; border-top: 0; }
td.r, th.r { text-align: right; }
.table-wrap { overflow-x: auto; }
/* Long emails wrap so the table fits the narrow phone column (U1). */
.table-wrap td { overflow-wrap: anywhere; }

.it { display: flex; align-items: flex-start; gap: 10px; padding: 7px 2px; border-top: 1px solid #edf3ef; }
.it .s { margin-left: auto; color: var(--muted); font-size: 12px; padding-top: 1px; white-space: nowrap; }
.it .body { min-width: 0; flex: 1 1 auto; }
.it .t { display: block; }
/* Under the title: the Critical tag, and on phones who it is for, so long titles wrap cleanly on their own line. */
.it .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.it .meta > * { margin-top: 3px; }
.it .meta .who { color: var(--muted); font-size: 12px; }
.cb {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 6px;
  border: 2px solid var(--green);
  background: #fff;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  padding: 0;
  cursor: pointer;
  flex: none;
}
.it.done .cb { background: var(--green); }
.it.done .t { color: #8aa394; text-decoration: line-through; }
.t.critical { font-weight: 800; }
.note, .when { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.when { color: var(--green-dark); }
.sec-h {
  font-size: 12px;
  font-weight: 700;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 12px 0 2px;
}
.prog { height: 6px; background: var(--soft); border-radius: 9px; overflow: hidden; }
.prog i { display: block; height: 100%; background: var(--green); border-radius: 9px; }
.trip { padding: 10px 0; border-top: 1px solid #edf3ef; cursor: pointer; }
.trip:first-of-type { border-top: 0; }
.trip { min-width: 0; overflow-wrap: anywhere; }
.trip.on { background: #f0f9f3; border-radius: 8px; padding: 10px 8px; }
.grid2 { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 0.75rem; align-items: start; }
.grid2 > .card + .card { margin-top: 0; }
.banner {
  background: #fdeee8;
  color: #8a3b22;
  border-radius: 8px;
  padding: 8px 10px;
  margin: 0 0 10px;
}
.list-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.list-head h2 { margin: 0; }
.head-icons { display: inline-flex; gap: 2px; flex: none; }
/* The title wraps inside its own box so rename and delete stay on the title row at 390. */
.title-row { flex-wrap: nowrap; }
.title-text { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
.title-text h2 { min-width: 0; }
.title-text .pill { flex: none; }
.filter-row, .list-actions { margin-top: 10px; }
.filter-row + .es-list, .list-actions + .es-list { margin-top: 8px; }
.with-tip { display: inline-flex; align-items: center; gap: 4px; }
.small { font-size: 12px; }
.list-name { display: block; min-width: 0; overflow-wrap: anywhere; }
.trip .prog { margin-top: 6px; }
.fund-head { display: flex; gap: 8px; align-items: baseline; }
.fund-left { margin-top: 4px; }
/* Row icons keep their 44px target without making each row taller. */
.it .gi { margin-top: -12px; margin-bottom: -12px; }
.who-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who-text { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.who-text > * { max-width: 100%; overflow-wrap: anywhere; }
.name-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.name-line .pill { flex: none; }
/* Users: Name and Email start where the form's Name and Email fields start; the other columns get fixed shares. */
/* The add-user form has four columns with 10px gaps, so its columns start every 25% + 2.5px.
   Name, Email, Role and Apps start on those same lines: 25% columns plus 2.5px more left padding each. */
.users-table { table-layout: fixed; }
.users-table th, .users-table td { padding-left: 0; padding-right: 10px; }
.users-table tr > :nth-child(2) { padding-left: 2.5px; }
.users-table tr > :nth-child(3) { padding-left: 5px; }
.users-table tr > :nth-child(4) { padding-left: 7.5px; }
.users-table .c-name, .users-table .c-email, .users-table .c-role { width: 25%; }
.users-table .c-status { width: 4.5rem; }
.users-table .c-edit, .users-table td.r { width: 44px; padding-right: 0; }
.after-table { margin: 14px 0 0; }
.tpl-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid #edf3ef; }
.tpl-row:first-child { border-top: 0; }
.tpl-name { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.confirm-text { margin: 0; overflow-wrap: anywhere; }
/* One order everywhere: Delete alone on the left, then Cancel, then the main action on the right. */
.actions { justify-content: flex-end; }
.actions-left { display: inline-flex; margin-right: auto; }
.stack > .msg-slot { margin: -4px 0; }
.cleared { margin-top: 12px; }
/* Honey Do: one divider under the tabs, with room before the first to-do. */
.tabs-head { padding-bottom: 10px; border-bottom: 1px solid #edf3ef; margin-bottom: 6px; }
.tabs-head ~ .es-list > .it:first-child { border-top: 0; }
.cleared summary { cursor: pointer; font-weight: 700; color: var(--muted); }

.modal-back {
  position: fixed;
  inset: 0;
  background: #16301f66;
  display: grid;
  place-items: center;
  z-index: 30;
  padding: 16px;
}
.modal {
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--line);
  width: min(560px, 100%);
  padding: 14px 16px;
  box-shadow: 0 8px 28px #16301f22;
}
.modal h2 { margin: 0 0 12px; font-size: 16px; }

.site-footer {
  width: 100%;
  flex: 0 0 auto;
  padding: 0.75rem var(--pad-x) 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}
.es-list { max-height: var(--es-list-max-h); overflow-x: hidden; overflow-y: auto; }
/* More rows below: the bottom edge fades so the list reads as scrollable. */
.es-list.more-below {
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);
}
.msg-slot {
  height: 1.25rem;
  line-height: 1.25rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #8a3b22;
}
.signin-wrap {
  display: grid;
  place-items: center;
  padding: 24px 0;
}
.signin {
  width: min(380px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 20px 18px;
}
.signin .brand { color: var(--ink); margin-bottom: 14px; }
.signin h1 { font-size: 20px; margin: 0 0 12px; }
.stack { display: grid; gap: 10px; }
.host { margin: 14px 0 0; font-size: 12px; }

@media (max-width: 800px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .tip-bubble { left: auto; right: 0; top: calc(100% + 4px); transform: none; }
}

/* U17: sections draw in place right away; slower data fills them as it arrives. */
.skel { background: var(--soft); border-radius: 8px; }
.skel-row { height: 2.4rem; margin: 0.45rem 0; }
.skel-chip { display: inline-block; width: 5.5rem; height: 2.75rem; margin-right: 0.4rem; }
.skel-line { height: 1.1rem; width: 40%; margin: 0.4rem 0; }

/* U1: long names wrap inside their card instead of pushing the page sideways. */
.card, .grid2 > * { min-width: 0; }
.card h2, .page-title { overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .wide-only { display: none; }
  td { overflow-wrap: anywhere; }
  .users-table .c-name { width: auto; }
}
@media (min-width: 601px) {
  .narrow-only { display: none; }
  /* Wide rows: the Critical tag follows the title on its line. */
  .it .t { display: inline; }
  .it .meta { display: inline-flex; margin-left: 8px; vertical-align: 1px; }
  .it .meta > * { margin-top: 0; }
}

/* Phones: forms are one clean column, the packed count sits under the list title, and Add is full width. */
@media (max-width: 600px) {
  .title-text { flex-direction: column; align-items: flex-start; }
  .list-head .prefs { margin-left: 0; flex-basis: 100%; }
  .item-grid, .modal .item-grid, .user-grid, .modal .user-grid, .grid4 { grid-template-columns: minmax(0, 1fr); }
  .user-grid .span2 { grid-column: auto; }
  .item-grid .form-end { grid-column: auto; flex-direction: column; align-items: stretch; }
  .item-grid .form-end .btn { width: 100%; }
}

/* Phones (600px and under): the column is the full screen width so tables and lists are not squeezed into one tile's width (U1). Tiles still pack from the left. */
@media (max-width: 600px) {
  .bar-inner,
  main { width: 100%; }
}
