/* enhancements.css — skeletons, freshness badges, command palette, drill-through,
   branded print cover + TOC. Layered on top of dataviz.css / index.html tokens. */

/* ------------------------------------------------------------------ *
   1. Skeleton loaders (shown while the first week fetches)
 * ------------------------------------------------------------------ */
.sk { display: flex; flex-direction: column; gap: 18px; }
.sk-line, .sk-card, .sk-kpi { position: relative; overflow: hidden; background: #eceef1; border-radius: var(--r-sm, 8px); }
.sk-line::after, .sk-card::after, .sk-kpi::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.7) 50%, transparent 100%);
  transform: translateX(-100%); animation: sk-shimmer 1.35s ease-in-out infinite;
}
@keyframes sk-shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .sk-line::after, .sk-card::after, .sk-kpi::after { animation: none; } }
.sk-kpirow { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px; }
.sk-kpi { height: 118px; border-radius: var(--r-md, 12px); background: #fff; border: 1px solid var(--line); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.sk-kpi::after { display: none; }
.sk-kpi .sk-line { background: #eceef1; }
.sk-kpi .a { width: 54%; height: 30px; }
.sk-kpi .b { width: 78%; height: 12px; }
.sk-kpi .c { width: 40%; height: 11px; margin-top: auto; }
.sk-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-md, 12px); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.sk-card::after { display: none; }
.sk-card .sk-line { background: #eceef1; }
.sk-card .t { width: 42%; height: 16px; }
.sk-card .s { width: 62%; height: 11px; }
.sk-card .big { width: 100%; flex: 1; min-height: 180px; border-radius: 10px; }
.sk-2 { display: grid; grid-template-columns: 2fr 3fr; gap: 18px; }
@media (max-width: 760px) { .sk-2 { grid-template-columns: 1fr; } }
.sk-tag { display: inline-flex; gap: 10px; }
.sk-tag .sk-line { width: 120px; height: 26px; border-radius: 999px; }

/* ------------------------------------------------------------------ *
   2. Data-freshness provenance strip + inline section badges
 * ------------------------------------------------------------------ */
.fresh-bar {
  display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap;
  margin: -2px 0 4px; padding-bottom: 2px;
}
.fresh-cap { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--gray-soft); }
.fresh-chip {
  display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--gray);
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-pill, 999px); padding: 5px 12px;
  white-space: nowrap;
}
.fresh-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex: none; box-shadow: 0 0 0 3px rgba(31,138,76,.12); }
.fresh-chip.stale i { background: var(--warning); box-shadow: 0 0 0 3px rgba(200,136,26,.14); }
.fresh-chip b { color: var(--navy); font-weight: 600; }
.fresh-chip em { font-style: normal; color: var(--gray-soft); }
/* inline badge attached to a specific section's title */
.fresh-badge {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 10px; vertical-align: middle;
  font-size: 10.5px; font-weight: 600; color: var(--cyan-deep); background: var(--info-bg);
  border: 1px solid rgba(0,155,227,.22); border-radius: var(--r-pill, 999px); padding: 3px 10px; white-space: nowrap;
}
.fresh-badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); flex: none; }

/* ------------------------------------------------------------------ *
   3. Command palette (⌘K)
 * ------------------------------------------------------------------ */
