/* Schedule (web/schedule.js). Everything under .sc, plus the .sc-pop event card
   that is appended to <body>. Same design language as Gantt / Crew & Site Map:
   gradient-underlined title, KPI tiles with a gradient cap, 12px cards.
   Brand tokens only (light + dark). */

#main:has(> .sc) { max-width: none; }
.sc { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.sc > * { min-width: 0; }
.sc-muted { color: var(--muted); }
.sc-warnt { color: var(--warn); font-weight: 600; }

/* head */
.sc-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.sc-titles h1 { margin: 0; font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; position: relative; padding-bottom: 9px; }
.sc-titles h1::after { content: ""; position: absolute; left: 0; bottom: 0; width: 72px; height: 3px; border-radius: 3px; background: var(--gradient); }
.sc-titles p { margin: 8px 0 0; color: var(--muted); font-size: .84rem; max-width: 780px; line-height: 1.45; }
.sc-sync { display: flex; align-items: center; gap: 8px; font-size: .74rem; color: var(--muted); flex-wrap: wrap; }
.sc-err { color: var(--crit); font-weight: 600; cursor: help; }
.sc-refresh { font-size: .76rem; padding: 4px 10px; }

/* week bar */
.sc-weekbar { display: flex; align-items: center; gap: 14px 18px; flex-wrap: wrap; }
.sc-weeknav { display: inline-flex; gap: 4px; }
.sc-weeknav button { padding: 5px 11px; font-size: .84rem; }
.sc-weeknav button.is-on { background: var(--surface-3); }
.sc-range { font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; }
.sc-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-left: auto; font-size: .74rem; color: var(--ink-2); }
.sc-lg { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sc-lg i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); display: inline-block; flex: none; }
.sc-lg i.off { background: repeating-linear-gradient(135deg, var(--muted) 0 2px, transparent 2px 4px); border: 1px solid var(--muted); }

/* KPI tiles */
.sc-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 12px; }
.sc-kpi { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 15px 16px 12px; text-align: left; font: inherit; color: inherit; }
.sc-kpi::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--gradient); }
.sc-kpi.click { cursor: pointer; }
.sc-kpi.click:hover { box-shadow: var(--shadow-hover); }
.sc-kpi.t-crit::before { background: var(--crit); }
.sc-kpi.t-warn::before { background: var(--warn); }
.sc-kpi .k { font-size: .63rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.sc-kpi .v { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.sc-kpi.t-crit .v { color: var(--crit); }
.sc-kpi.t-warn .v { color: var(--warn); }
.sc-kpi .s { font-size: .72rem; color: var(--muted); line-height: 1.35; }

/* card + tabs */
.sc-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 0; overflow: hidden; }
.sc-tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); }
.sc-tab { appearance: none; border: 0; background: none; font: inherit; font-weight: 600; font-size: .86rem; color: var(--muted); padding: 12px 10px 13px; position: relative; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.sc-tab:hover, .sc-tab[aria-selected="true"] { color: var(--ink); }
.sc-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--gradient); }
.sc-badge { background: var(--crit-soft); color: var(--crit); border-radius: 999px; font-size: .68rem; font-weight: 700; padding: 1px 7px; }

/* the week grid */
.sc-gridwrap { overflow-x: auto; }
.sc-grid { display: grid; grid-template-columns: minmax(170px, 210px) repeat(var(--cols), minmax(132px, 1fr)); min-width: calc(190px + var(--cols) * 132px); }
.sc-row { display: contents; }
.sc-rh, .sc-cell, .sc-dh { border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); padding: 8px; min-width: 0; }
.sc-rh { border-left: 0; position: sticky; left: 0; z-index: 1; background: var(--surface); display: flex; flex-direction: column; gap: 2px; }
.sc-rh b { font-size: .84rem; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sc-rh small { font-size: .7rem; color: var(--muted); line-height: 1.3; }
.sc-hrow > * { position: sticky; top: 0; z-index: 2; background: var(--surface-2); }
.sc-hrow .sc-rh { z-index: 3; background: var(--surface-2); font-size: .66rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); justify-content: flex-end; }
.sc-dh { display: flex; flex-direction: column; gap: 1px; font-size: .72rem; color: var(--muted); }
.sc-dh b { font-size: .8rem; color: var(--ink); }
.sc-dh.today { box-shadow: inset 0 3px 0 var(--teal); }
.sc-dh.today b { color: var(--accent-2); }
.sc-cell { display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.sc-cell.today { background: color-mix(in srgb, var(--teal) 6%, transparent); }
.sc-cell.wkend, .sc-dh.wkend { background: var(--surface-2); }
.sc-row.idle .sc-rh b { color: var(--muted); font-weight: 500; }
.sc-loose .sc-rh { background: var(--surface-2); }
.sc-loose .sc-cell { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

/* event chips */
.sc-chip { appearance: none; font: inherit; text-align: left; cursor: pointer; display: flex; align-items: baseline; gap: 5px; flex-wrap: wrap;
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); border-left: 3px solid var(--c); border-radius: 6px;
  background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--ink); padding: 4px 7px; font-size: .74rem; line-height: 1.3; }
