/* project-dashboard GOAL WS-2 (2026-07-16 night build)
   Unified morning project dashboard — styles.
   Chrome follows Telegram themeParams (CSS vars with dark fallbacks, like style.css).
   DATA colors are the validated dataviz reference palette (fixed per light/dark,
   never themed by Telegram) — status colors reserved, categorical slots in order. */

#dashboard { --dz-gap: 10px; }

/* ---------- tokens ---------- */
#dashboard {
  /* chrome (Telegram passthrough, dark fallbacks match style.css) */
  --dz-bg:      var(--tg-theme-bg-color, #0e1217);
  --dz-fg:      var(--tg-theme-text-color, #e8edf2);
  --dz-hint:    var(--tg-theme-hint-color, #8a94a0);
  --dz-link:    var(--tg-theme-link-color, #6ab3f3);
  --dz-card:    var(--tg-theme-secondary-bg-color, #1a1f27);
  --dz-accent:  var(--tg-theme-button-color, #2ea6ff);
  --dz-accent-fg: var(--tg-theme-button-text-color, #ffffff);
  /* data ink — dark set by default (matches app fallback look).
     Ink steps re-validated 2026-08-26 against the Telegram card surfaces
     (not the reference chart surfaces): content text ≥4.5:1 at UI sizes. */
  --dz-ink:        #ffffff;
  --dz-ink-2:      #d7d6cc;   /* 11.3:1 on #1a1f27 (was #c3c2b7) */
  --dz-ink-muted:  #a5a39c;   /*  6.6:1 on #1a1f27 (was #898781 @ 4.6:1) */
  --dz-grid-line:  #2c2c2a;
  --dz-hairline:   rgba(255,255,255,0.10);
  --dz-series-1:   #3987e5;
  --dz-series-2:   #008300;
  --dz-good:       #0ca30c;
  --dz-warn:       #fab219;
  --dz-serious:    #ec835a;
  --dz-critical:   #e66767;   /* 5.1:1 on dark card — table-size text (was #d03b3b @ 3.4:1) */
  --dz-delta-good: #0ca30c;
  --dz-chip-bg:    rgba(255,255,255,0.06);
}
#dashboard[data-scheme="light"] {
  --dz-ink:        #0b0b0b;
  --dz-ink-2:      #3f3e3b;   /* 9.3:1 on #efeff4 (was #52514e) */
  --dz-ink-muted:  #666460;   /* 5.2:1 on #efeff4 (was #898781 @ 3.1:1) */
  --dz-grid-line:  #e1e0d9;
  --dz-hairline:   rgba(11,11,11,0.10);
  --dz-series-1:   #2a78d6;
  --dz-series-2:   #008300;
  --dz-critical:   #d03b3b;   /* 4.7:1 on light */
  --dz-delta-good: #006300;
  --dz-chip-bg:    rgba(11,11,11,0.05);
}

/* ---------- header ---------- */
.dz-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 4px 2px 10px;
}
.dz-head .dz-title { font-size: 17px; font-weight: 700; color: var(--dz-fg); }
.dz-head .dz-sub   { font-size: 13px; color: var(--dz-ink-muted); width: 100%; }
.dz-head button {
  border: 1px solid var(--dz-hairline); background: var(--dz-card); color: var(--dz-fg);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.dz-head button.dz-on { background: var(--dz-accent); color: var(--dz-accent-fg); border-color: transparent; }
.dz-stale {
  width: 100%; border-radius: 8px; padding: 8px 10px; font-size: 12.5px;
  background: rgba(250,178,25,0.14); color: var(--dz-fg);
  border: 1px solid rgba(250,178,25,0.5);
}

/* freshness chips */
.dz-fresh { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.dz-fresh .chip {
  font-size: 11.5px; color: var(--dz-ink-2); background: var(--dz-chip-bg);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.dz-fresh .chip.stale { color: var(--dz-serious); }

/* ---------- grid of widgets ---------- */
.dz-grid {
  display: grid; gap: var(--dz-gap);
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 66px;
  grid-auto-flow: dense;
}
@media (max-width: 760px) {
  .dz-grid { grid-template-columns: repeat(4, 1fr); }
  /* phone: widgets stack full-width in layout order; height spans still apply */
  .dz-grid .dz-widget { grid-column: 1 / -1 !important; }
}
.dz-widget {
  background: var(--dz-card); border: 1px solid var(--dz-hairline);
  border-radius: 12px; overflow: hidden; display: flex; flex-direction: column;
  min-width: 0; position: relative;
}
.dz-widget.dz-dragging { opacity: 0.45; }
.dz-widget.dz-drop-before { box-shadow: -3px 0 0 0 var(--dz-accent); }
.dz-widget.dz-drop-after  { box-shadow:  3px 0 0 0 var(--dz-accent); }

.dz-w-head {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px 6px; flex: none;
}
.dz-w-title { font-size: 14px; font-weight: 700; color: var(--dz-fg); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-w-meta  { font-size: 11.5px; color: var(--dz-ink-muted); }
.dz-w-body  { flex: 1; overflow: auto; padding: 0 10px 10px; min-height: 0;
  -webkit-overflow-scrolling: touch; }

/* edit-mode chrome */
.dz-handle { display: none; cursor: grab; color: var(--dz-hint); font-size: 15px;
  padding: 2px 4px; touch-action: none; user-select: none; }
.dz-sizer  { display: none; gap: 2px; }
.dz-sizer button {
  border: 1px solid var(--dz-hairline); background: transparent; color: var(--dz-fg);
  border-radius: 6px; font-size: 12px; width: 24px; height: 22px; line-height: 1;
  cursor: pointer; padding: 0;
}
#dashboard.dz-edit .dz-handle { display: block; }
#dashboard.dz-edit .dz-sizer  { display: inline-flex; }
#dashboard.dz-edit .dz-widget { outline: 1px dashed var(--dz-hairline); }

/* comment affordance */
.dz-cmt {
  border: none; background: transparent; color: var(--dz-hint); cursor: pointer;
  font-size: 13px; padding: 2px 4px; border-radius: 6px; flex: none;
}
.dz-cmt:active { transform: scale(0.9); }
tr .dz-cmt, .dz-leaf .dz-cmt { opacity: 0.55; }

/* ---------- KPI strip ---------- */
.dz-kpis { display: flex; gap: 8px; height: 100%; align-items: stretch; overflow-x: auto; }
.dz-kpi {
  flex: 1 1 0; min-width: 96px; border-radius: 10px; padding: 8px 10px;
  background: var(--dz-chip-bg); display: flex; flex-direction: column; gap: 2px;
  justify-content: center; position: relative;
}
.dz-kpi .v { font-size: 20px; font-weight: 750; color: var(--dz-ink); line-height: 1.1; }
.dz-kpi .l { font-size: 11.5px; color: var(--dz-ink-2); }
.dz-kpi .s { font-size: 11px; color: var(--dz-ink-muted); }
.dz-kpi .v .neg { color: var(--dz-critical); }
.dz-kpi .v .pos { color: var(--dz-delta-good); }

/* ---------- tables ---------- */
.dz-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.dz-tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--dz-ink-muted); font-weight: 600; padding: 4px 6px;
  border-bottom: 1px solid var(--dz-grid-line); position: sticky; top: 0;
  background: var(--dz-card); z-index: 1; white-space: nowrap;
}
.dz-tbl td {
  padding: 6px; color: var(--dz-ink-2); border-bottom: 1px solid var(--dz-grid-line);
  white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.dz-tbl td.num, .dz-tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dz-tbl td.main { color: var(--dz-ink); font-weight: 600; }
.dz-tbl tbody tr { cursor: pointer; }
.dz-tbl tbody tr:active { background: var(--dz-chip-bg); }
.dz-empty { color: var(--dz-ink-muted); font-size: 13px; padding: 12px 4px; }

/* status + misc chips */
.dz-chip {
  display: inline-block; font-size: 11px; border-radius: 999px; padding: 1px 7px;
  background: var(--dz-chip-bg); color: var(--dz-ink-2); vertical-align: 1px;
}
.dz-chip.won  { background: rgba(12,163,12,0.16);  color: var(--dz-good); }
.dz-chip.lost { background: rgba(208,59,59,0.14);  color: var(--dz-critical); }
.dz-chip.flag { background: rgba(208,59,59,0.14);  color: var(--dz-critical); font-weight: 700; }
.dz-chip.warn { background: rgba(250,178,25,0.16); color: var(--dz-warn); }
.dz-chip.soon { background: rgba(236,131,90,0.16); color: var(--dz-serious); font-weight: 700; }
.dz-chip.ok   { background: rgba(12,163,12,0.12);  color: var(--dz-good); }

/* closes strip */
.dz-closes { display: flex; flex-direction: column; gap: 6px; }
.dz-close-row {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: 8px; background: var(--dz-chip-bg); cursor: pointer;
}
.dz-close-row .d { font-size: 15px; font-weight: 750; min-width: 34px; text-align: center;
  color: var(--dz-serious); }
.dz-close-row .d.today { color: var(--dz-critical); }
.dz-close-row .nm { flex: 1; min-width: 0; font-size: 13.5px; color: var(--dz-ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-close-row .amt { font-size: 12.5px; color: var(--dz-ink-2); font-variant-numeric: tabular-nums; }

/* ---------- drill panels ---------- */
.dz-panels { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.dz-panel {
  position: absolute; inset: 0; background: var(--dz-bg);
  display: flex; flex-direction: column; pointer-events: auto;
  transform: translateX(100%); transition: transform 0.22s ease;
  will-change: transform;
}
.dz-panel.in { transform: translateX(0); }
.dz-p-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px;
  border-bottom: 1px solid var(--dz-hairline); flex: none;
}
.dz-p-head .bk {
  border: none; background: var(--dz-card); color: var(--dz-fg); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.dz-p-titles { flex: 1; min-width: 0; }
.dz-p-title { font-size: 14.5px; font-weight: 700; color: var(--dz-fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-p-crumb { font-size: 11px; color: var(--dz-ink-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-p-body { flex: 1; overflow: auto; padding: 10px 12px 28px;
  -webkit-overflow-scrolling: touch; }

/* detail field grid + sections */
.dz-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px; margin-bottom: 12px; }
.dz-field { background: var(--dz-card); border-radius: 8px; padding: 7px 9px; min-width: 0; }
.dz-field .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--dz-ink-muted); }
.dz-field .v { font-size: 13.5px; color: var(--dz-ink); word-break: break-word; }
.dz-sec { margin: 14px 0 6px; display: flex; align-items: center; gap: 6px; }
.dz-sec h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--dz-ink-2); font-weight: 700; }
.dz-md { font-size: 14px; color: var(--dz-ink-2); line-height: 1.5; }
.dz-md h1, .dz-md h2, .dz-md h3 { color: var(--dz-ink); font-size: 14.5px; margin: 10px 0 4px; }
.dz-md ul { padding-left: 18px; margin: 4px 0; }
.dz-md li { margin: 2px 0; }
.dz-md p  { margin: 6px 0; }
.dz-md strong { color: var(--dz-ink); }
.dz-floor { font-size: 11.5px; color: var(--dz-ink-muted); font-style: italic;
  padding: 8px 0 0; }

/* ---------- comment sheet + toast ---------- */
.dz-sheet-wrap { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; }
.dz-sheet {
  background: var(--dz-bg); border-radius: 14px 14px 0 0; width: 100%;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); box-sizing: border-box;
}
.dz-sheet .path { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.dz-sheet .path .dz-chip { font-size: 10.5px; }
.dz-sheet textarea {
  width: 100%; box-sizing: border-box; min-height: 84px; resize: vertical;
  background: var(--dz-card); color: var(--dz-fg); border: 1px solid var(--dz-hairline);
  border-radius: 10px; padding: 9px; font-size: 14px; font-family: inherit;
}
.dz-sheet .row { display: flex; gap: 8px; margin-top: 10px; }
.dz-sheet .row button { flex: 1; border-radius: 10px; padding: 10px; font-size: 14px;
  border: 1px solid var(--dz-hairline); background: var(--dz-card); color: var(--dz-fg);
  cursor: pointer; }
.dz-sheet .row button.send { background: var(--dz-accent); color: var(--dz-accent-fg);
  border-color: transparent; font-weight: 700; }
.dz-sheet .hint { font-size: 11.5px; color: var(--dz-ink-muted); margin-top: 6px; }

.dz-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(8px);
  background: var(--dz-card); color: var(--dz-fg); border: 1px solid var(--dz-hairline);
  border-radius: 10px; padding: 9px 14px; font-size: 13.5px; z-index: 80;
  opacity: 0; transition: opacity 0.18s ease, transform 0.18s ease; pointer-events: none;
  max-width: 88vw; text-align: center;
}
.dz-toast.in { opacity: 1; transform: translateX(-50%) translateY(0); }

/* not-live / loading states */
.dz-state { padding: 28px 16px; text-align: center; color: var(--dz-ink-2); font-size: 14px;
  line-height: 1.5; }
.dz-state code { display: inline-block; background: var(--dz-chip-bg); border-radius: 6px;
  padding: 2px 8px; font-size: 12px; margin-top: 6px; user-select: all; }
.dz-spin { display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--dz-hairline); border-top-color: var(--dz-accent);
  animation: dzspin 0.8s linear infinite; margin-bottom: 8px; }
@keyframes dzspin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .dz-panel { transition: none; }
  .dz-toast { transition: none; }
  .dz-spin { animation-duration: 1.6s; }
}

/* ---------- Job Analysis (HCSS HeavyJob echo, 2026-08-26) ---------- */
.ja-tabs { display: flex; gap: 4px; margin: 2px 0 6px; flex-wrap: wrap; }
.ja-tab { border: 1px solid var(--dz-hairline); background: transparent; color: var(--dz-ink-2);
  border-radius: 8px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.ja-tab.on { background: var(--dz-accent); color: var(--dz-accent-fg); border-color: transparent; font-weight: 600; }
.ja-rangecap { font-size: 12px; color: var(--dz-ink-muted); margin: 0 0 6px; }
.ja-listhead { display: flex; align-items: baseline; justify-content: space-between;
  font-size: 12.5px; font-weight: 700; color: var(--dz-ink-2);
  background: var(--dz-chip-bg); border-radius: 6px; padding: 4px 8px; margin: 8px 0 2px; }
.ja-listhead .s { font-weight: 400; font-size: 11.5px; color: var(--dz-ink-muted); }
.ja-list { display: flex; flex-direction: column; }
.ja-row { display: flex; align-items: center; gap: 8px; padding: 8px 2px;
  border-bottom: 1px solid var(--dz-hairline); cursor: pointer; }
.ja-row:active { background: var(--dz-chip-bg); }
.ja-row .idn { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ja-row .cd { font-size: 14px; font-weight: 650; color: var(--dz-ink); }
.ja-row .nm { font-size: 12.5px; color: var(--dz-ink-2); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.ja-row .var { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--dz-ink);
  text-align: right; white-space: nowrap; }
.ja-row .chev { color: var(--dz-ink-muted); font-size: 17px; }
.ja-row .dz-cmt { flex: none; }
.ja-neg { color: var(--dz-critical); }
.ja-dim { color: var(--dz-ink-muted); }
.ja-seg { display: flex; gap: 0; margin: 10px auto 2px; width: fit-content;
  border: 1px solid var(--dz-hairline); border-radius: 10px; overflow: hidden; }
.ja-seg button { border: 0; background: transparent; color: var(--dz-ink-2);
  padding: 5px 22px; font-size: 13px; cursor: pointer; }
.ja-seg button.on { background: var(--dz-accent); color: var(--dz-accent-fg); font-weight: 600; }
.ja-sechead { font-size: 12.5px; font-weight: 700; color: var(--dz-ink-muted);
  background: var(--dz-chip-bg); border-radius: 6px; padding: 4px 8px; margin: 12px 0 2px; }
.ja-note { font-size: 11.5px; color: var(--dz-ink-muted); margin: 6px 0; }
