/* SHAPE UP shared tool kit - the clothes all eight SHAPE tools wear.
 *
 * Sits on top of app.css. Every tool sets its own --tool accent trio in a
 * :root block and inherits the rest, so the eight read as siblings with
 * different personalities rather than eight one-off pages.
 *
 *   :root{ --tool:#0E7BFF; --tool-deep:#0A5FCC; --tool-soft:#E8F1FF }
 *
 * Design rules honored here (SUNNY_DESIGN_TASTE.md):
 *  - emphasis is a halo ring + matching border, never a plate behind text
 *  - hairline borders carry edges; shadows stay off data surfaces
 *  - nothing that is actually working is ever grayed out
 *  - pills, chips and buttons always have breathing room on all sides
 */

:root { --tool: var(--blue); --tool-deep: var(--blue-deep); --tool-soft: var(--tint-2); }

/* ---------- Gate ---------- */
.gate-shake { animation: gate-shake .42s var(--ease) }
@keyframes gate-shake {
  10%, 90% { transform: translateX(-2px) } 20%, 80% { transform: translateX(4px) }
  30%, 50%, 70% { transform: translateX(-7px) } 40%, 60% { transform: translateX(7px) }
}
.login .form-row { margin-top: 12px }
.login .form-row button { width: 100% }

/* ---------- Honest source banner ---------- */
.src-banner {
  display: flex; gap: 12px; align-items: flex-start;
  border-radius: var(--r-md); padding: 14px 16px; margin: 0 0 20px;
}
.src-banner p { margin: 0; color: var(--ink); font-size: .92rem; line-height: 1.5 }
.src-banner .chip { margin-top: 1px; flex: 0 0 auto }
.src-banner.is-sample { background: linear-gradient(180deg,#FFF8EC,#FFF3DD); border: 1px solid rgba(212,139,44,.42) }
.src-banner.is-warn { background: linear-gradient(180deg,#FFF4F1,#FFE9E3); border: 1px solid rgba(178,54,54,.34) }
.src-banner.is-live { background: linear-gradient(180deg,var(--surface-2),var(--tint-2)); border: 1px solid rgba(30,114,190,.28) }

/* Where the real data will come from. Deliberately visible, not a code comment. */
.hookup {
  margin: 22px 0 0; padding: 16px 18px; border: 1px dashed var(--line);
  border-radius: var(--r-md); background: var(--surface-2);
}
.hookup h3 { margin: 0 0 8px; font-size: .82rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted) }
.hookup p { margin: 0 0 8px; color: var(--muted); font-size: .88rem; line-height: 1.55 }
.hookup p:last-child { margin-bottom: 0 }
.hookup code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82em;
  background: var(--tint); border: 1px solid var(--line-soft); border-radius: 6px; padding: 2px 6px;
}

/* ---------- Toolbar: filters, search, actions ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 18px }
.toolbar .grow { flex: 1 1 auto; min-width: 0 }
.toolbar input[type="search"], .toolbar select {
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px;
  background: var(--surface-2); color: var(--ink); min-width: 0;
}
.toolbar input[type="search"] { width: 100%; max-width: 320px }
.toolbar input:focus, .toolbar select:focus {
  outline: 0; border-color: var(--tool); box-shadow: 0 0 0 3px rgba(30,114,190,.14); background: #fff;
}
.toolbar .secondary { padding: 10px 14px }

/* Segmented pills. Generous gap: pills never touch (Sunny, breathing room). */
.seg { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 }
.seg button {
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-strong);
  font-weight: 700; font-size: .86rem; padding: 9px 15px; border-radius: var(--r-pill);
  transition: all .18s var(--ease);
}
.seg button:hover { border-color: var(--tool); transform: none }
.seg button.on {
  background: var(--tool); border-color: var(--tool); color: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tool) 18%, transparent);
}
.seg button .n { margin-left: 7px; font-variant-numeric: tabular-nums; opacity: .72 }