.sc-chip:hover, .sc-chip:focus-visible { background: color-mix(in srgb, var(--c) 28%, transparent); outline: none; box-shadow: 0 0 0 2px var(--focus); }
.sc-chip .t { font-weight: 600; overflow-wrap: anywhere; }
.sc-chip b { font-weight: 700; color: var(--ink-2); font-size: .7rem; }
.sc-chip em { font-style: normal; font-size: .66rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sc-chip.long { background: color-mix(in srgb, var(--c) 7%, transparent); border-style: solid; border-color: color-mix(in srgb, var(--c) 20%, transparent); border-left-color: color-mix(in srgb, var(--c) 55%, transparent); }
.sc-chip.long .t { font-weight: 500; color: var(--ink-2); }
.sc-chip.tent { border-style: dashed; border-left-style: dashed; }
.sc-chip.off { --c: var(--muted); background: repeating-linear-gradient(135deg, var(--surface-3) 0 4px, var(--surface) 4px 8px); }

/* what ADP has for the day */
.sc-adp { font-size: .68rem; line-height: 1.3; color: var(--muted); padding-left: 10px; position: relative; overflow-wrap: anywhere; }
.sc-adp::before { content: ""; position: absolute; left: 0; top: .32em; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.sc-adp.good::before { background: var(--good); }
.sc-adp.warn::before { background: var(--warn); }
.sc-adp.warn { color: var(--ink-2); }
.sc-adp.crit::before { background: var(--crit); }
.sc-adp.crit { color: var(--crit); font-weight: 600; }
.sc-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; vertical-align: middle; }
.sc-dot.good { background: var(--good); } .sc-dot.warn { background: var(--warn); } .sc-dot.crit { background: var(--crit); }
.sc-foot { margin: 0; padding: 10px 14px 12px; font-size: .72rem; color: var(--muted); border-top: 1px solid var(--line); line-height: 1.5; }

/* event card */
.sc-pop { position: fixed; z-index: 60; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-hover); padding: 14px 16px; max-height: 70vh; overflow: auto; font-size: .8rem; color: var(--ink); }
.sc-pop h3 { margin: 4px 0 2px; font-size: .98rem; line-height: 1.3; }
.sc-pop-k { font-size: .64rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sc-pop-k::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.sc-pop-when { margin: 0 0 10px; color: var(--muted); font-size: .76rem; }
.sc-pop-row { display: grid; grid-template-columns: 52px 1fr; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.sc-pop-row > span { font-size: .66rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.sc-pop-row small { display: block; color: var(--muted); font-size: .7rem; }
.sc-who { display: inline-block; margin: 0 4px 4px 0; padding: 1px 7px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--surface-3); }
.sc-who.k-crew { background: var(--accent-soft); color: var(--ink); }
.sc-who.k-sub { background: var(--warn-soft); color: var(--ink); }
.sc-who.k-unknown { background: var(--surface-3); color: var(--muted); font-style: italic; }
.sc-pop-notes { white-space: pre-wrap; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; color: var(--ink-2); font-size: .76rem; line-height: 1.45; }
.sc-pop-hint { margin: 8px 0 0; font-size: .72rem; color: var(--muted); font-style: italic; }

/* checks */
.sc-checks { display: flex; flex-direction: column; gap: 6px; padding: 4px 0 8px; }
.sc-checks section { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); min-width: 0; }
.sc-checks section:last-child { border-bottom: 0; }
.sc-checks h2 { margin: 0; font-size: 1rem; font-weight: 700; }
.sc-checks h3 { margin: 0 0 8px; font-size: .84rem; font-weight: 700; }
.sc-sub { margin: 4px 0 12px; font-size: .78rem; color: var(--muted); max-width: 860px; line-height: 1.45; }
.sc-tablewrap { overflow-x: auto; }
.sc-table { width: 100%; font-size: .8rem; }
.sc-table td { vertical-align: top; }
.sc-table small { display: block; font-size: .7rem; }
.sc-table td > b + small { display: inline; }
.sc-clip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-agrees { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-bottom: 12px; }
.sc-agree-h { display: flex; justify-content: space-between; gap: 10px; font-size: .78rem; margin-bottom: 6px; flex-wrap: wrap; }
.sc-agree-h span { color: var(--muted); }
.sc-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.sc-bar span.good { background: var(--good); } .sc-bar span.warn { background: var(--warn); } .sc-bar span.crit { background: var(--crit); }
.sc-ok { color: var(--good); font-size: .8rem; font-weight: 600; margin: 4px 0; }
.sc-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.sc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.sc-list li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .8rem; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }

@media (max-width: 700px) {
  .sc-legend { margin-left: 0; }
  .sc-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .sc-kpi .v { font-size: 1.35rem; }
  .sc-grid { grid-template-columns: minmax(120px, 140px) repeat(var(--cols), minmax(118px, 1fr)); min-width: calc(130px + var(--cols) * 118px); }
}