.tb-cmd { display: inline-flex; align-items: center; gap: 8px; }
.tb-cmd kbd {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--gray);
  background: var(--mist); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; line-height: 1.5;
}
.cmdk { position: fixed; inset: 0; z-index: 140; display: flex; align-items: flex-start; justify-content: center; padding: 24px; }
.cmdk[hidden] { display: none; }
.cmdk-back { position: absolute; inset: 0; background: rgba(11,32,75,.42); backdrop-filter: blur(2px); }
.cmdk-box {
  position: relative; z-index: 1; width: min(620px, 100%); margin-top: 9vh; background: #fff;
  border-radius: 16px; box-shadow: 0 28px 70px rgba(11,32,75,.34); overflow: hidden;
  animation: cmdk-in .18s var(--ease, ease);
}
@keyframes cmdk-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cmdk-box { animation: none; } }
.cmdk-inwrap { display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.cmdk-inwrap svg { width: 19px; height: 19px; color: var(--gray-soft); flex: none; }
.cmdk-in {
  flex: 1; border: none; outline: none; background: none; padding: 18px 0;
  font-family: var(--font-sans); font-size: 16px; color: var(--navy);
}
.cmdk-in::placeholder { color: var(--gray-soft); }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: 8px; }
.cmdk-group { font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gray-soft); padding: 12px 12px 6px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; cursor: pointer; }
.cmdk-item.on, .cmdk-item:hover { background: var(--mist); }
.cmdk-item.on { box-shadow: inset 0 0 0 1px rgba(0,155,227,.35); }
.cmdk-kind { font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--gray); background: var(--off-white); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; flex: none; min-width: 74px; text-align: center; }
.cmdk-name { flex: 1; min-width: 0; font-size: 14px; color: var(--navy); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-val { flex: none; font-family: var(--font-mono); font-size: 12.5px; color: var(--gray); font-variant-numeric: tabular-nums; }
.cmdk-empty { padding: 30px 20px; text-align: center; color: var(--gray-soft); font-size: 13px; }
.cmdk-foot { display: flex; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 11px; color: var(--gray-soft); }
.cmdk-foot span { display: inline-flex; align-items: center; gap: 6px; }
.cmdk-foot kbd { font-family: var(--font-mono); font-size: 10.5px; background: var(--mist); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }

/* pulse a metric card the palette jumped to */
@keyframes cmdk-hl { 0% { box-shadow: 0 0 0 0 rgba(0,155,227,.55); } 100% { box-shadow: 0 0 0 12px rgba(0,155,227,0); } }
.cmdk-target { animation: cmdk-hl 1.4s ease-out 2; border-color: var(--cyan) !important; }

/* ------------------------------------------------------------------ *
   4. Drill-through: clickable funnel stages / won accounts + records modal
 * ------------------------------------------------------------------ */
[data-drill] { cursor: pointer; }
.bd-fn-row[data-drill] { transition: transform .12s var(--ease, ease); }
.bd-fn-row[data-drill]:hover { transform: translateX(2px); }
.bd-fn-row[data-drill]:hover .bd-fn-track { box-shadow: inset 0 0 0 2px var(--cyan); }
.bd-out-card[data-drill] { transition: box-shadow .15s var(--ease, ease); }
.bd-out-card.won[data-drill]:hover { box-shadow: inset 0 0 0 2px var(--success); }
.bd-out-card.lost[data-drill]:hover { box-shadow: inset 0 0 0 2px var(--danger); }
.acc-row[data-drill] { transition: border-color .15s var(--ease, ease), box-shadow .15s var(--ease, ease); }
.acc-row[data-drill]:hover { border-color: var(--cyan); box-shadow: 0 5px 16px rgba(11,32,75,.09); }
/* small "records" affordance */
.drill-cue { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 10px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--cyan-deep); opacity: 0; transition: opacity .15s; }
.acc-row[data-drill]:hover .drill-cue, .bd-fn-row[data-drill]:hover .drill-cue { opacity: 1; }