/* ---------- KPI strip ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin: 0 0 20px }
.kpis .result { padding: 18px 20px }
.kpis .hero-number { font-size: 2rem; color: var(--navy) }
.kpis .result.is-hero {
  border-color: var(--tool);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--tool) 14%, transparent);
  background: linear-gradient(180deg, #fff, var(--tool-soft));
}
.kpis .result.is-hero .hero-number { font-size: 2.9rem; color: var(--tool-deep) }
.kpi-sub { display: block; margin-top: 8px; font-size: .8rem; color: var(--muted); line-height: 1.4 }
.kpi-sub b { color: var(--tool-deep) }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0,1fr)) } }
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr } }

/* ---------- Data table ---------- */
.dtable { width: 100%; border-collapse: collapse; font-size: .92rem }
.dtable th {
  text-align: left; font-size: .75rem; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); padding: 10px 12px;
  border-bottom: 2px solid var(--line); white-space: nowrap; background: var(--surface);
}
.dtable th.sortable { cursor: pointer; user-select: none }
.dtable th.sortable:hover { color: var(--tool-deep) }
.dtable th .dir { opacity: .45; margin-left: 5px }
.dtable th[aria-sort] .dir { opacity: 1; color: var(--tool) }
.dtable td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle }
.dtable tbody tr { transition: background .16s }
.dtable tbody tr:hover { background: var(--tint) }
.dtable tbody tr.is-open { background: var(--tool-soft) }
.dtable .num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap }
.dtable .who { font-weight: 700; color: var(--ink-strong) }
.dtable .sub { display: block; color: var(--muted); font-size: .78rem; margin-top: 3px; font-weight: 400 }
.dtable tr.clickable { cursor: pointer }

/* Sticky header for long boards */
.tscroll { max-height: 620px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-md) }
.tscroll .dtable th { position: sticky; top: 0; z-index: 2 }

/* ---------- Status pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: var(--r-pill);
  font-size: .7rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
}
.pill.good { background: #EAF7EE; border: 1px solid rgba(30,122,60,.32); color: #1E7A3C }
.pill.warn { background: #FFF8EC; border: 1px solid rgba(212,139,44,.45); color: var(--gold-deep) }
.pill.bad  { background: #FDEDEA; border: 1px solid rgba(192,57,43,.32); color: #B23636 }
.pill.calm { background: var(--tint-2); border: 1px solid rgba(30,114,190,.24); color: var(--blue-deep) }
.pill.mute { background: var(--tint); border: 1px solid var(--line); color: var(--muted) }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto }

/* ---------- Proportional bar (share of total, ranked lists) ---------- */
.bar { position: relative; height: 8px; border-radius: 99px; background: var(--tint-2); overflow: hidden; min-width: 60px }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--tool); width: var(--w,0%); transition: width .5s var(--ease) }
.bar.good > i { background: #2E9E58 } .bar.warn > i { background: var(--gold) } .bar.bad > i { background: #C0392B }

/* Sparkline: pure CSS bars, no chart library, no images */
.spark { display: inline-flex; align-items: flex-end; gap: 3px; height: 26px }
.spark i { width: 5px; border-radius: 2px 2px 0 0; background: color-mix(in srgb, var(--tool) 42%, #fff); height: var(--h,20%) }
.spark i.last { background: var(--tool) }

/* ---------- Drill-down drawer ---------- */
.drawer-scrim { position: fixed; inset: 0; background: rgba(13,31,53,.42); opacity: 0; pointer-events: none; transition: opacity .24s var(--ease); z-index: 60 }
.drawer-scrim.on { opacity: 1; pointer-events: auto }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100%); z-index: 61;
  background: var(--surface); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .28s var(--ease);
  display: flex; flex-direction: column; overflow: hidden;
}
.drawer.on { transform: none }
.drawer-head { padding: 20px 22px 16px; border-bottom: 1px solid var(--line) }
.drawer-head .eyebrow { margin: 0 0 4px }
.drawer-head h2 { font-size: 1.24rem }
.drawer-close { position: absolute; top: 14px; right: 14px; background: none; border: 0; color: var(--faint); font-size: 1.5rem; line-height: 1; padding: 6px 10px; cursor: pointer }
.drawer-close:hover { color: var(--ink) }
.drawer-body { padding: 20px 22px 28px; overflow-y: auto; flex: 1 }
.drawer-body dl.facts { grid-template-columns: 1fr 1fr }
.drawer-body h3 { margin: 22px 0 10px; font-size: .78rem; letter-spacing: .11em; text-transform: uppercase; color: var(--muted) }
.drawer-body h3:first-child { margin-top: 0 }
@media (max-width: 560px) { .drawer { width: 100% } }

/* Timeline inside a drawer */
.tline { list-style: none; margin: 0; padding: 0 }
.tline li { position: relative; padding: 0 0 18px 24px; border-left: 2px solid var(--line-soft); margin-left: 5px }
.tline li:last-child { border-left-color: transparent; padding-bottom: 0 }
.tline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--tool) }
.tline li.dim::before { border-color: var(--line) }
.tline strong { display: block; color: var(--ink-strong); font-size: .92rem }
.tline span { display: block; color: var(--muted); font-size: .8rem; margin-top: 2px }

