/* Staff portal at /admin/. Loaded after site.css, which supplies colors, type, buttons and form fields.
   Built for a phone first: a tab bar along the bottom, big touch targets, one column. */
@view-transition { navigation: none; }

.portal { --red: #B42318; --orange: #F08C00; --tabbar: 64px; min-height: 100vh; background: var(--sage-50); padding-bottom: 0; }
.portal--in { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px)); }

/* ---------- header ---------- */
.portal-top { position: relative; background: var(--green-950); color: var(--white); }
.portal-top::after { content: ""; display: block; height: 6px; background: var(--turf); }
.portal-top__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 28px; padding-block: 12px; }
.portal-brand { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; color: var(--white); font: 600 1.15rem/1.2 var(--font-head); text-decoration: none; }
.portal-brand img { width: 30px; height: 32px; }
.portal-brand em { display: block; font: 500 0.82rem/1.2 var(--font-body); color: #B9D6C3; }
.portal-nav { display: none; }

/* ---------- phone tab bar ---------- */
.portal-tabbar { position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(6, 1fr); padding-bottom: env(safe-area-inset-bottom, 0px); border-top: 1px solid var(--line); background: var(--white); }
.portal-tabbar a { display: grid; justify-items: center; align-content: center; gap: 2px; min-width: 0; min-height: var(--tabbar); color: var(--muted); font: 600 0.72rem/1.1 var(--font-body); text-decoration: none; }
.portal-tabbar a[href="/"] { border-left: 1px solid var(--line); }
@media (max-width: 350px) { .portal-tabbar a { font-size: 0.66rem; } }
.portal-tabbar a[aria-current="page"] { color: var(--green-800); box-shadow: inset 0 3px 0 var(--green-700); }
.portal-tabbar svg { width: 24px; height: 24px; }

@media (min-width: 960px) {
  .portal--in { padding-bottom: 0; }
  .portal-tabbar { display: none; }
  .portal-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; }
  .portal-nav a, .portal-nav button { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border: 0; border-radius: 999px; background: none; color: var(--white); font: 500 0.98rem var(--font-body); text-decoration: none; cursor: pointer; }
  .portal-nav a:hover, .portal-nav button:hover { background: rgba(255, 255, 255, 0.12); }
  .portal-nav a[aria-current="page"] { background: var(--white); color: var(--green-950); }
  .portal-nav .portal-nav__site { margin-left: 8px; border: 1px solid rgba(255, 255, 255, 0.45); }
  .portal-nav button { margin-left: 8px; text-decoration: underline; text-underline-offset: 3px; }
}

/* ---------- page ---------- */
.portal-main { max-width: 860px; padding-block: clamp(20px, 4vw, 40px) 56px; }
.portal-main h1 { margin: 0 0 6px; font-size: clamp(1.7rem, 5vw, 2.3rem); }
.portal-intro { margin: 0 0 20px; max-width: 60ch; color: var(--muted); }
.portal-main h1 + :not(.portal-intro) { margin-top: 18px; }
.portal-note { margin: 0 0 18px; padding: 12px 16px; border-left: 4px solid var(--green-700); border-radius: var(--radius-sm); background: var(--white); font-weight: 600; }
.portal-note--warn { border-left-color: var(--red); }
.portal-sub { display: flex; align-items: center; gap: 10px; margin: 26px 0 10px; font-size: 1.2rem; }
.portal-card > .portal-sub:first-of-type { margin-top: 0; }
.portal-count { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; background: var(--sage-100); color: var(--green-950); font: 700 0.9rem var(--font-body); }

.portal-card { display: block; margin: 0 0 18px; padding: clamp(16px, 3.5vw, 26px); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); color: inherit; }
.portal-card h2 { margin: 0 0 8px; font-size: 1.25rem; }
.portal-card > p { margin: 0 0 14px; color: var(--muted); }
.portal-card > :last-child { margin-bottom: 0; }
.portal-empty { text-align: left; border-style: dashed; }
.portal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
.portal-actions .btn { flex: 1 1 auto; }
@media (min-width: 640px) { .portal-actions .btn { flex: 0 0 auto; } }

/* ---------- lights and pills ---------- */
.light { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 600; font-size: 0.95rem; white-space: nowrap; }
.light__dot { flex: none; width: 14px; height: 14px; border-radius: 50%; background: #98A29C; box-shadow: 0 0 0 3px rgba(152, 162, 156, 0.25); }
.light--green .light__dot { background: var(--green-600); box-shadow: 0 0 0 3px rgba(46, 141, 86, 0.22); }
.light--orange .light__dot { background: var(--orange); box-shadow: 0 0 0 3px rgba(240, 140, 0, 0.25); }
.light--red .light__dot { background: var(--red); box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.22); }
.check .light, .portal-status .light { white-space: normal; }
.portal-fieldset .check { display: flex; }
.pill { display: inline-flex; align-items: center; min-height: 28px; padding: 2px 12px; border-radius: 999px; background: var(--sage-100); color: var(--green-950); font-size: 0.88rem; font-weight: 600; white-space: nowrap; }
.pill--quiet { background: none; border: 1px solid var(--line); color: var(--muted); }

