/* Anchor Care & Growth portal — one stylesheet.
   Palette from the Care & Growth brand (cream / green / yellow / pink /
   blue), calmed for clinical use: the brand's saturation belongs on a
   marketing page, not on a screen someone reads at 11pm mid-shift.

   Entity hues follow the FM portal's doctrine: colour says what a thing IS,
   never what state it's in. Red is reserved for genuine problems and is
   never an entity hue. */

:root {
  --bg:      #F7F3EF;
  --card:    #FFFFFF;
  --card2:   #FBF7F3;   /* elevated tier — fixes the "washed/muddy" look */
  --line:    #E6DED5;
  --text:    #1C1A17;
  --text2:   #55504A;
  --text3:   #7A736B;   /* 4.6:1 on --card — do not lighten */

  --green:   #2C4D2E;   /* Care & Growth primary */
  --green2:  #E7EFE5;
  --yellow:  #C99A1F;   /* darkened from brand #F3CD60 for text contrast */
  --yellow2: #FBF1D8;
  --pink:    #C2607A;
  --pink2:   #FBEAEF;
  --blue:    #2F6D8C;
  --blue2:   #E4EFF4;
  --danger:  #B3261E;
  --danger2: #FBEAE8;

  /* entity tokens (--e is read by every treatment below) */
  --c-shift: var(--green);   --c-shift2: var(--green2);
  --c-part:  var(--blue);    --c-part2:  var(--blue2);
  --c-note:  var(--pink);    --c-note2:  var(--pink2);
  --c-pay:   var(--yellow);  --c-pay2:   var(--yellow2);

  --radius: 14px;
  --gut: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.e-shift { --e: var(--c-shift); --e2: var(--c-shift2); }
.e-part  { --e: var(--c-part);  --e2: var(--c-part2); }
.e-note  { --e: var(--c-note);  --e2: var(--c-note2); }
.e-pay   { --e: var(--c-pay);   --e2: var(--c-pay2); }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
main { max-width: 560px; margin: 0 auto; padding: var(--gut); }

/* ---- header ---- */
.hdr {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gut) 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.hdr-t { font-weight: 700; font-size: 17px; flex: 1; }
.hdr .back, .hdr .who {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; border-radius: 50%;
  text-decoration: none; color: var(--text);
  background: var(--card); border: 1px solid var(--line);
  font-size: 13px; font-weight: 700;
}
.hdr .back { font-size: 22px; line-height: 1; padding-bottom: 3px; }
.hdr .bell { position: relative; display: inline-flex; align-items: center;
  justify-content: center; min-width: 34px; height: 34px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  text-decoration: none; font-size: 15px; }
.hdr .bell i { position: absolute; top: -4px; right: -4px; min-width: 18px;
  height: 18px; padding: 0 4px; border-radius: 9px;
  /* fixed strong red in BOTH themes: --danger lightens for dark-mode text
     contrast, and white-on-light-pink made the count unreadable */
  background: #C0271E; color: #fff;
  font-size: 11px; font-weight: 700; font-style: normal; line-height: 1;
  display: flex; align-items: center; justify-content: center; }
/* `display:flex` above outranks the UA rule for the hidden attribute, so
   without this an EMPTY red dot sits there whenever the count is zero. */
.hdr .bell i[hidden] { display: none; }

/* ---- cards ---- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin: 0 0 12px;
}
.card h2 { margin: 0 0 8px; font-size: 17px; }
.card h3 { margin: 14px 0 6px; font-size: 15px; color: var(--text2); }
.card p  { margin: 6px 0; }
.muted { color: var(--text3); font-size: 14px; }
.empty { color: var(--text3); font-style: italic; padding: 8px 0; }

.shift-card { border-left: 4px solid var(--c-shift); }
.shift-card .when { font-size: 20px; font-weight: 700; }
.shift-card .who  { color: var(--text2); }

/* ---- pills ---- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .01em;
  background: var(--card2); color: var(--text2); border: 1px solid var(--line);
}
.pill.ok    { background: var(--green2); color: var(--green); border-color: transparent; }
.pill.warn  { background: var(--yellow2); color: var(--yellow); border-color: transparent; }
.pill.due   { background: var(--pink2); color: var(--pink); border-color: transparent; }
.pill.info  { background: var(--blue2); color: var(--blue); border-color: transparent; }
.pill.bad   { background: var(--danger2); color: var(--danger); border-color: transparent; }

/* ---- the action card (outstanding work, blueprint §8.2) ---- */
.action {
  display: flex; align-items: center; gap: 10px;
  background: var(--pink2); border: 1px solid transparent;
  border-left: 4px solid var(--c-note);
  border-radius: var(--radius); padding: 12px 14px; margin: 0 0 10px;
  text-decoration: none; color: var(--text);
}
.action-b { flex: 1; display: flex; flex-direction: column; }
.action-b span { font-size: 14px; color: var(--text2); }
.action-m { font-weight: 700; white-space: nowrap; }
.action-go { color: var(--text3); font-size: 20px; }

/* ---- participant tabs (the shared-shift workspace) ---- */
.ptabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 12px; padding-bottom: 2px; }
.ptabs a {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  text-decoration: none; color: var(--text2); font-weight: 600; font-size: 14px;
}
.ptabs a.on { background: var(--c-part); border-color: var(--c-part); color: #fff; }
.ptabs a.house.on { background: var(--text2); border-color: var(--text2); }

/* ---- forms ---- */
label { display: block; font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
label.chk { display: flex; align-items: flex-start; gap: 10px; font-weight: 500;
  padding: 10px 12px; background: var(--card2); border: 1px solid var(--line);
  border-radius: 10px; margin: 8px 0 0; }
label.chk input { width: 20px; height: 20px; margin: 1px 0 0; flex: 0 0 auto; }
label.chk .muted { display: block; font-size: 13px; }

/* note entries */
.entry { padding: 10px 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry-b { font-weight: 600; }
.entry-o { margin-top: 4px; padding: 8px 10px; background: var(--card2);
  border-radius: 8px; font-size: 15px; }
.entry.shared .entry-b::before { content: 'shared · '; color: var(--text3);
  font-weight: 500; }
.outcome-form { margin-top: 6px; }
details.exc { margin-top: 10px; }
details.exc summary { cursor: pointer; color: var(--text2); font-size: 14px;
  padding: 8px 0; }
h2.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text3); margin: 18px 0 8px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--text);
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
}
textarea { min-height: 84px; resize: vertical; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 13px 16px; margin: 12px 0 0;
  font: inherit; font-weight: 700; cursor: pointer;
  background: var(--green); color: #fff;
  border: 0; border-radius: 12px; text-decoration: none;
}
button.ghost, .btn.ghost {
  background: var(--card); color: var(--text); border: 1px solid var(--line);
}
button.small, .btn.small { width: auto; padding: 8px 14px; font-size: 14px; margin: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; min-width: 0; }
/* datetime-local is intrinsically wide (dd/mm/yyyy, --:-- --) and two of
   them side by side overflow a 375px phone — the second field was cut off
   the screen. Stack them where the pair cannot fit. */