.drill { position: fixed; inset: 0; z-index: 130; display: flex; align-items: center; justify-content: center; padding: 24px; }
.drill[hidden] { display: none; }
.drill-back { position: absolute; inset: 0; background: rgba(11,32,75,.42); backdrop-filter: blur(2px); }
.drill-box {
  position: relative; z-index: 1; width: min(780px, 100%); max-height: 85vh; overflow-y: auto;
  background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(11,32,75,.28);
  padding: 26px 28px 24px; animation: cmdk-in .2s var(--ease, ease);
}
.drill-x { position: absolute; top: 14px; right: 16px; width: 32px; height: 32px; border: none; background: none; font-size: 24px; line-height: 1; color: var(--gray-soft); cursor: pointer; border-radius: 50%; }
.drill-x:hover { background: var(--mist); color: var(--navy); }
.drill-head { padding-right: 40px; margin-bottom: 4px; }
.drill-eye { font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--cyan-deep); }
.drill-title { margin: 5px 0 0; font-size: 21px; font-weight: 600; color: var(--navy); line-height: 1.25; }
.drill-title b { color: var(--cyan-deep); }
.drill-sub { margin: 6px 0 0; font-size: 13px; color: var(--gray); }
.drill-stat { display: flex; gap: 26px; flex-wrap: wrap; margin: 16px 0 4px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.drill-stat div { display: flex; flex-direction: column; gap: 3px; }
.drill-stat b { font-size: 20px; font-weight: var(--w-light, 300); color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1; }
.drill-stat span { font-size: 10.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--gray); }
.drill-tblwrap { margin-top: 16px; overflow-x: auto; }
.drill-empty { margin-top: 18px; padding: 26px 20px; text-align: center; background: var(--mist); border: 1px dashed var(--line-strong); border-radius: var(--r-md, 12px); color: var(--gray); font-size: 13px; line-height: 1.6; }
.drill-empty b { display: block; color: var(--navy); margin-bottom: 4px; }

/* ------------------------------------------------------------------ *
   5. Branded print cover + table of contents (print only)
 * ------------------------------------------------------------------ */
.print-cover, .print-toc { display: none; }
@media print {
  .print-cover {
    display: flex; flex-direction: column; min-height: 96vh; padding: 8mm 4mm 12mm;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; break-after: page;
  }
  .print-cover .pc-top { display: flex; align-items: center; gap: 14px; }
  .print-cover .pc-top img { height: 30px; }
  .print-cover .pc-mark { font-family: var(--font-mono); font-size: 11px; letter-spacing: .06em; color: var(--gray); text-transform: uppercase; }
  .print-cover .pc-mid { margin-top: auto; margin-bottom: auto; }
  .print-cover .pc-eye { font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan-deep); }
  .print-cover .pc-rule { width: 64px; height: 3px; background: var(--cyan); margin: 14px 0 22px; }
  .print-cover h1 { margin: 0; font-size: 46px; font-weight: 300; letter-spacing: -.01em; color: var(--navy); line-height: 1.1; max-width: 16ch; }
  .print-cover .pc-week { margin: 22px 0 0; font-size: 20px; font-weight: 400; color: var(--ink); }
  .print-cover .pc-gen { margin: 8px 0 0; font-family: var(--font-mono); font-size: 12px; color: var(--gray); }
  .print-cover .pc-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
  .print-cover .pc-foot .creds { font-size: 11px; color: var(--gray); line-height: 1.6; }
  .print-cover .pc-foot .creds b { color: var(--navy); }
  .print-cover .pc-foot .conf { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--danger); }

  .print-toc { display: block; break-after: page; padding: 4mm; }
  .print-toc .tc-top { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid var(--cyan); padding-bottom: 12px; margin-bottom: 4px; }
  .print-toc .tc-top img { height: 24px; }
  .print-toc .tc-top b { font-size: 15px; font-weight: 600; color: var(--navy); }
  .print-toc h2 { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--gray); margin: 22px 0 6px; }
  .print-toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
  .print-toc li { display: flex; align-items: baseline; gap: 14px; padding: 15px 0; border-bottom: 1px solid var(--line); counter-increment: toc; }
  .print-toc li::before { content: counter(toc, decimal-leading-zero); font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--cyan-deep); flex: none; }
  .print-toc .tc-name { font-size: 17px; font-weight: 500; color: var(--navy); }
  .print-toc .tc-note { margin-left: auto; font-size: 12px; color: var(--gray); }
}