/* ---------- home ---------- */
.portal-today { margin: 0 0 18px; padding: clamp(18px, 4vw, 30px); border-radius: var(--radius-lg); background: var(--green-900) repeating-radial-gradient(circle at 110% -20%, transparent 0 38px, rgba(255, 255, 255, 0.045) 38px 76px); color: var(--white); }
.portal-today__date { margin: 0 0 4px; color: #B9D6C3; font-weight: 600; }
.portal-today h2 { margin: 0 0 12px; color: var(--white); font-size: clamp(1.6rem, 6vw, 2.2rem); }
.portal-today__lights { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0 0 18px; }
.portal-today .light { color: var(--white); }
.portal-today .light--green .light__dot { background: var(--green-400); }
.portal-today .portal-actions { margin: 0; }
.portal-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 18px; }
@media (min-width: 720px) { .portal-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.portal-tile { display: grid; gap: 2px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); color: inherit; text-decoration: none; }
.portal-tile:hover, .portal-links a:hover, .portal-row > a:hover strong { border-color: var(--green-700); }
.portal-tile__label { color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.portal-tile__number { font: 600 2rem/1.1 var(--font-head); color: var(--green-900); }
.portal-tile__detail { color: var(--muted); font-size: 0.9rem; }
.portal-tile--alert { border-color: var(--red); box-shadow: inset 4px 0 0 var(--red); }
.portal-tile--watch { border-color: var(--orange); box-shadow: inset 4px 0 0 var(--orange); }
@media (max-width: 420px) { .portal-tiles { gap: 8px; } .portal-tile { padding: 12px 10px; } .portal-tile__number { font-size: 1.7rem; } }
.portal-links { display: grid; gap: 10px; margin: 0 0 18px; padding: 0; list-style: none; }
.portal-links a { display: grid; gap: 2px; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); color: inherit; text-decoration: none; }
.portal-links span { color: var(--muted); }
.portal-signout { margin-top: 24px; }

/* ---------- lists ---------- */
.portal-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin: 0 0 14px; }
.portal-search input { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid #9FB2A4; border-radius: var(--radius-sm); background: var(--white); font: inherit; }
.portal-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.portal-tabs a { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--white); color: var(--green-900); font-weight: 500; text-decoration: none; }
.portal-tabs a[aria-current="page"] { border-color: var(--green-700); background: var(--green-700); color: var(--white); }
.portal-rows { display: grid; gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; }
.portal-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); }
.portal-row > a, .portal-row__text { display: grid; gap: 2px; flex: 1 1 220px; min-width: 0; color: inherit; text-decoration: none; }
.portal-row > a strong { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 4px; }
.portal-row span, .portal-check__text span { color: var(--muted); font-size: 0.95rem; }
.portal-row .light, .portal-check .light { color: var(--ink); }
.portal-row__pills { display: flex; flex-wrap: wrap; gap: 6px; }
.portal-row--review { align-items: flex-start; }
.portal-row__quote { margin-top: 4px; color: var(--ink) !important; white-space: pre-line; }
.portal-row__tools { display: flex; flex-wrap: wrap; gap: 0 10px; flex: 1 1 100%; }
.portal-linkbtn { min-height: 44px; padding: 0 6px; border: 0; background: none; color: var(--green-700); font: 600 0.95rem var(--font-body); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.portal-plain { margin: 0; padding-left: 1.2em; color: var(--ink); }
.portal-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin: 0 0 14px; }
.portal-status--summary { max-width: none; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); }
.portal-allclear { margin: 0 0 6px; }

/* ---------- checklists (schedule, setup) ---------- */
.portal-checks { display: grid; gap: 0; margin: 0 0 8px; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.portal-checks li + li { border-top: 1px solid var(--line); }
.portal-check { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; min-height: 56px; padding: 10px 14px; cursor: pointer; }
.portal-check:has(input:checked) { background: var(--sage-50); }
.portal-check input { flex: none; width: 24px; height: 24px; accent-color: var(--green-700); }
.portal-check__text { display: grid; gap: 1px; flex: 1 1 180px; min-width: 0; }
.portal-check .light { margin-left: 38px; }
@media (min-width: 560px) { .portal-check .light { margin-left: 0; } }
.portal-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 16px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.portal-bar .field { flex: 1 1 180px; }
.portal-bar .btn { flex: 1 1 220px; }
.portal-bar--stick { position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 8px); z-index: 5; margin-top: 14px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); box-shadow: 0 6px 24px rgba(14, 42, 24, 0.16); }
@media (min-width: 960px) { .portal-bar--stick { bottom: 12px; } }
.portal-found { min-height: 1.5em; margin: -6px 0 12px; color: var(--muted); }
.portal-found:empty { display: none; }
.portal-add summary { cursor: pointer; min-height: 32px; font: 600 1.15rem/1.4 var(--font-head); color: var(--green-900); }
.portal-add[open] summary { margin-bottom: 14px; }
.portal-setup { display: grid; gap: 10px; }
.portal-setup__row[hidden] { display: none; }
.portal-setup__row { margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); min-width: 0; }
.portal-setup__row:has(input[type="checkbox"]:checked) { border-color: var(--green-700); box-shadow: inset 4px 0 0 var(--green-700); }
.portal-setup__fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 0 14px 14px; }
.portal-setup__fields .field > label { font-size: 0.9rem; color: var(--muted); }

