:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --paper: #f6f8fb;
  --card: #ffffff;
  --surface: #f8fafc;
  --line: #dfe5ec;
  --line-strong: #cdd6e1;
  --brand: #246bfe;
  --brand-dark: #1754cf;
  --brand-soft: #edf4ff;
  --teal: #087f73;
  --teal-soft: #e8f7f4;
  --amber: #a15c07;
  --amber-soft: #fff4df;
  --red: #b42318;
  --red-soft: #fff0ee;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 26px rgba(16, 24, 40, .05);
  --radius: 14px;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
.hidden { display: none !important; }

.shell { width: 100%; margin: 0 auto; padding: 24px clamp(16px, 2.4vw, 40px) 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; color: white; background: var(--ink); font: 800 14px var(--font-mono); }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 16px; letter-spacing: -.02em; }
.brand span { margin-top: 1px; color: var(--muted); font-size: 11px; }
.identity { display: flex; align-items: center; gap: 12px; }
.identity-copy { text-align: right; }
.identity-copy strong, .identity-copy span { display: block; }
.identity-copy strong { font-size: 12px; }
.identity-copy span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.signout { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: white; text-decoration: none; font-size: 11px; font-weight: 700; }

.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.page-heading h1 { margin: 0; font-size: clamp(23px, 2vw, 30px); letter-spacing: -.035em; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.week-nav { display: flex; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: 0 1px 2px rgba(16,24,40,.03); }
.week-nav button { height: 34px; min-width: 36px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-weight: 750; }
.week-nav button:hover { color: var(--ink); background: var(--surface); }
.week-nav .this-week { padding: 0 13px; color: var(--ink); background: var(--surface); }

.notice { display: none; margin: 0 0 16px; padding: 11px 13px; border-radius: 9px; font-size: 12px; line-height: 1.45; }
.notice.show { display: block; }
.notice.error { color: #8b2018; border: 1px solid #f0b9b4; background: var(--red-soft); }
.notice.success { color: #075e54; border: 1px solid #a9ddd5; background: var(--teal-soft); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric { min-width: 0; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 1px 2px rgba(16,24,40,.025); }
.metric-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.metric-value { display: flex; align-items: baseline; gap: 7px; margin-top: 7px; }
.metric-value strong { font: 750 24px var(--font-mono); letter-spacing: -.04em; }
.metric-value span { color: var(--muted); font-size: 10px; }
.metric.attention .metric-value strong { color: var(--amber); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.workspace { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 14px; align-items: start; }
.shift-editor { position: sticky; top: 14px; overflow: hidden; }
.panel-inner { padding: 18px; }
.panel h2 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.panel-sub { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.hours-card { margin: -18px -18px 18px; padding: 16px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.hours-owner { margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.hours-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.hours-top strong { font: 750 24px var(--font-mono); letter-spacing: -.04em; }
.hours-top span { color: var(--muted); font-size: 10px; }
.bar { height: 5px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: var(--line); }
.bar-fill { width: 0; height: 100%; border-radius: inherit; background: var(--brand); transition: width .2s ease; }
.hours-caption { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted); font-size: 9px; }

.field { margin-top: 13px; }
label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
select, input, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 10px; color: var(--ink); outline: none; background: white; }
select, input { height: 40px; }
textarea { min-height: 72px; padding-top: 9px; resize: vertical; }
select:focus, input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.time-row { display: grid; grid-template-columns: 1fr 20px 1fr; align-items: end; gap: 7px; }
.time-arrow { display: grid; place-items: center; height: 40px; color: var(--muted); }
.calculation { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding: 11px 12px; border: 1px solid #bfd3ff; border-radius: 9px; background: var(--brand-soft); }
.calculation span { color: var(--brand-dark); font-size: 11px; font-weight: 700; }
.calculation strong { color: var(--brand-dark); font: 750 19px var(--font-mono); }
.form-hint { min-height: 34px; margin: 8px 1px 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.primary, .secondary, .danger-button { min-height: 40px; padding: 0 14px; border-radius: 8px; font-weight: 750; }
.primary { border: 1px solid var(--brand); color: white; background: var(--brand); }
.primary:hover:not(:disabled) { background: var(--brand-dark); }
.secondary { border: 1px solid var(--line-strong); color: var(--ink); background: white; }
.secondary:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-dark); }
.danger-button { border: 1px solid #efb0aa; color: var(--red); background: var(--red-soft); }
.wide { width: 100%; }

.schedule-panel { min-width: 0; overflow: hidden; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; font-weight: 700; }
.legend-dot { width: 8px; height: 8px; border-radius: 3px; background: var(--brand); }
.board-scroll { max-width: 100%; overflow: auto; overscroll-behavior: contain; }
.week-grid { display: grid; grid-template-columns: 220px repeat(7, minmax(135px, 1fr)) 112px; min-width: 1280px; }
.week-cell { min-width: 0; min-height: 104px; padding: 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: white; }
.week-cell.header { position: sticky; top: 0; z-index: 12; min-height: 54px; padding: 10px; color: var(--muted); background: var(--surface); font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.week-cell.header strong { display: block; margin-top: 4px; color: var(--ink); font: 750 12px var(--font-mono); letter-spacing: 0; text-transform: none; }
.week-cell.person-cell { position: sticky; left: 0; z-index: 6; display: flex; align-items: flex-start; gap: 10px; border-right-color: var(--line-strong); background: white; }
.week-cell.person-cell.header { z-index: 20; background: var(--surface); }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; color: var(--operator-text, var(--brand-dark)); background: var(--operator-bg, var(--brand-soft)); font-size: 10px; font-weight: 850; }
.person-copy { min-width: 0; flex: 1; }
.person-copy strong, .person-copy span { display: block; }
.person-copy strong { overflow: hidden; color: var(--ink); font-size: 12px; line-height: 1.3; text-overflow: ellipsis; }
.person-copy span { overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.person-status { margin-top: 7px !important; overflow: visible !important; white-space: normal !important; }
.day-cell.today { background: #f8fbff; }
.day-cell.past { background: #fbfcfd; }
.empty-shift { color: #b3becb; font-size: 10px; }
.shift-stack { display: grid; gap: 6px; }
.shift-card { position: relative; min-width: 0; padding: 9px 28px 9px 10px; border: 1px solid var(--operator-border, #b9d0f3); border-left: 4px solid var(--operator-accent, var(--brand)); border-radius: 9px; color: var(--operator-text, var(--ink)); background: var(--operator-bg, var(--brand-soft)); }
.shift-card strong, .shift-card span { display: block; }
.shift-card strong { font: 750 11px var(--font-mono); white-space: nowrap; }
.shift-time-range { padding-right: 18px; }
.shift-time-range span { margin-top: 2px; font: 700 9px var(--font-mono); }
.shift-card span { margin-top: 4px; font-size: 9px; line-height: 1.35; }
.shift-card .release { position: absolute; top: 5px; right: 5px; display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 6px; color: inherit; background: rgba(255,255,255,.55); font-size: 15px; }
.shift-card .release:hover { background: white; }
.week-total { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; text-align: right; }
.week-total strong { font: 750 16px var(--font-mono); }
.week-total span { margin-top: 4px; color: var(--muted); font-size: 9px; }

.status { display: inline-flex; align-items: center; width: fit-content; padding: 4px 7px; border-radius: 999px; font-size: 8px; font-weight: 850; letter-spacing: .035em; text-transform: uppercase; }
.status.ready { color: #087066; background: var(--teal-soft); }
.status.review, .status.open { color: var(--amber); background: var(--amber-soft); }
.status.missing { color: var(--red); background: var(--red-soft); }
.status.neutral { color: var(--muted); background: #eef2f6; }

.time-panel { margin-top: 14px; overflow: hidden; }
.time-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.clock-copy { min-width: 185px; text-align: right; }
.clock-copy strong, .clock-copy span { display: block; }
.clock-copy strong { font-size: 11px; }
.clock-copy span { margin-top: 2px; color: var(--muted); font: 10px var(--font-mono); }
.small-button { min-height: 34px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: white; font-size: 10px; font-weight: 750; }
.small-button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-dark); }
.small-button.accent { color: white; border-color: var(--brand); background: var(--brand); }
.small-button.accent:hover:not(:disabled) { color: white; background: var(--brand-dark); }
.time-content { padding: 16px 18px 18px; }
.section-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 9px; }
.section-label { color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.section-note { color: var(--muted); font-size: 9px; }
.table-scroll { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.hours-table { width: 100%; min-width: 820px; border-collapse: collapse; }
.hours-table th, .hours-table td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; }
.hours-table th { color: var(--muted); background: var(--surface); font-size: 8px; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.hours-table tr:last-child td { border-bottom: 0; }
.hours-table .number { font: 750 11px var(--font-mono); text-align: right; }
.hours-table .person-name { font-size: 11px; font-weight: 750; }
.variance.negative { color: var(--red); }
.variance.positive { color: var(--teal); }
.entry-section { margin-top: 18px; }
.entry-list { display: grid; gap: 7px; }
.time-entry { display: grid; grid-template-columns: minmax(150px, .9fr) minmax(260px, 1.5fr) 82px auto; align-items: center; gap: 12px; min-height: 52px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: white; font-size: 10px; }
.time-entry strong, .time-entry span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time-entry .entry-meta { margin-top: 3px; color: var(--muted); font-size: 9px; }
.time-entry .entry-meta { display: block; }
.time-entry .entry-time { color: var(--muted); }
.time-entry .entry-hours { font: 750 11px var(--font-mono); text-align: right; }
.entry-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.empty-state { padding: 26px 12px; color: var(--muted); text-align: center; font-size: 11px; }

.people-panel { display: none; margin-top: 14px; overflow: hidden; }
.people-panel.show { display: block; }
.people-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.invite-form { display: grid; grid-template-columns: 170px minmax(230px, 1fr) auto; gap: 9px; align-items: end; }
.invite-form .field { margin: 0; }
.people-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 9px; padding: 16px 18px; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.remove-person { border: 0; color: var(--red); background: transparent; font-size: 10px; font-weight: 750; }
.admin-badge { padding: 4px 7px; border-radius: 999px; color: var(--brand-dark); background: var(--brand-soft); font-size: 8px; font-weight: 850; text-transform: uppercase; }

dialog { width: min(590px, calc(100vw - 24px)); max-height: calc(100vh - 36px); padding: 0; overflow: auto; border: 0; border-radius: 16px; color: var(--ink); background: white; box-shadow: 0 24px 80px rgba(16,24,40,.25); }
dialog::backdrop { background: rgba(15,23,42,.48); backdrop-filter: blur(3px); }
.dialog-head { padding: 19px 20px 15px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 19px; }
.dialog-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.dialog-body { padding: 18px 20px; }
.dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.dialog-grid .full { grid-column: 1 / -1; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: var(--ink); font-size: 11px; font-weight: 700; }
.check-row input { width: 16px; height: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }

.gate { display: none; max-width: 520px; margin: 12vh auto 0; padding: 34px; text-align: center; }
.gate.show { display: block; }
.gate h1 { margin: 0 0 10px; font-size: 22px; }
.gate p { color: var(--muted); line-height: 1.55; }
.email-pill { display: inline-block; margin: 8px 0 18px; padding: 8px 12px; border-radius: 999px; color: var(--brand-dark); background: var(--brand-soft); font-size: 12px; font-weight: 750; }

@media (max-width: 1120px) {
  .workspace { grid-template-columns: 280px minmax(0, 1fr); }
  .people-head { display: block; }
  .invite-form { margin-top: 15px; }
}
@media (max-width: 880px) {
  .shell { padding: 16px 12px 36px; }
  .workspace { display: flex; flex-direction: column; }
  .shift-editor { position: static; width: 100%; }
  .schedule-panel { width: 100%; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-head { display: block; }
  .legend { justify-content: flex-start; margin-top: 12px; }
  .time-actions { flex-wrap: wrap; margin-top: 12px; justify-content: flex-start; }
  .clock-copy { min-width: 100%; text-align: left; }
  .people-head { display: block; }
}
@media (max-width: 600px) {
  .topbar { margin-bottom: 17px; }
  .brand span, .identity-copy span { display: none; }
  .identity-copy { max-width: 120px; }
  .identity-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page-heading { align-items: flex-end; }
  .page-heading h1 { font-size: 21px; }
  .page-heading p { font-size: 10px; }
  .week-nav button { min-width: 38px; height: 40px; }
  .week-nav .this-week { display: none; }
  .metric { padding: 13px; }
  .metric-value strong { font-size: 20px; }
  .panel-inner { padding: 15px; }
  .hours-card { margin: -15px -15px 16px; padding: 14px 15px; }
  select, input { height: 44px; font-size: 16px; }
  .primary, .secondary { min-height: 46px; }
  .week-grid { grid-template-columns: 178px repeat(7, 142px) 100px; min-width: 1272px; }
  .week-cell { min-height: 96px; padding: 8px; }
  .time-content { padding: 13px; }
  .time-entry { grid-template-columns: minmax(120px, 1fr) 70px auto; gap: 8px; }
  .time-entry .entry-time { grid-column: 1 / -1; grid-row: 2; }
  .time-entry .entry-meta { display: none; }
  .entry-actions { gap: 4px; }
  .people-list { grid-template-columns: 1fr; padding: 13px; }
  .invite-form { grid-template-columns: 1fr; }
  .dialog-grid { grid-template-columns: 1fr; }
  .dialog-grid .full { grid-column: auto; }
}