/* ---------- States ---------- */
.state-box { padding: 44px 24px; text-align: center; color: var(--muted) }
.state-box .big { display: block; font-size: 1.5rem; margin-bottom: 10px }
.state-box h3 { margin: 0 0 6px; color: var(--navy); font-size: 1.08rem }
.state-box p { margin: 0 auto; max-width: 420px; line-height: 1.55 }
.state-box .primary, .state-box .secondary { margin-top: 18px }
.state-box.is-error h3 { color: #B23636 }

.skel { display: grid; gap: 10px; padding: 8px 0 }
.skel i { display: block; height: 46px; border-radius: var(--r-sm); background: linear-gradient(90deg,var(--tint) 25%,var(--tint-2) 37%,var(--tint) 63%); background-size: 400% 100%; animation: sheen 1.3s linear infinite }
@keyframes sheen { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }

/* ---------- Footnote / method note ---------- */
.method { margin: 18px 0 0; padding: 14px 16px; border-left: 4px solid var(--gold); background: var(--tint); border-radius: 0 var(--r-sm) var(--r-sm) 0 }
.method p { margin: 0; color: var(--ink); font-size: .88rem; line-height: 1.55 }
.method p + p { margin-top: 8px }

/* ---------- Section rhythm ---------- */
.tool + .tool, .card + .card { margin-top: 22px }
.tool.wide { width: 100% }
.tool-sub { margin: 10px 0 0; color: var(--muted); font-size: .93rem; line-height: 1.55 }

/* ---------- Mobile: tables become stacked cards ---------- */
@media (max-width: 720px) {
  .tscroll { max-height: none; border: 0; border-radius: 0; overflow: visible }
  .dtable, .dtable tbody, .dtable tr, .dtable td { display: block; width: 100% }
  .dtable thead { display: none }
  .dtable tr {
    border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; margin: 0 0 12px; background: #fff;
  }
  .dtable tr.is-open { border-color: var(--tool) }
  .dtable td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: right }
  .dtable td::before {
    content: attr(data-label); flex: 0 0 auto; text-align: left;
    font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
  }
  .dtable td:first-child { padding-top: 0 }
  .dtable td[data-label=""]::before { content: none }
  .dtable .num { text-align: right }
  .dtable .sub { text-align: right }
  .toolbar { gap: 10px }
  .toolbar input[type="search"] { max-width: none }
  .seg { gap: 8px }
  .seg button { padding: 8px 13px; font-size: .82rem }
}

@media print {
  .toolbar, .seg, .drawer, .drawer-scrim, .login, footer .noprint { display: none !important }
  .card { border: 1px solid #ccc !important; box-shadow: none !important; break-inside: avoid }
}