/* ---------- forms ---------- */
.portal-form { display: grid; gap: 18px; justify-items: start; }
.portal-form > .field, .portal-form > .portal-pair, .portal-form > .portal-trio, .portal-form > .portal-fieldset, .portal-form > .portal-remind { width: 100%; }
.portal-form > h2 { margin: 6px 0 -6px; }
.portal-form > h2:first-of-type { margin-top: 0; }
.portal-form .portal-card { width: 100%; margin: 0; }
.portal-pair, .portal-trio { display: grid; gap: 14px; }
@media (min-width: 560px) { .portal-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } .portal-trio { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.portal-fieldset { display: grid; gap: 10px; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 0; }
.portal-fieldset legend { padding: 0 6px; font-weight: 700; }
.portal-remind { display: grid; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.portal-remind .field { max-width: 12rem; }
.portal .field input[type="date"], .portal .field input[type="file"] { max-width: 100%; }

/* ---------- log ---------- */
.portal-log { display: grid; margin: 0; padding: 0; list-style: none; }
.portal-log li { display: grid; grid-template-columns: minmax(0, 10.5rem) minmax(0, 1fr); gap: 2px 16px; padding: 10px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.portal-log li:first-child { border-top: 0; }
.portal-log li > span:first-child { color: var(--muted); font-size: 0.95rem; }
.portal-bars { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.portal-bars li { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr) 3.5rem; align-items: center; gap: 12px; }
.portal-bars li > span:first-child { color: var(--muted); font-size: 0.95rem; }
.portal-bars strong { text-align: right; }
.portal-bars--wide li { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 2.75rem; }
.portal-bars--wide li > span:first-child { color: var(--ink); overflow-wrap: anywhere; }
.portal-bars__sub { display: block; font-size: 0.85rem; color: var(--muted); }
.portal-bars--photos li > span:first-child { display: flex; align-items: center; gap: 10px; }
.portal-bars--photos img { flex: none; width: 64px; height: 48px; border-radius: 6px; object-fit: cover; }
div.portal-tile { cursor: default; }
@media (max-width: 560px) { .portal-log li { grid-template-columns: 1fr; } }

/* ---------- inventory ---------- */
.portal-stock { display: grid; gap: 0; margin: 0 0 8px; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.portal-stock__row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 14px; }
.portal-stock__row + .portal-stock__row { border-top: 1px solid var(--line); }
.portal-stock__what { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; min-width: 0; }
.portal-stock__what a { flex: 1 1 100%; color: var(--green-900); }
.portal-stock__detail { color: var(--muted); font-size: 0.95rem; }
.portal-stock .field > label { font-size: 0.9rem; color: var(--muted); }
@media (min-width: 640px) { .portal-stock__row { grid-template-columns: minmax(0, 1fr) 11rem; align-items: center; } }
.meter { flex: 1 1 100%; display: block; height: 8px; border-radius: 999px; background: var(--sage-100); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; background: var(--green-600); }
.meter--orange span { background: var(--orange); }
.meter--red span { background: var(--red); }

/* ---------- prices ---------- */
.portal-price { padding-block: 14px; border-top: 1px solid var(--line); }
.portal-price__inputs { display: grid; grid-template-columns: auto minmax(0, 9rem) minmax(0, 10rem); align-items: center; gap: 8px; }
/* A public price can be a range: "$ 23.50 to 30.00 per yard". The unit drops to its own row on a phone. */
.portal-price__inputs--range { grid-template-columns: auto minmax(0, 6.5rem) auto minmax(0, 6.5rem) minmax(0, 9rem); }
@media (max-width: 520px) { .portal-price__inputs--range { grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); } .portal-price__inputs--range select { grid-column: 1 / -1; } }

/* ---------- quote requests ---------- */
.portal-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.portal-list a { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto auto; align-items: center; gap: 6px 16px; padding: 14px 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); color: inherit; text-decoration: none; }
.portal-list a:hover { border-color: var(--green-700); }
.portal-list span { color: var(--muted); }
.portal-tag { padding: 3px 10px; border-radius: 999px; background: var(--sage-100); color: var(--green-950) !important; font-size: 0.85rem; font-weight: 600; }
.portal-tag--new { background: var(--green-700); color: var(--white) !important; }
.portal-pre { margin: 0 0 14px; padding: 16px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sage-50); font: 0.95rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.portal-delete { margin-top: 28px; }
.portal-delete summary { cursor: pointer; color: var(--red); font-weight: 600; }
.portal-delete p { margin: 10px 0; color: var(--muted); }
@media (max-width: 640px) { .portal-list a { grid-template-columns: 1fr auto; } .portal-list a span:nth-of-type(2) { grid-column: 1; } }
.portal-back { margin: 20px 0 0; }
.portal-back a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
