/* CEO Priorities: phone-first, calm, Stalwart visual language.
   Colour key (strict): red = Needs you only; amber = slipping; navy/grey otherwise;
   green = the small tick beside Done. Brand red only in the logo and the header rule. */

@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/assets/fonts/Inter-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --page: #f6f5f2;
  --card: #ffffff;
  --line: #e4e1da;
  --line-hover: #cbc6ba;
  --field-line: #858a93;
  --navy: #14284b;
  --navy-tint: #eef1f6;
  --ink: #1d2433;
  --muted: #5b6372;
  --grey-tint: #f1efea;
  --soft: #fbfaf7;
  --brand: #d42a2f;
  --red: #b3261e;
  --red-tint: #fcf1f0;
  --amber: #9a5b00;
  --amber-bg: #fff4e0;
  --green: #2e7d4f;

  --radius: 10px;
  --radius-sm: 8px;
  --gutter: 16px;
  --tabbar: 60px;
  --speed: 150ms;
  --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}

@media (min-width: 600px) {
  :root { --gutter: 24px; }
}
@media (min-width: 900px) {
  :root { --gutter: 32px; }
}

/* ---------- base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--page);
  /* Keep focused or scrolled-to elements clear of the fixed tab bar. */
  scroll-padding-bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom));
}
@media (min-width: 900px) {
  html { scroll-padding-bottom: 16px; scroll-padding-top: 66px; }
}
html.has-sheet { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss03';
  overflow-x: hidden;
}

img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--navy); }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; }

:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.muted { color: var(--muted); }
.break { overflow-wrap: anywhere; }
.icon { width: 20px; height: 20px; flex: 0 0 auto; }

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -100px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 12px; }

.only-wide { display: none; }
@media (min-width: 720px) {
  .only-wide { display: inline; }
  .only-phone { display: none; }
}

/* ---------- header ---------- */

.app-header {
  background: var(--card);
  border-top: 3px solid var(--brand);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "logo user"
    "titles titles";
  align-items: center;
  gap: 12px 12px;
  padding-block: 12px 14px;
  padding-top: max(12px, env(safe-area-inset-top));
}

.logo {
  grid-area: logo;
  height: 26px;
  width: auto;
}

.titles { grid-area: titles; min-width: 0; }

.app-title {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--navy);
}

.freshness {
  margin-top: 2px;
  font-size: 13.5px;
  color: var(--muted);
  min-height: 1.4em;
}

.user {
  grid-area: user;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.user-email {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.role-tag {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
  background: var(--navy-tint);
  padding: 3px 7px;
  border-radius: 5px;
}

@media (min-width: 900px) {
  .header-inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "logo titles user";
    gap: 0 20px;
    padding-block: 16px;
  }
  .logo {
    height: 34px;
    padding-right: 20px;
    border-right: 1px solid var(--line);
    box-sizing: content-box;
  }
  .app-title { font-size: 19px; }
  .user-email { font-size: 13px; }
}

/* ---------- tabs: bottom bar on phone, top tabs on desktop ---------- */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabs-inner {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-inline: 0;
}

.tabs a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tabbar);
  padding: 6px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--speed) ease;
}
.tabs a:hover { color: var(--navy); }
.tabs a[aria-current="page"] { color: var(--navy); font-weight: 600; }
.tabs a[aria-current="page"]::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 28%;
  right: 28%;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--navy);
}
.tabs a:focus-visible { outline-offset: -3px; }
.tab-icon { width: 22px; height: 22px; }

@media (min-width: 900px) {
  .tabs {
    position: sticky;
    top: 0;
    bottom: auto;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0;
  }
  .tabs-inner {
    display: flex;
    gap: 4px;
    padding-inline: calc(var(--gutter) - 14px);
  }
  .tabs a {
    flex-direction: row;
    min-height: 50px;
    padding: 0 14px;
    font-size: 15px;
  }
  .tab-icon { display: none; }
  .tabs a[aria-current="page"]::before {
    top: auto;
    bottom: -1px;
    left: 14px;
    right: 14px;
    border-radius: 2px 2px 0 0;
  }
}