@media (max-width: 430px) { .row { display: block; } .row > * + * { margin-top: 10px; } }
.err { background: var(--danger2); color: var(--danger); padding: 10px 12px;
       border-radius: 10px; margin: 10px 0; font-size: 14px; }

/* ---- lists / matrix ---- */
.matrix { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.matrix .row2 {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--card);
}
.matrix .row2:last-child { border-bottom: 0; }
.row2.day { padding: 10px 12px; border-bottom: 1px solid var(--line); background: transparent; }
.row2.day:last-of-type { border-bottom: 0; }
form.inline { display: inline; margin: 0; }
form.inline button { width: auto; margin: 0; padding: 4px 10px; font-size: 13px; }
.matrix .row2 .nm { flex: 1; font-weight: 600; }

.tl { list-style: none; margin: 0; padding: 0; }
.tl li { padding: 8px 0 8px 14px; border-left: 2px solid var(--line); position: relative; }
.tl li::before { content: ''; position: absolute; left: -5px; top: 14px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.tl .t { font-size: 13px; color: var(--text3); }

/* ---- tab bar ---- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; text-align: center; padding: 8px 2px; font-size: 13px; font-weight: 600;
  color: var(--text3); text-decoration: none; border-radius: 10px;
  /* An admin who also works shifts carries seven tabs. Without nowrap
     "Pay run" broke onto a second line and made the whole bar taller. */
  white-space: nowrap;
}
/* Below ~360px seven labels genuinely cannot fit — shrink rather than wrap. */
@media (max-width: 380px) { .tabs a { font-size: 12px; } }
.tabs a.on { color: var(--green); background: var(--green2); }

/* ---- login ---- */
.login-wrap { max-width: 380px; margin: 12vh auto; padding: var(--gut); }
.brand { text-align: center; margin-bottom: 18px; }
.brand b { display: block; font-size: 22px; letter-spacing: -.01em; }
.brand span { color: var(--text3); font-size: 14px; }

/* The "switch account" block on /login?switch=1 — the header avatar leads
   here rather than straight to /logout, so signing in as another role is
   possible on a phone without knowing the /logout URL. */
.signed-in { background: var(--card2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 14px; margin-bottom: 16px; }
.signed-in b { display: block; font-size: 15px; }
.signed-in span { color: var(--text3); font-size: 13px; word-break: break-all; }
.signed-in p { margin: 8px 0 0; font-size: 14px; color: var(--text3); }
.signed-in a { color: var(--green); font-weight: 600; text-decoration: none; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150F; --card: #1F1D17; --card2: #262319; --line: #332F26;
    --text: #F4EFE7; --text2: #C9C1B4; --text3: #9A9184;
    --green: #7FB07F; --green2: #24301F;
    --yellow: #E0BB63; --yellow2: #322A17;
    --pink: #E098AC; --pink2: #332126;
    --blue: #7FB6CE; --blue2: #1B2A31;
    --danger: #F0918A; --danger2: #341D1B;
  }
  .action { background: var(--pink2); }
}
