/* Team Hub - William Place Dental Aesthetics.
   Tokens carried from the website (site/assets/css/main.css): flat purples, teal for state,
   gold only for the one primary action per screen, radius 10/14/6, near-flat shadows. */

:root {
  --purple: #3f2056;
  --purple-deep: #311941;
  --purple-soft: #f8f5fb;
  --teal: #58b6af;
  --teal-deep: #3d918b;
  --teal-soft: #e8f5f4;
  --gold: #c2a878;
  --gold-deep: #a98a52;
  --ink: #2c2436;
  --muted: #6b6276;
  --line: #ece8f0;
  --white: #fff;
  --cream: #faf6f1;
  --blush: #f4eff8;
  --lilac: #e9def3;
  --red: #b8434f;
  --red-soft: #fbecee;
  --amber: #a8741a;
  --amber-soft: #fbf3e2;

  --font-sans: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: "Fraunces", Georgia, "Times New Roman", serif;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(63, 32, 86, 0.08);
  --nav-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--purple);
  line-height: 1.15;
  margin: 0 0 .5rem;
  letter-spacing: -0.01em;
  font-variation-settings: "SOFT" 40;
}
h1 { font-size: 1.65rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; font-family: var(--font-sans); font-weight: 600; letter-spacing: 0; }
p { margin: 0 0 .75rem; }
a { color: var(--purple); text-decoration-color: var(--teal); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 2px; }
.num, td, .stat b { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

.boot { min-height: 100vh; display: grid; place-items: center; }

/* --- Layout -------------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 12px;
}
.top .logo { height: 34px; width: auto; display: block; }
.top .app-name { font-size: .78rem; color: var(--muted); border-left: 1px solid var(--line); padding-left: 12px; line-height: 1.2; }
.top .spacer { flex: 1; }
.top .who { font-size: .85rem; color: var(--muted); }
.bell { position: relative; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--purple); }
.bell .dot { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; border-radius: 9px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; text-align: center; padding: 0 4px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--white); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; text-align: center; text-decoration: none; color: var(--muted);
  font-size: .72rem; padding: 8px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.nav a svg { width: 22px; height: 22px; }
.nav a.on { color: var(--purple); font-weight: 600; }
.nav a.on svg { color: var(--teal-deep); }

main { max-width: 1180px; margin: 0 auto; padding: 18px 16px calc(var(--nav-h) + 28px); }

@media (min-width: 900px) {
  .nav { position: sticky; top: 55px; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); justify-content: center; gap: 4px; padding: 0 16px; }
  .nav a { flex: 0 0 auto; flex-direction: row; gap: 8px; font-size: .9rem; padding: 12px 16px; border-bottom: 2px solid transparent; }
  .nav a.on { border-bottom-color: var(--teal); }
  .nav a svg { width: 18px; height: 18px; }
  main { padding-bottom: 48px; }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.grid { display: grid; gap: 14px; }
@media (min-width: 900px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
  .grid.home { grid-template-columns: 1.1fr 1fr; align-items: start; }
}

.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 16px;
}
.card > h2:first-child { margin-bottom: 10px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }

/* --- Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--purple); background: var(--purple); color: #fff;
  border-radius: var(--radius); padding: 10px 16px; font-weight: 500; cursor: pointer;
  text-decoration: none; line-height: 1.2; min-height: 42px;
}
.btn:hover { background: var(--purple-deep); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--purple-deep); font-weight: 600; }
.btn.gold:hover { background: var(--gold-deep); border-color: var(--gold-deep); color: #fff; }
.btn.line { background: var(--white); color: var(--purple); border-color: var(--line); }
.btn.line:hover { border-color: var(--purple); background: var(--white); }
.btn.teal { background: var(--teal-deep); border-color: var(--teal-deep); }
.btn.danger { background: var(--white); color: var(--red); border-color: #efcdd1; }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--purple); text-decoration: underline; text-decoration-color: var(--teal); cursor: pointer; }

/* --- Clock card ----------------------------------------------------------- */
.clock { text-align: center; padding: 22px 16px; }
.clock .now { font-family: var(--font-serif); font-size: 2.6rem; color: var(--purple); line-height: 1; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.clock .date { color: var(--muted); margin-bottom: 14px; }
.clock .state { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--purple-soft); font-size: .9rem; margin-bottom: 16px; }
.clock .state.in { background: var(--teal-soft); color: var(--teal-deep); }
.clock .state i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.clock .btn { min-height: 56px; font-size: 1.1rem; width: 100%; max-width: 360px; }
.clock .shift-line { margin-top: 12px; font-size: .88rem; color: var(--muted); }
.clock .where { margin-top: 10px; font-size: .82rem; color: var(--muted); }

/* --- Stats ----------------------------------------------------------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { background: var(--purple-soft); border-radius: var(--radius); padding: 10px 12px; }
.stat b { display: block; font-family: var(--font-serif); font-size: 1.5rem; color: var(--purple); line-height: 1.1; font-weight: 600; }
.stat span { font-size: .78rem; color: var(--muted); }
.stat.warn b { color: var(--red); }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; display: flex; margin: 10px 0 4px; }
.bar i { display: block; height: 100%; }

/* --- Lists ------------------------------------------------------------------ */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 500; }
.list .sub { font-size: .82rem; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 600; color: #fff; background: var(--purple); flex: none; }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 500; padding: 2px 9px; border-radius: 999px; background: var(--purple-soft); color: var(--purple); white-space: nowrap; }
.chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.chip.in { background: var(--teal-soft); color: var(--teal-deep); }
.chip.due { background: var(--amber-soft); color: var(--amber); }
.chip.away { background: var(--blush); color: var(--muted); }
.chip.pending { background: var(--amber-soft); color: var(--amber); }
.chip.approved { background: var(--teal-soft); color: var(--teal-deep); }
.chip.declined, .chip.cancelled { background: var(--red-soft); color: var(--red); }
.chip.flag { background: var(--red-soft); color: var(--red); }
.chip.ok { background: var(--teal-soft); color: var(--teal-deep); }

.whos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.whos .p { display: flex; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
.whos .p .n { font-weight: 500; font-size: .9rem; line-height: 1.2; }
.whos .p .t { font-size: .75rem; color: var(--muted); }
.team-label { font-size: .75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 12px 0 6px; }

/* --- Tables ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-weight: 600; font-size: .78rem; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--white); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--purple-soft); }
td.r, th.r { text-align: right; }
.neg { color: var(--red); font-weight: 500; }
.pos { color: var(--teal-deep); font-weight: 500; }
tr.weekend td { background: #fcfbfd; }
tr.bh td { background: var(--blush); }
tr.flagged td:first-child { box-shadow: inset 3px 0 0 var(--red); }

/* --- Rota ------------------------------------------------------------------------ */
.rota-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rota-nav .label { font-weight: 600; color: var(--purple); min-width: 170px; text-align: center; }
.day-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.day-tabs button { flex: none; border: 1px solid var(--line); background: var(--white); border-radius: var(--radius); padding: 6px 12px; cursor: pointer; text-align: center; line-height: 1.2; }
.day-tabs button b { display: block; font-size: .95rem; color: var(--purple); }
.day-tabs button span { font-size: .72rem; color: var(--muted); }
.day-tabs button.on { background: var(--purple); border-color: var(--purple); }
.day-tabs button.on b, .day-tabs button.on span { color: #fff; }
.day-tabs button.today:not(.on) { border-color: var(--teal); }

.rota-day { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.room { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 10px 12px; }
.room-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.room-h b { font-family: var(--font-serif); color: var(--purple); font-size: 1.02rem; }
.room-h span { font-size: .72rem; color: var(--muted); }
.slot { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius-sm); background: var(--purple-soft); margin-top: 5px; min-height: 40px; }
.slot .role { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); width: 44px; flex: none; }
.slot .nm { font-weight: 500; flex: 1; min-width: 0; line-height: 1.25; }
.slot .nm small { display: block; font-weight: 400; font-size: .74rem; color: var(--muted); }
.slot.empty { background: var(--white); border: 1px dashed var(--line); }
.slot.empty .nm { color: var(--muted); font-weight: 400; }
.slot.away { background: var(--red-soft); }
.slot.away .nm { text-decoration: line-through; text-decoration-color: rgba(184, 67, 79, .5); }
.slot.me { box-shadow: inset 0 0 0 2px var(--teal); }
.slot.editable { cursor: pointer; }
.slot.editable:hover { box-shadow: inset 0 0 0 1px var(--purple); }
.slot .ovr { font-size: .65rem; color: var(--gold-deep); font-weight: 600; }
.gap-warn { font-size: .74rem; color: var(--red); margin-top: 4px; }
.unplaced { margin-top: 14px; }

/* week table on wide screens */
.rota-week { display: none; }
@media (min-width: 1100px) {
  .rota-week { display: block; }
  .rota-mobile { display: none; }
}
.rota-week table { table-layout: fixed; }
.rota-week th:first-child, .rota-week td:first-child { width: 96px; }
.rota-week td { padding: 6px; }
.rota-week .slot { margin-top: 3px; min-height: 34px; padding: 4px 6px; font-size: .84rem; }
.rota-week .slot .role { display: none; }
.rota-week td.loc b { font-family: var(--font-serif); color: var(--purple); display: block; }
.rota-week td.loc span { font-size: .72rem; color: var(--muted); }
.rota-week th.today { color: var(--teal-deep); }

/* --- Forms ----------------------------------------------------------------------- */
.field { margin-bottom: 14px; }
.field > label, .field > .lbl { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 5px; }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=month], select, textarea {
  width: 100%; border: 1px solid #ddd5e4; border-radius: var(--radius); padding: 10px 12px; background: var(--white); min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(88, 182, 175, .2); }
input.bad { border-color: var(--red); }
textarea { min-height: 80px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline .to { color: var(--muted); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.switch label { font-weight: 600; font-size: .9rem; }
.toggle { position: relative; width: 46px; height: 26px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle span { position: absolute; inset: 0; background: #d9d2e0; border-radius: 13px; cursor: pointer; transition: background .15s; }
.toggle span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked + span { background: var(--teal-deep); }
.toggle input:checked + span::after { transform: translateX(20px); }
.toggle input:focus-visible + span { outline: 3px solid var(--teal); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; margin: 6px 0; }
.total-band { background: var(--purple-soft); border-radius: var(--radius); padding: 12px 14px; display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 14px; }
.total-band .v { color: var(--purple); }
.msg { border-radius: var(--radius); padding: 10px 12px; font-size: .88rem; margin-bottom: 12px; }
.msg.err { background: var(--red-soft); color: var(--red); }
.msg.info { background: var(--teal-soft); color: var(--teal-deep); }
.msg.warn { background: var(--amber-soft); color: var(--amber); }

/* pattern editor */
.pattern-row { display: grid; grid-template-columns: 56px 1fr 1fr 80px 100px; gap: 6px; align-items: center; margin-bottom: 6px; }
.pattern-row .d { font-weight: 600; color: var(--purple); }
.pattern-row input, .pattern-row select { min-height: 38px; padding: 6px 8px; }

/* --- Sheet (slide-over panel, like the "Add time off" drawer) --------------------------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(44, 36, 54, .4); z-index: 50; display: flex; justify-content: flex-end; }
.sheet {
  background: var(--white); width: 100%; max-width: 440px; height: 100%; overflow-y: auto;
  padding: 0 18px 24px; box-shadow: -4px 0 24px rgba(44, 36, 54, .15);
  animation: slidein .18s ease-out;
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-h { position: sticky; top: 0; background: var(--white); display: flex; align-items: center; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); margin-bottom: 16px; z-index: 1; }
.sheet-h h2 { margin: 0; flex: 1; font-size: 1.1rem; }
.x { background: none; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }
@media (max-width: 600px) {
  .sheet-bg { align-items: flex-end; }
  .sheet { max-width: none; height: auto; max-height: 92vh; border-radius: 16px 16px 0 0; animation: slideup .18s ease-out; }
  @keyframes slideup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
}

/* --- Login ------------------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 400px; padding: 28px 24px; }
.login .logo { width: 230px; max-width: 80%; display: block; margin: 0 auto 6px; }
.login .app-title { text-align: center; color: var(--muted); font-size: .85rem; margin-bottom: 22px; }
.login .rule { width: 40px; height: 2px; background: var(--gold); margin: 0 auto 22px; }
.code-input { letter-spacing: .5em; text-align: center; font-size: 1.4rem !important; font-variant-numeric: tabular-nums; }

/* --- Toast ----------------------------------------------------------------------------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px); transform: translateX(-50%); background: var(--purple-deep); color: #fff; padding: 10px 16px; border-radius: var(--radius); z-index: 60; font-size: .9rem; max-width: calc(100% - 32px); box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.err { background: var(--red); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.empty-state { text-align: center; color: var(--muted); padding: 24px 8px; font-size: .9rem; }
.tabs { display: inline-flex; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; gap: 2px; }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: .88rem; color: var(--muted); }
.tabs button.on { background: var(--purple); color: #fff; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

@media print {
  .top, .nav, .no-print, .btn { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
}

/* --- Nav badges, More menu ----------------------------------------------------------------- */
.nav a { position: relative; }
.nav .badge { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 17px; height: 17px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10.5px; line-height: 17px; padding: 0 4px; font-weight: 600; }
.nav .mob-only { display: flex; }
.nav .desk-only { display: none; }
@media (min-width: 900px) {
  .nav .mob-only { display: none; }
  .nav .desk-only { display: flex; }
  .nav .badge { position: static; margin-left: 2px; }
}
.more-list a { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 500; }
.more-list a svg { color: var(--teal-deep); }
.more-list a .badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 9px; font-size: 11px; padding: 1px 7px; }

/* --- Events ------------------------------------------------------------------------------------ */
.event { display: flex; gap: 14px; align-items: flex-start; }
.event .when { flex: none; width: 58px; text-align: center; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 0; background: var(--white); }
.event .when b { display: block; font-family: var(--font-serif); font-size: 1.5rem; color: var(--purple); line-height: 1.05; }
.event .when span { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.event .body { flex: 1; min-width: 0; }
.event h3 { margin: 0 0 2px; font-size: 1.02rem; }
.event.cancelled h3 { text-decoration: line-through; color: var(--muted); }
.rsvp { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.rsvp button { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: .88rem; }
.rsvp button.on.going { background: var(--teal-deep); border-color: var(--teal-deep); color: #fff; }
.rsvp button.on.maybe { background: var(--gold); border-color: var(--gold); color: var(--purple-deep); }
.rsvp button.on.no { background: var(--muted); border-color: var(--muted); color: #fff; }

/* --- Chat -------------------------------------------------------------------------------------- */
.chat-list li { cursor: pointer; }
.chat-list .unread { background: var(--teal-deep); color: #fff; border-radius: 999px; font-size: .74rem; padding: 1px 8px; font-weight: 600; }
.chat-list .preview { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 360px; }
@media (min-width: 900px) { .thread { height: calc(100vh - 230px); } }
.thread-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.thread-h h2 { margin: 0; flex: 1; font-size: 1.05rem; }
.msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; background: #fdfcfe; }
.msg-b { max-width: 80%; padding: 8px 12px; border-radius: 14px; background: var(--white); border: 1px solid var(--line); align-self: flex-start; white-space: pre-wrap; word-wrap: break-word; }
.msg-b.mine { align-self: flex-end; background: var(--purple); color: #fff; border-color: var(--purple); }
.msg-b .meta { font-size: .7rem; color: var(--muted); margin-top: 3px; }
.msg-b.mine .meta { color: rgba(255,255,255,.7); text-align: right; }
.msg-b .from { font-size: .74rem; font-weight: 600; color: var(--teal-deep); margin-bottom: 2px; }
.msg-b a.file { display: flex; align-items: center; gap: 8px; margin-top: 4px; padding: 6px 8px; border-radius: 8px; background: rgba(63,32,86,.06); color: inherit; text-decoration: none; font-size: .86rem; }
.msg-b.mine a.file { background: rgba(255,255,255,.14); }
.day-sep { align-self: center; font-size: .72rem; color: var(--muted); margin: 8px 0 2px; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid var(--line); background: var(--white); }
.composer textarea { min-height: 42px; max-height: 140px; resize: none; padding: 9px 12px; }
.composer .attach { flex: none; width: 42px; height: 42px; border-radius: var(--radius); border: 1px solid var(--line); display: grid; place-items: center; cursor: pointer; color: var(--purple); background: var(--white); }
.composer .attach input { display: none; }
.pending-files { font-size: .8rem; color: var(--muted); padding: 0 12px 6px; }
.member-picks { max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 10px; }

/* --- Shift-based rota ------------------------------------------------------------------- */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; margin-right: 6px; vertical-align: 1px; }
.room-h { justify-content: flex-start; gap: 0; align-items: center; }
.room-h span:not(.dot) { margin-left: auto; }
.shift { display: block; padding: 5px 8px; border-radius: var(--radius-sm); background: var(--purple-soft); margin-top: 5px; line-height: 1.25; font-size: .86rem; }
.shift b { font-weight: 600; font-size: .78rem; color: var(--purple); }
.shift span { display: block; }
.shift small { display: block; font-size: .72rem; color: var(--muted); }
.shift.me { box-shadow: inset 0 0 0 2px var(--teal); }
.shift.free { background: var(--white); border: 1px dashed #d8cfe0; }
.shift.away { background: var(--red-soft); }
.shift.away span { text-decoration: line-through; text-decoration-color: rgba(184, 67, 79, .5); }
.shift.off { background: var(--white); border: 1px solid var(--line); }
.shift.editable { cursor: pointer; }
.shift.editable:hover { box-shadow: inset 0 0 0 1px var(--purple); }
.shift .chip { display: inline-flex; font-size: .65rem; padding: 0 6px; }
.add-shift { display: block; width: 100%; margin-top: 5px; border: 1px dashed #d8cfe0; background: none; border-radius: var(--radius-sm); color: var(--muted); cursor: pointer; line-height: 1.6; font-size: .9rem; }
.add-shift:hover { border-color: var(--purple); color: var(--purple); }
.rota-week td.loc { white-space: nowrap; }
.rota-week td.loc b { display: inline; }
.rota-week td.loc span:not(.dot) { display: block; padding-left: 16px; }
table.master td { min-width: 130px; vertical-align: top; padding: 6px; }
table.master td.loc { white-space: nowrap; }
table.master td.loc span:not(.dot) { display: block; font-size: .72rem; color: var(--muted); padding-left: 16px; }
.viewas-bar { background: var(--gold); color: var(--purple-deep); text-align: center; padding: 6px 12px; font-size: .88rem; font-weight: 500; }
.viewas-bar button { margin-left: 8px; }
@media print { .add-shift, .viewas-bar { display: none !important; } .rota-week { display: block !important; } .rota-mobile { display: none !important; } }
.shift[draggable="true"] { cursor: grab; }
.shift.dragging { opacity: .45; }
.drop-on { outline: 2px dashed var(--teal); outline-offset: -2px; background: var(--teal-soft) !important; }

.avatar.photo { object-fit: cover; padding: 0; background: var(--lilac); }

/* rota week grid: room/row labels wrap inside a wider first column (were spilling into Monday) */
.rota-week th:first-child, .rota-week td:first-child { width: 150px; }
.rota-week td.loc { white-space: normal; line-height: 1.25; padding-left: 12px; }
.rota-week td.loc b { display: inline; font-size: .95rem; }
.rota-week td.loc .dot { margin-right: 5px; }
/* "+" add-shift buttons only show when you point at a cell (computers); always there on touch screens */
@media (hover: hover) {
  .rota-week .add-shift { opacity: 0; transition: opacity .12s; }
  .rota-week td:hover .add-shift, .rota-week .add-shift:focus { opacity: 1; }
}
/* policies */
.doc-list li { gap: 12px; }
.doc-ic { width: 38px; height: 38px; border-radius: var(--radius); background: var(--purple-soft); color: var(--purple); display: grid; place-items: center; flex: none; }
.click-row { cursor: pointer; }
.click-row:hover { background: var(--purple-soft); }

/* --- Phones: nothing may be wider than the screen ------------------------------------------ */
html, body { max-width: 100%; overflow-x: hidden; }
.whos .p { min-width: 0; }
.whos .p > div { min-width: 0; }
.whos .chip, .list .chip, .sub .chip { white-space: normal; text-align: left; }
.grid > * { min-width: 0; }
img, table { max-width: 100%; }

/* Home order on phones: clock, things to do, then my info, then the team */
@media (max-width: 899px) {
  .grid.home { display: flex; flex-direction: column; gap: 14px; }
  .grid.home > .grid { display: contents; }
  .o1 { order: 1; } .o2 { order: 2; } .o3 { order: 3; } .o4 { order: 4; }
  .o5 { order: 5; } .o6 { order: 6; } .o7 { order: 7; } .o8 { order: 8; }
  main { padding-left: 12px; padding-right: 12px; }
  .page-head h1 { font-size: 1.45rem; }
  .card { padding: 14px; }
  .top { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .top .logo { height: 28px; }
  .top .who { display: none; }
  /* holiday numbers: one compact row of four */
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .stat { padding: 8px 6px; text-align: center; }
  .stat b { font-size: 1.2rem; }
  .stat span { font-size: .68rem; line-height: 1.2; display: block; }
  .card-head { flex-wrap: wrap; }
  .card-head h2 { font-size: 1.1rem; }
  .clock { padding: 18px 12px; }
  .clock .now { font-size: 2.2rem; }
}
.whos .p { align-items: flex-start; }
.whos .p .t { font-size: .72rem; color: var(--muted); line-height: 1.3; margin: 1px 0 3px; }
.whos .p.is-away .n { color: var(--muted); }
.whos .chip { font-size: .7rem; }

/* ---------------------------------------------------------------- polish: headings, clock ring, nav, toasts, skeletons */
.h-ic { display: flex; align-items: center; gap: 8px; }
.h-ic svg { color: var(--teal-deep); flex: none; }
.card > .h-ic { margin-top: 0; }
.btn svg { vertical-align: -3px; }
.btn.small svg { width: 15px; height: 15px; }

.ring-wrap { position: relative; width: 168px; height: 168px; margin: 2px auto 10px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--line); }
.ring-fg { stroke: var(--teal); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-in .now { margin: 0 0 4px; }
.ring-sub { font-size: .78rem; color: var(--muted); }
.clock .btn svg { margin-right: 4px; }

@media (max-width: 899px) {
  .nav a svg { padding: 3px 14px; width: 50px; height: 28px; border-radius: 999px; box-sizing: border-box; transition: background .15s; }
  .nav a.on svg { background: var(--teal-soft); }
}

.toast { display: flex; align-items: center; gap: 10px; }
.toast .t-ic { flex: none; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; background: rgba(255,255,255,.18); }

.skel { display: grid; gap: 14px; }
.sk { border-radius: var(--radius-lg); background: linear-gradient(90deg, var(--line) 25%, var(--purple-soft) 50%, var(--line) 75%); background-size: 200% 100%; animation: sk 1.2s ease-in-out infinite; }
.sk-h { height: 30px; width: 40%; }
.sk-card { height: 120px; }
.sk-card.short { height: 70px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } .ring-fg { transition: none; } }

/* ---------------------------------------------------------------- team profiles */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }
.tm { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--white); font: inherit; color: inherit; cursor: pointer; text-align: center; min-width: 0; }
.tm:hover { border-color: var(--teal); }
.tm:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.tm .avatar { width: 72px; height: 72px; font-size: 1.3rem; margin-bottom: 6px; }
.tm-n { font-weight: 600; color: var(--purple); }
.tm-j { font-size: .78rem; color: var(--muted); line-height: 1.3; overflow-wrap: anywhere; }
.tm-f { font-size: .72rem; color: var(--teal-deep); margin-top: 2px; }
.tm-big { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.tm-big .avatar { width: 84px; height: 84px; font-size: 1.5rem; }
.favs { margin: 0 0 16px; display: grid; gap: 2px; }
.favs dt { font-size: .75rem; color: var(--muted); margin-top: 10px; }
.favs dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.photo-edit { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.photo-edit label.btn { cursor: pointer; }
.row2 > * { min-width: 0; }
.row2 input[type=date], .row2 input[type=time] { min-width: 0; width: 100%; }
.pattern-row { grid-template-columns: 56px 1fr 1fr 80px 100px 62px; }
.pattern-row .hrs { font-size: .82rem; color: var(--teal-deep); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.pattern-row.small .hrs { color: var(--muted); font-weight: 400; }
.pattern-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 10px 12px; margin: 4px 0 8px; border-radius: var(--radius); background: var(--teal-soft); }
.pattern-total b { color: var(--teal-deep); }
.pattern-total .pt-days { font-size: .82rem; }

/* pattern rows: lay out by the width of the panel they're in (the Add person panel is narrow even on a PC) */
.sheet { container-type: inline-size; }
@container (max-width: 620px) {
  .pattern-row { grid-template-columns: 40px 1fr 1fr 64px; grid-template-areas: "d st fi hrs" ". lu fq fq"; row-gap: 4px; margin-bottom: 10px; }
  .pattern-row > .d { grid-area: d; }
  .pattern-row > .st { grid-area: st; }
  .pattern-row > .fi { grid-area: fi; }
  .pattern-row > .lu-w { grid-area: lu; }
  .pattern-row .lu-w span { display: inline; }
  .pattern-row > .fq { grid-area: fq; }
  .pattern-row > .hrs { grid-area: hrs; text-align: right; }
  .pattern-row.small { grid-template-areas: "d st fi hrs"; margin-bottom: 2px; }
  .pattern-row.small .lunch, .pattern-row.small .freq { display: none; }
  .pattern-row.small .hrs { display: block; }
  .pattern-row .lu::placeholder { color: var(--muted); }
}
.pattern-row .lu { min-width: 0; }
.extra-row { display: grid; grid-template-columns: 110px 1fr; gap: 8px; max-width: 320px; }
.allow-out { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 12px; border-radius: var(--radius); background: var(--purple-soft); margin: 4px 0 6px; }
.allow-out b { color: var(--purple); font-size: 1.1rem; }
.allow-out .small { flex-basis: 100%; }
.lu-w { display: flex; align-items: center; gap: 6px; min-width: 0; margin: 0; font-weight: 400; }
.lu-w input { min-width: 0; width: 100%; }
.lu-w span { display: none; font-size: .78rem; color: var(--muted); white-space: nowrap; }
/* shifts take their room's colour: a soft tint with a solid edge, so each room reads at a glance */
.shift.tinted { background: color-mix(in srgb, var(--c) 14%, var(--white)); border-left: 3px solid var(--c); }
.shift.tinted.away { background: var(--red-soft); border-left-color: var(--red); }
.shift.tinted.free { background: var(--white); border: 1px dashed color-mix(in srgb, var(--c) 45%, var(--white)); border-left: 3px solid color-mix(in srgb, var(--c) 45%, var(--white)); }

.note-line { font-size: .8rem; color: var(--ink); margin-top: 3px; overflow-wrap: anywhere; }
.note-line span { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-right: 4px; }
.note-line.mgr span { color: var(--teal-deep); }

.clock-opts { text-align: left; max-width: 360px; margin: 0 auto 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.clock-opts .check { font-size: .9rem; }
.clock-opts .field { margin: 8px 0 2px; }
.chip.swap { background: var(--lilac); color: var(--purple); }

.ts-table td:first-child { white-space: nowrap; }
.ts-table td:nth-child(2) { white-space: nowrap; }
.ts-table .chip { white-space: normal; text-align: left; margin: 1px 0; }
.ts-table .chip { border-radius: 8px; }
.ts-table td:nth-child(3) { min-width: 118px; }
.ts-table td:nth-child(6) { min-width: 170px; }