/* ---------- main ---------- */

.main {
  display: block;
  min-height: 60vh;
  padding-bottom: calc(var(--tabbar) + 40px + env(safe-area-inset-bottom));
}
.main:focus { outline: none; }
@media (min-width: 900px) {
  .main { padding-bottom: 72px; }
}

body.is-blocked .tabs { display: none; }
body.is-blocked .main { padding-bottom: 48px; }

.loading {
  padding: 48px 0;
  text-align: center;
  color: var(--muted);
}

.banner {
  background: var(--navy-tint);
  border-bottom: 1px solid var(--line);
}
.banner-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-block: 6px;
}
.banner-icon { color: var(--navy); }
.banner-text { flex: 1 1 auto; font-size: 14.5px; color: var(--navy); font-weight: 500; }

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin: 24px 0 16px;
}
.view-titles { min-width: 0; }
.view-title {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--navy);
}
.view-sub {
  margin-top: 4px;
  font-size: 14.5px;
  color: var(--muted);
}
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (min-width: 900px) {
  .view-head { margin-top: 32px; margin-bottom: 20px; }
  .view-title { font-size: 28px; }
}

.section { margin-top: 32px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 12px;
}
.section-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--navy);
}
.section-sub { font-size: 13px; color: var(--muted); }
.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--navy);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--speed) ease, border-color var(--speed) ease;
}
.btn:hover { background: var(--soft); border-color: var(--navy); }
.btn-primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: #1d3763; border-color: #1d3763; }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { background: var(--navy-tint); border-color: transparent; }
.btn-small { padding: 0 12px; font-size: 14px; }
.btn:disabled,
.btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.5;
}
.btn:disabled:hover { background: var(--card); border-color: var(--field-line); }
.btn-primary:disabled:hover { background: var(--navy); border-color: var(--navy); }
.btn .icon { width: 18px; height: 18px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--navy);
  transition: background-color var(--speed) ease;
}
.icon-btn:hover { background: var(--navy-tint); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; background: var(--card); }

/* ---------- pills (always text beside colour) ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}
.pill-sm { min-height: 22px; padding: 2px 7px; font-size: 12px; }
.tone-amber { color: var(--amber); background: var(--amber-bg); }
.tone-red { color: var(--red); background: var(--red-tint); }
.tone-navy { color: var(--navy); background: var(--navy-tint); }
.tone-grey { color: var(--muted); background: var(--grey-tint); }
.tone-done { color: var(--ink); background: var(--grey-tint); }
.tone-done .tick { width: 15px; height: 15px; color: var(--green); stroke-width: 2.4; }
.pill-plain { background: transparent; padding-left: 0; }

/* ---------- overview tiles ---------- */

.tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.tiles > li { display: flex; min-width: 0; }

.tile {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 120px;
  padding: 14px 14px 13px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--speed) ease;
}
.tile:hover { border-color: var(--line-hover); }
.tile-label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}
.tile-value {
  margin-top: 10px;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.tile-caption {
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--muted);
  text-wrap: balance;
}
/* Line up labels, numbers and captions across a row when the browser can. */
@supports (grid-template-rows: subgrid) {
  .tiles > li,
  .tile {
    display: grid;
    grid-row: span 3;
    grid-template-rows: subgrid;
    row-gap: 0;
  }
  .tile { align-content: start; }
  .tile-value { align-self: end; }
  .tile-caption { align-self: start; }
}
.tile-amber { box-shadow: inset 3px 0 0 var(--amber); }
.tile-amber .tile-value { color: var(--amber); }
.tile-red { box-shadow: inset 3px 0 0 var(--red); }
.tile-red .tile-value { color: var(--red); }

