/* Shift Tool */
:root {
  --ink: #1f2a44;
  --ink-2: #3a4660;
  --muted: #5f6b80;
  --line: #dde3ea;
  --line-2: #c9d2dd;
  --bg: #eef1f5;
  --surface: #ffffff;
  --accent: #0f6e74;
  --accent-ink: #0b5257;
  --accent-soft: #e2f1f1;
  --amber: #f2b84b;
  --amber-soft: #fdf3dd;
  --amber-ink: #7a4f00;
  --red: #b4382a;
  --red-soft: #fbe9e6;
  --green: #2f7d4f;
  --green-soft: #e3f3e9;
  --radius: 8px;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1.02rem; margin: 1rem 0 .4rem; }
p { margin: 0 0 .8rem; }
code { background: #eef2f6; padding: 1px 5px; border-radius: 4px; font-size: .9em; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.opt { color: var(--muted); font-weight: 400; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute; left: -9999px; }
:focus-visible { outline: 3px solid #6fb6bb; outline-offset: 2px; }

/* ---------- top bar & shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; height: 58px; padding: 0 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); text-decoration: none; font-size: 1.08rem; white-space: nowrap; }
.brand-lg { font-size: 1.35rem; justify-content: center; margin-bottom: 18px; }
.brand-mark { flex: none; }
.company-switch select, .company-name { font: inherit; font-size: .95rem; }
.company-switch select { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; background: #f8fafc; max-width: 240px; }
.company-name { color: var(--muted); border-left: 1px solid var(--line); padding-left: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: .95rem; }
.topbar-user form { margin: 0; }
.user-link { color: var(--ink); text-decoration: none; }
.nav-toggle { display: none; background: none; border: 0; padding: 6px; color: var(--ink); cursor: pointer; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }

.shell { display: flex; min-height: calc(100vh - 58px); }
.sidenav { width: 210px; flex: none; padding: 18px 10px; background: var(--surface); border-right: 1px solid var(--line); }
.sidenav a { display: block; padding: 8px 12px; margin-bottom: 2px; border-radius: 6px; color: var(--ink-2); text-decoration: none; }
.sidenav a:hover { background: #f1f4f7; color: var(--ink); }
.sidenav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.nav-group { margin: 16px 12px 6px; font-size: .82rem; color: var(--muted); }
.nav-mobile-only { display: none !important; }
.content { flex: 1; min-width: 0; padding: 26px 30px 60px; max-width: 1180px; }

/* ---------- page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { margin: .2rem 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards, sections ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card.narrow { max-width: 560px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 26px 0 10px; }
.section-head h2 { margin: 0; }
.empty { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); background: rgba(255,255,255,.5); }
.empty p { margin-bottom: 12px; }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: .95rem; font-weight: 700; line-height: 1.2; padding: 9px 15px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f4f6f9; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); color: #fff; }
.btn-danger { color: var(--red); border-color: #e6bdb7; }
.btn-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: .87rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; margin: 0; }

label { display: block; font-weight: 700; font-size: .93rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=color], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: 5px; font: inherit; font-weight: 400; font-size: 1rem; color: var(--ink);
  padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 6px; background: #fff;
}
input[type=color] { padding: 2px; height: 40px; width: 70px; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; width: 17px; height: 17px; flex: none; }
.check strong { font-weight: 700; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: .86rem; margin-top: 3px; }
.stack > * + * { margin-top: 14px; }
.stack h2 { margin-top: 26px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-2 > *, .grid-3 > *, .grid-4 > * { margin-top: 0 !important; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; }

/* ---------- flashes, badges ---------- */
.flash { padding: 11px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid; }
.flash-ok { background: var(--green-soft); border-color: #b9dcc6; color: #1f5a37; }
.flash-error { background: var(--red-soft); border-color: #eec3bd; color: #8a271c; }
.flash-warn { background: var(--amber-soft); border-color: #f0d79d; color: var(--amber-ink); }
.flash-info { background: var(--accent-soft); border-color: #b8dadb; color: var(--accent-ink); }
.badge { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: #e9edf2; color: var(--ink-2); white-space: nowrap; }
.badge-published, .badge-active { background: var(--green-soft); color: #1f5a37; }
.badge-assigned, .badge-pending, .badge-invited { background: var(--amber-soft); color: var(--amber-ink); }
.badge-suspended, .badge-disabled { background: var(--red-soft); color: #8a271c; }
.badge-open { background: var(--amber); color: #3b2700; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .86rem; font-weight: 700; color: var(--ink-2); }
.chip::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--pc, var(--accent)); flex: none; }
.chip-any::before { background: transparent; border: 2px solid var(--line-2); width: 8px; height: 8px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; }
table.list { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.list th { text-align: left; font-size: .84rem; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #f8fafc; white-space: nowrap; }
table.list td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list td.num, table.list th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- hours bar ---------- */
.bar { position: relative; height: 8px; background: #e7ebf0; border-radius: 99px; overflow: hidden; min-width: 90px; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 99px; }
.bar.over > span { background: var(--amber); }

/* ---------- the shift ticket ---------- */
.day-group { margin-bottom: 22px; }
.day-label { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; font-size: 1.02rem; }
.day-label .muted { font-weight: 400; font-size: .9rem; }
.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.ticket { position: relative; display: grid; grid-template-columns: 92px 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.ticket-time { padding: 14px 10px 14px 14px; border-right: 2px dashed var(--line); font-variant-numeric: tabular-nums; }
.ticket-time strong { display: block; font-size: 1.05rem; line-height: 1.2; }
.ticket-time span { display: block; color: var(--muted); font-size: .85rem; }
.ticket::before, .ticket::after { content: ""; position: absolute; left: 85px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); }
.ticket::before { top: -9px; clip-path: inset(50% 0 0 0); }
.ticket::after { bottom: -9px; clip-path: inset(0 0 50% 0); }
.ticket-body { padding: 12px 14px; min-width: 0; }
.ticket-title { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.ticket-title h3 { margin: 0; font-size: 1.02rem; }
.ticket-meta { color: var(--muted); font-size: .88rem; margin: 2px 0 6px; overflow-wrap: anywhere; }
.ticket-notes { font-size: .88rem; background: #f6f8fa; border-radius: 6px; padding: 6px 9px; margin: 6px 0; white-space: pre-line; }
.seats { list-style: none; margin: 8px 0 0; padding: 0; }
.seats li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid #eef1f4; font-size: .93rem; }
.seat-who { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.seat-open { color: var(--amber-ink); font-weight: 700; }
.seat-open::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); margin-right: 6px; vertical-align: 1px; }
.seat-note { display: block; color: var(--muted); font-size: .84rem; white-space: pre-line; }
.seat-mine { background: var(--accent-soft); margin: 0 -8px; padding: 6px 8px !important; border-radius: 6px; border-top-color: transparent !important; }
.seat-src { font-size: .78rem; color: var(--muted); }
.ticket.mine { border-color: #a9d3d5; }
.ticket.past { opacity: .62; }
.ticket-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ---------- availability editor ---------- */
.week-grid { display: grid; gap: 10px; }
.wday { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.wday:first-child { border-top: 0; }
.wday-name { font-weight: 700; padding-top: 8px; }
.ranges { display: grid; gap: 8px; }
.range-row { display: grid; grid-template-columns: 1fr 1fr 1.3fr auto; gap: 8px; align-items: center; }
.range-row input, .range-row select { margin-top: 0; }
.lvl-2 { border-left: 4px solid var(--accent) !important; }
.lvl-1 { border-left: 4px solid #8fb9bc !important; }
.lvl-0 { border-left: 4px solid var(--red) !important; }
.timeline { position: relative; height: 16px; background: #eef1f4; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.timeline span { position: absolute; top: 0; bottom: 0; }
.timeline .t2 { background: var(--accent); }
.timeline .t1 { background: #8fb9bc; }
.timeline .t0 { background: repeating-linear-gradient(45deg, #d77a6f 0 4px, #f0c3bd 4px 8px); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- need editor (slot form) ---------- */
.need { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: #fafbfc; }
.need + .need { margin-top: 10px; }
.need-head { display: grid; grid-template-columns: 2fr 90px auto; gap: 10px; align-items: end; }
.need-seats { margin-top: 10px; display: grid; gap: 6px; }
.need-seats label { font-weight: 400; font-size: .88rem; color: var(--muted); }
.need-seats input { margin-top: 2px; }
.weekday-picks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.weekday-picks label { font-weight: 400; display: flex; gap: 5px; align-items: center; }

/* ---------- candidate picker ---------- */
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 60px); color: var(--ink); }
dialog::backdrop { background: rgba(20, 30, 50, .45); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.dlg-head h2 { margin: 0; font-size: 1.08rem; }
.dlg-body { padding: 14px 18px 18px; }
.cand { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid #eef1f4; }
.cand:first-child { border-top: 0; }
.cand-why { display: block; font-size: .83rem; color: var(--red); }
.cand-ok { display: block; font-size: .83rem; color: var(--muted); }
.cand form { margin: 0; }

/* ---------- stats ---------- */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; min-width: 150px; }
.stat b { display: block; font-size: 1.35rem; }
.stat span { color: var(--muted); font-size: .88rem; }

.checklist { list-style: none; padding: 0; margin: 0 0 16px; }
.checklist li { padding: 3px 0; }
.checklist .ok { color: var(--green); }
.checklist .bad { color: var(--red); font-weight: 700; }

/* ---------- auth pages ---------- */
body.bare { background: var(--bg); }
.auth-wrap { max-width: 440px; margin: 0 auto; padding: 48px 16px; }
.auth-card h1 { margin-bottom: 14px; }
.auth-links { margin-top: 16px; font-size: .95rem; }

.activity { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.activity li { padding: 6px 0; border-top: 1px solid #eef1f4; }
.activity time { color: var(--muted); margin-right: 8px; }
details summary { cursor: pointer; font-weight: 700; }
details[open] summary { margin-bottom: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .company-name { display: none; }
  .topbar { padding: 0 10px; gap: 8px; }
  .topbar-user .user-link { display: none; }
  .company-switch select { max-width: 150px; }
  .sidenav { position: fixed; top: 58px; left: 0; bottom: 0; z-index: 30; transform: translateX(-100%); transition: transform .18s ease; box-shadow: 4px 0 20px rgba(0,0,0,.12); overflow-y: auto; width: 240px; }
  .sidenav.open { transform: none; }
  .nav-mobile-only { display: block !important; }
  .content { padding: 18px 16px 50px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .tickets { grid-template-columns: 1fr; }
  .ticket { grid-template-columns: 74px 1fr; }
  .ticket::before, .ticket::after { left: 67px; }
  .ticket-time { padding: 12px 8px 12px 11px; }
  .seats li { flex-wrap: wrap; }
  .seats li > .btn-row { margin-left: auto; }
  .table-wrap table.list td, .table-wrap table.list th { padding: 9px 10px; }
  .wday { grid-template-columns: 1fr; gap: 4px; }
  .wday-name { padding-top: 0; }
  .range-row { grid-template-columns: 1fr 1fr; }
  .need-head { grid-template-columns: 1fr 80px; }
  .need-head > :last-child { grid-column: 1 / -1; }
  h1 { font-size: 1.4rem; }
}
@media (max-width: 420px) {
  .brand span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
