/* =========================================================
   TTK ERP Brain — Daily digest ("Có gì mới") inside the chat welcome screen.
   Uses the shared domain tokens (--d-accent / --d-text / --d-tint) from widget.css.
   Every class is prefixed .dg- so nothing leaks into the chat styles.
   ========================================================= */

.dg-root {
  --dg-ink: #0f172a; --dg-ink-2: #475569; --dg-ink-3: #64748b;
  --dg-line: #e2e8f0; --dg-grid: #e2e8f0; --dg-baseline: #cbd5e1;
  --dg-context-bar: #7d8ba1; /* non-selected days, 3.45:1 on white */
  margin: 10px 0 12px;
  color: var(--dg-ink);
  container-type: inline-size;
}
.dg-root.is-loading .dg-content { opacity: 0.55; transition: opacity 0.15s; pointer-events: none; }

.dg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.dg-title { margin: 0; font-size: 14px; font-weight: 700; }
.dg-sub { margin: 1px 0 0; font-size: 11px; color: var(--dg-ink-3); }
.dg-controls { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.dg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 30px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--dg-line);
  background: #fff; color: var(--dg-ink-2); font-family: inherit; font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer;
}
.dg-btn:hover:not(:disabled) { border-color: #2563eb; color: #1d4ed8; background: #eff6ff; }
.dg-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.dg-btn.icon { width: 30px; padding: 0; font-size: 15px; }
.dg-date { min-height: 30px; padding: 0 8px; border: 1px solid var(--dg-line); border-radius: 8px; background: #fff; color: var(--dg-ink); font-family: inherit; font-size: 12px; }

.dg-note, .dg-error, .dg-placeholder { font-size: 11.5px; border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.dg-note { color: #92400e; background: #fffbeb; border: 1px solid #fde68a; }
.dg-error { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; }
.dg-placeholder { color: var(--dg-ink-3); background: #f8fafc; border: 1px dashed var(--dg-line); min-height: 120px; display: flex; align-items: center; justify-content: center; }

.dg-section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--dg-ink-3); margin: 14px 0 8px; }

/* KPI tiles */
/* 6 tiles on one row when the digest is wide enough, else 3×2 then 2×3 (container queries) */
.dg-kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
@container (max-width: 620px) { .dg-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container (max-width: 360px) { .dg-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dg-kpi { background: #fff; border: 1px solid var(--dg-line); border-radius: 9px; padding: 7px 9px 6px; min-width: 0; }
.dg-kpi-label { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--dg-ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dg-kpi-label::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--d-accent); flex-shrink: 0; }
.dg-kpi-value { font-size: 19px; font-weight: 700; margin-top: 1px; letter-spacing: -0.4px; line-height: 1.25; }
.dg-kpi-unit { font-size: 11px; font-weight: 500; color: var(--dg-ink-3); margin-left: 3px; }
.dg-kpi-delta { font-size: 10.5px; color: var(--dg-ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Cards & charts */
.dg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.dg-charts { margin-top: 6px; }
@container (max-width: 420px) { .dg-grid { grid-template-columns: 1fr; } }
.dg-card { background: #fff; border: 1px solid var(--dg-line); border-radius: 9px; padding: 7px 10px 6px; min-width: 0; }
.dg-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.dg-card-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; margin: 0; }
.dg-card-title::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--d-accent); flex-shrink: 0; }
.dg-card-meta { font-size: 11px; color: var(--dg-ink-3); white-space: nowrap; }
.dg-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.dg-chart .dg-tick { font-size: 11px; fill: var(--dg-ink-3); font-variant-numeric: tabular-nums; }
.dg-chart .dg-val { font-size: 12px; font-weight: 700; fill: var(--dg-ink); font-variant-numeric: tabular-nums; }
.dg-chart .dg-hit { fill: transparent; cursor: pointer; }
.dg-chart .dg-hit:hover + .dg-bar, .dg-chart .dg-hit:focus + .dg-bar { filter: brightness(1.12); }
.dg-chart .dg-hit:focus { outline: none; }
.dg-chart .dg-hit:focus-visible { stroke: #93c5fd; stroke-width: 2; }

.dg-tooltip {
  position: fixed; z-index: 60; pointer-events: none; opacity: 0; transition: opacity 0.1s;
  background: #0f172a; color: #fff; border-radius: 8px; padding: 6px 9px; font-size: 12px; line-height: 1.35;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.25); max-width: 240px;
}
.dg-tooltip.show { opacity: 1; }
.dg-tooltip strong { display: block; font-size: 13.5px; }
.dg-tooltip span { color: #cbd5e1; }

/* Ranked bars (teams) */
.dg-hbar-row { display: grid; grid-template-columns: minmax(100px, 40%) 1fr; align-items: center; gap: 8px; padding: 3px 0; }
.dg-hbar-name { font-size: 12px; color: var(--dg-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-hbar-track { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dg-hbar-fill { height: 12px; border-radius: 0 4px 4px 0; background: var(--d-accent); min-width: 2px; }
.dg-hbar-val { font-size: 11.5px; font-weight: 700; color: var(--dg-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Detail cards */
.dg-details { display: grid; grid-template-columns: 1fr; gap: 8px; }
.dg-detail { border-top: 3px solid var(--d-accent); }
.dg-stat-line { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--dg-ink-2); margin: 2px 0 8px; }
.dg-stat-line b { color: var(--dg-ink); }
/* .dg-root prefix outranks the chat bubble's .erp-bubble ul/li spacing */
.dg-root .dg-list { list-style: none; margin: 0; padding: 0; }
.dg-root .dg-list li { padding: 6px 0; border-top: 1px solid #f1f5f9; font-size: 12px; line-height: 1.45; margin: 0; }
.dg-root .dg-list li:first-child { border-top: 0; }
.dg-item-top { display: flex; justify-content: space-between; gap: 10px; }
.dg-code { font-weight: 700; color: var(--dg-ink); white-space: nowrap; }
.dg-amount { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dg-item-sub { color: var(--dg-ink-3); }
.dg-tag { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: #f1f5f9; color: #334155; margin-left: 4px; white-space: nowrap; }
.dg-tag.urgent { background: #fef2f2; color: #b91c1c; }
.dg-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.dg-chip { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--d-tint); color: var(--d-text); }
.dg-empty { font-size: 12px; color: var(--dg-ink-3); padding: 4px 0; }
.dg-ask {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; padding: 0; border: 0; background: none;
  font-family: inherit; font-size: 12px; font-weight: 600; color: #1d4ed8; cursor: pointer;
}
.dg-ask:hover { text-decoration: underline; }

.dg-expand { margin-top: 6px; width: 100%; min-height: 28px; }
.dg-more[hidden] { display: none; }

/* Table view */
.dg-table-view { margin-top: 8px; }
.dg-table-view summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--dg-ink-2); }
.dg-table-wrap { overflow-x: auto; margin-top: 6px; }
.dg-table { border-collapse: collapse; font-size: 12px; min-width: 100%; background: #fff; }
.dg-table th, .dg-table td { border: 1px solid var(--dg-line); padding: 5px 8px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dg-table th:first-child, .dg-table td:first-child { text-align: left; }
.dg-table th { background: #f8fafc; color: var(--dg-ink-2); font-weight: 700; }
.dg-table tr.is-selected td { font-weight: 700; background: #eff6ff; }