@media (min-width: 600px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .tile { min-height: 132px; padding: 16px 18px 15px; }
  .tile-value { font-size: 38px; }
}
/* Outstanding is the seventh tile: full width below the others on phones and
   tablets, two columns wide in the four-column desktop grid (4 + 4). */
.tiles > li.tile-wide { grid-column: 1 / -1; }
.caption-warn { color: var(--amber); font-weight: 600; }
@media (min-width: 1100px) {
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tiles > li.tile-wide { grid-column: span 2; }
}

/* Quiet secondary link under the tiles ("Vacancies → open vacancy review"). */
.quiet-link-row { margin: 12px 0 0; }
.quiet-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  padding: 0 2px;
  color: var(--navy);
  font-size: 14.5px;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.quiet-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.quiet-link-label { font-weight: 600; }
.quiet-link-icon { width: 16px; height: 16px; margin-left: 6px; color: var(--muted); flex: none; }

/* ---------- needs you (overview, above the tiles) ---------- */

.needs-panel { margin-bottom: 20px; }
.needs-panel .section-title { margin-bottom: 10px; }
.needs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.needs-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--speed) ease;
}
.needs-card:hover { border-color: var(--line-hover); }
.needs-card .needs { display: block; margin-top: 0; font-size: 15px; }
.needs-task { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.needs-more { margin: 4px 0 0; }

/* ---------- region roll-up ---------- */

.rollup {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.rollup :focus-visible { outline-offset: -3px; }
.rollup-head { display: none; }
.rollup-list { list-style: none; margin: 0; padding: 0; }
.rollup-list > li + li { border-top: 1px solid var(--line); }
.rollup-calm > .rollup-list > li:first-child { border-top: 1px solid var(--line); }
.rollup-none {
  margin: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.rollup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 18px;
  grid-template-areas:
    "name flags chev"
    "nums flags chev";
  align-items: center;
  gap: 2px 12px;
  min-height: 60px;
  padding: 11px 12px 11px 16px;
  color: var(--ink);
  text-decoration: none;
  transition: background-color var(--speed) ease;
}
.rollup-row:hover { background: var(--soft); }
.rr-name { grid-area: name; font-weight: 600; overflow-wrap: anywhere; }
.rr-nums { grid-area: nums; font-size: 13.5px; color: var(--muted); }
.rr-nums b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.rr-flags {
  grid-area: flags;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.rr-flag:empty { display: none; }
.rr-zero { font-size: 13px; color: var(--muted); }
/* Phones stack the flags: "needs you" (red) goes above "overdue" (amber). The
   desktop table keeps DOM order through display: contents. */
@media (max-width: 719px) {
  .rr-flag-needs { order: -1; }
}
.rr-chev { grid-area: chev; width: 18px; height: 18px; color: var(--muted); }

.rollup-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 12px 12px 12px 16px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--navy);
  font-size: 14.5px;
  font-weight: 500;
  text-align: left;
  transition: background-color var(--speed) ease;
}
.rollup-all-calm .rollup-toggle { border-top: 0; }
.rollup-toggle:hover { background: var(--soft); }
.rollup-toggle .chev { width: 18px; height: 18px; transition: transform var(--speed) ease; }
.rollup-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

@media (min-width: 720px) {
  .rollup-head,
  .rollup-row {
    grid-template-columns: minmax(0, 1fr) 72px 72px 128px 128px 18px;
    grid-template-areas: none;
    column-gap: 12px;
  }
  .rollup-head {
    display: grid;
    padding: 10px 12px 10px 16px;
    background: var(--soft);
    border-bottom: 1px solid var(--line);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
  }
  .rollup-row { min-height: 52px; }
  .rr-name, .rr-chev { grid-area: auto; }
  .rr-nums, .rr-flags { display: contents; }
  .rr-dot { display: none; }
  .rr-num b { font-size: 15px; }
  .rr-word {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .rr-flag { display: block; }
  .rr-flag:empty { display: block; }
}

/* ---------- lists of items ---------- */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.row {
  position: relative;
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color var(--speed) ease;
}
.row:hover { border-color: var(--line-hover); }
.row-static:hover { border-color: var(--line); }

.rank {
  flex: 0 0 auto;
  min-width: 20px;
  font-size: 15px;
  font-weight: 700;
  line-height: 26px;
  color: var(--navy);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row-body { flex: 1 1 auto; min-width: 0; }

.row-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
  min-height: 26px;
  margin-bottom: 8px;
}
/* Wraps under the status pill when it does not fit, never cut off. */
.row-where {
  min-width: 0;
  font-size: 12.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.row-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  overflow-wrap: anywhere;
  /* Three lines at most in lists; the full task is in the item panel. The h3
     is not positioned, so the full-card tap area (.row-link::after) is not clipped. */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}
.row-link { color: inherit; text-decoration: none; }
.row-link::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}
.row-link:focus-visible { outline: none; }
.row-link:focus-visible::after { outline: 2px solid var(--navy); outline-offset: 2px; }

.row-who {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.row-who .pill { vertical-align: 1px; }
.row-next {
  margin-top: 6px;
  font-size: 14px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.lbl { color: var(--muted); font-weight: 500; }

.needs {
  margin-top: 10px;
  padding: 7px 10px;
  border-left: 3px solid var(--red);
  border-radius: 0 6px 6px 0;
  background: var(--red-tint);
  font-size: 14px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.needs-label { color: var(--red); font-weight: 600; }

/* Amber words without a tint: slipping details beside the (tinted) status pill. */
.warn-text { color: var(--amber); font-weight: 600; }

.row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}
.meta-amount strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.meta-target { color: var(--ink); }

.row-controls {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hint-banner {
  margin: -4px 0 12px;
  font-size: 14px;
  color: var(--muted);
}

@media (min-width: 900px) {
  .row { padding: 16px 20px; }
  .row-title { font-size: 16.5px; }
}

/* ---------- search, segmented, chips ---------- */

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 12px;
  background: #ebe9e3;
  border-radius: var(--radius);
  max-width: 100%;
}
.seg {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--speed) ease, color var(--speed) ease;
}
.seg:hover { color: var(--navy); }
.seg[aria-current="page"] {
  background: var(--card);
  color: var(--navy);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(20, 40, 75, 0.08);
}
.seg-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(20, 40, 75, 0.06);
  border-radius: 999px;
  padding: 2px 7px;
  font-variant-numeric: tabular-nums;
}

.search { position: relative; }
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  min-height: 48px;
  padding: 0 48px 0 44px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius);
  background: var(--card);
  font-size: 16px;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.search-input::placeholder { color: var(--muted); opacity: 1; }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
/* Our own clear button: 44x44, navy, shown only while the field has text. */
.search-clear {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--navy);
}
.search-clear:hover { background: var(--navy-tint); }
.search-clear[hidden] { display: none; }
.search-clear svg { width: 18px; height: 18px; }

.filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Phones: the four dropdown filters sit behind a "Filters" toggle. */
.filters-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--navy);
  font-size: 15px;
  font-weight: 600;
  text-align: left;
}
.filters-toggle:hover { border-color: var(--navy); }
.filters-toggle .filters-summary {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  color: var(--muted);
}
.filters-toggle .chev { width: 18px; height: 18px; transition: transform var(--speed) ease; }
.filters-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.filter-panel.is-collapsed { display: none; }
@media (min-width: 600px) {
  .filters-toggle { display: none; }
  .filter-panel.is-collapsed { display: flex; }
}

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  max-width: 100%;
  padding: 0 14px;
  border: 1px solid var(--field-line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  transition: background-color var(--speed) ease, border-color var(--speed) ease;
}
.chip:hover { border-color: var(--navy); }
.chip.is-on {
  background: var(--navy-tint);
  border-color: var(--navy);
  color: var(--navy);
  font-weight: 600;
}
.chip-check { width: 16px; height: 16px; stroke-width: 2.2; }
/* A select styled as a chip: the select itself carries the border so the
   whole 44px pill is the tap target. */
.chip-has-select,
.chip-has-select:hover,
.chip-has-select.is-on {
  padding: 0;
  border: 0;
  background: transparent;
}
.chip-select {
  min-height: 44px;
  max-width: min(100%, 15rem);
  field-sizing: content;
  padding: 0 36px 0 14px;
  border: 1px solid var(--field-line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background-color var(--speed) ease, border-color var(--speed) ease;
}
.chip-select:hover { border-color: var(--navy); }
.chip-has-select.is-on .chip-select {
  background: var(--navy-tint);
  border-color: var(--navy);
  color: var(--navy);
  font-weight: 600;
}
.chip-has-select.is-on .chip-chev { color: var(--navy); }
.chip-select option { color: var(--ink); background: #fff; font-weight: 400; }
.chip-chev {
  position: absolute;
  right: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  pointer-events: none;
}

.list-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-height: 44px;
  margin: 12px 0 8px;
}
.result-count { font-size: 13.5px; color: var(--muted); }
.clear-slot:empty { display: none; }
.clear-slot .btn-quiet { padding-inline: 4px; }

/* ---------- empty and whole-page states ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 36px 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}
.empty-title { font-size: 16px; font-weight: 600; color: var(--ink); }
.empty-body { max-width: 46ch; font-size: 14.5px; color: var(--muted); }
.empty .btn { margin-top: 8px; }

.state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 480px;
  margin: 56px auto;
  padding: 36px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
}
.state-card .view-title { font-size: 22px; }
.state-card .btn { margin-top: 10px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: #fff;
  font-size: 14.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px);
  transition: opacity var(--speed) ease, transform var(--speed) ease;
}
.toast:empty { padding: 0; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) {
  .toast { bottom: 24px; }
}

/* ---------- item detail sheet ---------- */

.sheet {
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--page);
  color: var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sheet::backdrop { background: rgba(20, 40, 75, 0.32); }
.sheet[open] { animation: sheet-up var(--speed) ease-out; }

@keyframes sheet-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes sheet-left {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}

@media (min-width: 900px) {
  .sheet {
    width: min(600px, 100%);
    margin: 0 0 0 auto;
    border-left: 1px solid var(--line);
  }
  .sheet[open] { animation-name: sheet-left; }
}

.sheet-bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 6px 16px 6px 6px;
  padding-top: max(6px, env(safe-area-inset-top));
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.sheet-close { padding: 0 12px; }
.sheet-kicker {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--muted);
}

.sheet-body { padding: 18px 16px calc(32px + env(safe-area-inset-bottom)); }
@media (min-width: 600px) {
  .sheet-body { padding: 24px 24px 40px; }
}

.sheet-live:not(:empty) {
  margin-bottom: 16px;
  padding: 11px 14px;
  border-left: 3px solid var(--navy);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--navy-tint);
  color: var(--navy);
  font-size: 14.5px;
  font-weight: 500;
}

.detail-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.detail-title {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.005em;
  color: var(--ink);
  overflow-wrap: anywhere;
}
@media (min-width: 600px) {
  .detail-title { font-size: 22px; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
}
.detail-where { margin-top: 8px; font-size: 14.5px; color: var(--muted); }
.detail-head + .needs { margin-top: 12px; font-size: 15px; padding: 10px 12px; }

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.action-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.action-row .btn { flex: 1 1 auto; }
.action-row-top { padding-top: 8px; border-top: 1px solid var(--line); }
.action-row .hint { flex-basis: 100%; }

.detail-section { margin-top: 24px; }
.detail-section-title {
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.fields {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.field { padding: 11px 16px; border-top: 1px solid var(--line); }
.field:first-child { border-top: 0; }
.field dt { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field dd {
  margin: 2px 0 0;
  font-size: 15px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.field dd .pill { white-space: nowrap; vertical-align: 1px; }
.needs-inline .needs-label { color: var(--red); }

.field {
  display: grid;
  grid-template-columns: minmax(104px, 34%) minmax(0, 1fr);
  gap: 12px;
  align-items: baseline;
}
.field dd { margin: 0; }
.field.field-long { display: block; }
.field.field-long dd { margin-top: 2px; }
@media (min-width: 600px) {
  .field,
  .field.field-long {
    display: grid;
    grid-template-columns: 168px minmax(0, 1fr);
    gap: 16px;
  }
  .field.field-long dd { margin: 0; }
}

.history {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.history li {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  overflow-wrap: anywhere;
}
.history li:first-child { border-top: 0; }
.history-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.history-sep { color: var(--muted); }
.history-host > .btn { margin-top: 8px; }

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

.edit-form .detail-title { margin-bottom: 16px; }

.form-group {
  min-width: 0;
  margin: 0 0 16px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.form-group legend {
  float: left;
  width: 100%;
  margin: 0 0 12px;
  padding: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.form-group legend + * { clear: both; }

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  margin-bottom: 14px;
}
.form-group > .form-field:last-child,
.form-group > .form-grid:last-child > .form-field:last-child { margin-bottom: 0; }

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  column-gap: 14px;
}
@media (min-width: 600px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-group > .form-grid:last-child > .form-field:nth-last-child(2):nth-child(odd) { margin-bottom: 0; }
}

.form-field label { font-size: 14px; font-weight: 500; color: var(--ink); }

.form-field input,
.form-field select,
.form-field textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
}
.form-field input[type="date"] { -webkit-appearance: none; appearance: none; min-height: 46px; }
.form-field select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2314284b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 7.5L10 13l5.5-5.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
}
.form-field textarea {
  resize: vertical;
  /* Grow with the text where supported; rows= is the fallback (see item.js). */
  field-sizing: content;
  min-height: 3lh;
  max-height: 12lh;
}
.form-field [aria-invalid="true"] { border: 2px solid var(--navy); padding: 9px 11px; }
.form-field select[aria-invalid="true"] { padding-right: 37px; }


.input-prefix { display: flex; align-items: stretch; min-width: 0; }
.input-prefix .prefix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--field-line);
  border-right: 0;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--grey-tint);
  color: var(--muted);
  font-weight: 600;
}
.input-prefix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.hint { margin: 0; font-size: 13px; color: var(--muted); }
.field-error {
  margin: 0;
  padding-left: 9px;
  border-left: 3px solid var(--navy);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
}

.form-summary {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-left: 3px solid var(--navy);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--navy-tint);
  color: var(--ink);
  font-size: 14.5px;
}
.form-summary-title { font-weight: 600; color: var(--navy); }
.form-summary ul { margin: 6px 0 0; padding-left: 18px; }

.form-footer {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 4px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--page);
  border-top: 1px solid var(--line);
}
.form-footer .btn { flex: 1 1 0; }
@media (min-width: 600px) {
  .form-footer { margin-inline: -24px; padding-inline: 24px; }
  .form-footer .btn { flex: 0 0 auto; min-width: 120px; }
}
.import-clear-warning { margin: 16px 0 0; font-size: 14.5px; line-height: 1.45; }
.change-clear { overflow-wrap: anywhere; }

.form-footer-inline {
  position: static;
  margin: 16px 0 0;
  padding: 0;
  border-top: 0;
  background: transparent;
  flex-wrap: wrap;
}
.form-footer-inline .btn { flex: 1 1 auto; }
@media (min-width: 600px) {
  .form-footer-inline { margin-inline: 0; padding-inline: 0; }
  .form-footer-inline .btn { flex: 0 0 auto; }
}

/* ---------- More: links, data, colour key ---------- */

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-list > li + li { border-top: 1px solid var(--line); }
.card-list :focus-visible { outline-offset: -3px; }

.link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 16px;
  color: var(--ink);
  text-decoration: none;
  transition: background-color var(--speed) ease;
}
.link-row:hover { background: var(--soft); }
.link-text { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.link-label { font-weight: 600; color: var(--navy); overflow-wrap: anywhere; }
.link-host {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--muted);
}
.link-icon { color: var(--muted); }

.links-form {
  padding: 4px 16px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.link-edit-list { list-style: none; margin: 0; padding: 0; }
.link-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  column-gap: 10px;
  padding: 14px 0 6px;
  border-top: 1px solid var(--line);
}
.link-edit:first-child { border-top: 0; }
.link-edit .form-field { grid-column: 1; margin-bottom: 8px; }
.link-remove { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.link-add { margin-top: 4px; }
@media (min-width: 720px) {
  .link-edit {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) 44px;
    align-items: end;
    padding-bottom: 14px;
  }
  .link-edit .form-field { grid-column: auto; margin-bottom: 0; }
  .link-remove { grid-column: auto; grid-row: auto; }
}

.key-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  font-size: 14px;
}
.key-row .pill { flex: 0 0 auto; }
.key-text { padding-top: 2px; }

/* ---------- import ---------- */

.steps {
  margin: 0 0 16px;
  padding: 14px 16px 14px 36px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14.5px;
}
.steps li + li { margin-top: 6px; }
.steps strong { font-weight: 600; color: var(--navy); }

.file-pick { position: relative; }
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.file-zone {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 88px;
  padding: 18px;
  border: 1.5px dashed #a9a395;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--navy);
  cursor: pointer;
  transition: border-color var(--speed) ease, background-color var(--speed) ease;
}
.file-zone:hover,
.file-zone.is-over { border-color: var(--navy); background: var(--soft); }
.file-input:focus-visible + .file-zone { outline: 2px solid var(--navy); outline-offset: 2px; }
.file-icon { width: 30px; height: 30px; }
.file-zone-text { display: flex; flex-direction: column; min-width: 0; }
.file-zone-title { font-size: 16px; font-weight: 600; }
.file-zone-sub { font-size: 13px; color: var(--muted); }

.import-status:not(:empty) { margin-top: 12px; font-size: 14.5px; color: var(--muted); }
.import-body { margin-top: 16px; }
.import-body > * + * { margin-top: 12px; }

.card {
  padding: 18px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
@media (min-width: 600px) {
  .card { padding: 20px 22px; }
}
.import-file { margin-bottom: 6px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.import-sentence {
  margin-bottom: 8px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--navy);
}
.import-group { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.import-group-title { margin-bottom: 4px; font-size: 15px; font-weight: 600; color: var(--ink); }
.import-list { margin: 8px 0 0; padding-left: 18px; font-size: 14px; overflow-wrap: anywhere; }
.import-list > li + li { margin-top: 6px; }
.change-task { font-weight: 500; }
.change-fields { list-style: none; margin: 2px 0 0; padding: 0; font-size: 13.5px; }
.import-more { margin-top: 8px; font-size: 14px; }
.import-more summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--navy);
  font-weight: 500;
  cursor: pointer;
}
.import-group .hint,
.import-preview > .hint { margin-top: 8px; }

.notice {
  padding: 12px 14px;
  border-left: 3px solid var(--navy);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--navy-tint);
  font-size: 14.5px;
}
.notice-title { font-weight: 600; color: var(--navy); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.notice .btn { margin-top: 10px; }

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .tabs, .toast, .skip-link, .banner { display: none !important; }
  .main { padding-bottom: 0; }
  body { background: #fff; }
}
