/* Dashboard, Notifications, Reports and Audit History (loaded by those
   modules through ui.stylesheet). Builds on app.css tokens. Charts are
   HTML + SVG drawn by modules/reports.js: marks carry the app's chart
   colors, text stays in the ink/dim/faint text tokens. */

/* ---------------- Dashboard ---------------- */
.dash-hero { display: flex; flex-direction: column; gap: 16px; border: 1px solid rgba(169, 116, 31, 0.35); border-bottom: 4px solid var(--gold-bright); }
.dash-hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dash-hero-titles { min-width: 0; }
.dash-greeting { font-size: 0.95rem; color: rgba(255, 255, 255, 0.75); }
.dash-company { margin-top: 3px; font-size: 1.45rem; font-weight: 750; line-height: 1.25; color: #fff; overflow-wrap: anywhere; }
.dash-mark { width: 46px; height: auto; flex-shrink: 0; }
.dash-hero .hero-stats { margin-top: 0; gap: 22px; }
.dash-hero .hero-stat-label { color: rgba(255, 255, 255, 0.65); }

.dash-block { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dash-heading { font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.dash-caption { margin-top: -8px; font-size: 0.82rem; color: var(--text-dim); }

.dash-card {
  padding: 16px 18px; border-radius: var(--radius-card);
  background: var(--surface); border: 1px solid var(--edge); box-shadow: var(--shadow-card);
}
.dash-card-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--ink); }
.dash-card-text { margin-top: 6px; color: var(--text-dim); font-size: 0.93rem; }

.dash-attention {
  display: flex; flex-direction: column; gap: 6px; padding: 14px 18px; border-radius: var(--radius-card);
  background: rgba(180, 35, 24, 0.08); color: var(--text);
}
a.dash-attention:hover { background: rgba(180, 35, 24, 0.12); }
.dash-attention-label { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--red); }
.dash-attention-label .icon { color: var(--ink); }
.dash-attention-line { font-size: 0.85rem; color: var(--text-dim); overflow-wrap: anywhere; }

/* ---------------- Notifications ---------------- */
.notif-row { display: flex; align-items: stretch; min-width: 0; }
.notif-main { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: flex-start; padding: 12px 6px 12px 16px; text-align: left; width: 100%; }
button.notif-main:hover { background: rgba(23, 32, 51, 0.035); }
.notif-icon { width: 26px; display: flex; justify-content: center; color: var(--ink); flex-shrink: 0; padding-top: 1px; }
.notif-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.notif-title-line { display: flex; align-items: flex-start; gap: 8px; }
.notif-title { flex: 1; min-width: 0; color: var(--ink); font-size: 0.95rem; font-weight: 450; overflow-wrap: anywhere; }
.notif-row.is-unread .notif-title { font-weight: 680; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: #1f6fe5; flex-shrink: 0; margin-top: 7px; }
.notif-message { font-size: 0.86rem; color: var(--text-dim); overflow-wrap: anywhere; }
.notif-meta { font-size: 0.78rem; color: var(--text-faint); }
.notif-actions { display: flex; align-items: center; gap: 2px; padding: 0 10px 0 2px; flex-shrink: 0; }
.notif-actions .btn-danger-text { color: var(--red); }
.notif-toggle .switch-row { padding: 12px 16px; }

/* ---------------- Audit History ---------------- */
.audit-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; width: 100%; }
.audit-filters .search { flex: 1 1 260px; }
.audit-row { padding: 11px 16px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.audit-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.audit-type { font-size: 0.82rem; color: var(--text-dim); overflow-wrap: anywhere; }
.audit-time { margin-left: auto; font-size: 0.78rem; color: var(--text-faint); white-space: nowrap; }
.audit-name { font-weight: 560; color: var(--ink); font-size: 0.95rem; overflow-wrap: anywhere; }
.audit-detail { font-size: 0.85rem; color: var(--text-dim); overflow-wrap: anywhere; white-space: pre-wrap; }
.audit-by { font-size: 0.78rem; color: var(--text-faint); overflow-wrap: anywhere; }
.audit-more { padding: 10px 16px; display: flex; justify-content: center; }

/* ---------------- Reports ---------------- */
.report-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-card {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: 16px 18px 18px; border-radius: var(--radius-card);
  background: var(--surface); border: 1px solid var(--edge); box-shadow: var(--shadow-card);
}
.report-title { font-size: 1.02rem; font-weight: 700; color: var(--ink); }
.report-sub { margin-top: -6px; font-size: 0.82rem; color: var(--text-dim); min-height: 1.2em; overflow-wrap: anywhere; }
.report-empty { color: var(--text-dim); }
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.report-grid > .is-full { grid-column: 1 / -1; }

/* ---------------- Charts ---------------- */
.chart { position: relative; width: 100%; min-width: 0; user-select: none; -webkit-user-select: none; }
.chart-frame { position: relative; width: 100%; }
.chart-plot { position: absolute; top: 8px; right: 4px; bottom: 26px; }
.chart-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--line); }
.chart-grid.is-zero { border-top-color: rgba(23, 32, 51, 0.22); }
.chart-y { position: absolute; left: 0; text-align: right; transform: translateY(-50%); font-size: 0.72rem; line-height: 1;
  color: var(--text-faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-xaxis { position: absolute; bottom: 0; right: 4px; height: 20px; display: flex; }
.chart-x { flex: 1 1 0; min-width: 0; text-align: center; font-size: 0.72rem; color: var(--text-faint); white-space: nowrap;
  overflow: visible; display: flex; justify-content: center; }
.chart-x.is-skip { visibility: hidden; }
.chart-cols { position: absolute; inset: 0; display: flex; }
.chart-col { flex: 1 1 0; min-width: 0; position: relative; display: flex; justify-content: center; }
.chart-col.is-hover { background: rgba(23, 32, 51, 0.045); border-radius: 6px; }
/* The bars of one month: 80% of the column (air between months), each
   bar at most 24px, 2px apart. */
.chart-group { width: 80%; height: 100%; display: flex; justify-content: center; gap: 2px; }
.chart-slot { position: relative; flex: 0 1 24px; min-width: 1px; height: 100%; }
.chart-bar { position: absolute; left: 0; right: 0; border-radius: 4px 4px 0 0; }
.chart-bar.is-neg { border-radius: 0 0 4px 4px; }
.chart-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.chart-line { fill: none; stroke: var(--ink); stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { stroke: none; }
.chart-cross { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid rgba(23, 32, 51, 0.28); pointer-events: none; }
.chart-dot { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--ink);
  box-shadow: 0 0 0 2px #fbfdff; transform: translate(-50%, -50%); pointer-events: none; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.8rem; color: var(--text-dim); }
.chart-key { display: inline-flex; align-items: center; gap: 6px; }
.chart-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.chart-swatch.is-dot { border-radius: 50%; width: 8px; height: 8px; }
.chart-tip {
  position: absolute; top: 0; z-index: 5; min-width: 140px; max-width: 240px; padding: 8px 10px; border-radius: 10px;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow-deep); pointer-events: none;
  font-size: 0.8rem; color: var(--text-dim);
}
.chart-tip-title { font-weight: 650; color: var(--ink); margin-bottom: 4px; white-space: nowrap; }
.chart-tip-row { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.chart-tip-key { width: 10px; height: 2px; border-radius: 1px; flex-shrink: 0; }
.chart-tip-value { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Horizontal bars (sales pipeline, KPI achievement) */
.hbars { display: flex; flex-direction: column; padding-top: 4px; }
.hbar-row { display: grid; grid-template-columns: minmax(70px, 30%) minmax(0, 1fr); align-items: center; gap: 10px; }
.hbar-label { font-size: 0.82rem; color: var(--text-dim); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 100%; display: flex; align-items: center; min-width: 0; padding-right: 48px; }
.hbar-lane { position: relative; flex: 1; min-width: 0; height: 18px; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-value { position: absolute; top: 50%; transform: translateY(-50%); font-size: 0.75rem; color: var(--text-dim);
  white-space: nowrap; font-variant-numeric: tabular-nums; }
.hbar-axis { display: grid; grid-template-columns: minmax(70px, 30%) minmax(0, 1fr); gap: 10px; margin-top: 4px; }
.hbar-ticks { position: relative; height: 16px; border-top: 1px solid var(--line); margin-right: 48px; }
.hbar-tick { position: absolute; top: 2px; transform: translateX(-50%); font-size: 0.72rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.hbar-tick.is-first { transform: none; }

/* Donut */
.donut-wrap { display: flex; justify-content: center; }
.donut { position: relative; width: 200px; height: 200px; max-width: 100%; }
.donut svg { width: 100%; height: 100%; display: block; overflow: visible; }
.donut-seg { stroke: #fbfdff; stroke-width: 2px; stroke-linejoin: round; }
.donut-seg.is-hover { opacity: 0.85; }
.donut-label { position: absolute; transform: translate(-50%, -50%); font-size: 0.75rem; font-weight: 700; color: #fff; pointer-events: none; }

/* Mark colors (the app's chart colors; text never wears them) */
.mark-green { background-color: var(--green); fill: var(--green); }
.mark-red { background-color: var(--red); fill: var(--red); }
.mark-orange { background-color: #d07000; fill: #d07000; }
.mark-blue { background-color: var(--blue); fill: var(--blue); }
.mark-teal { background-color: var(--teal); fill: var(--teal); }
.mark-indigo { background-color: var(--indigo); fill: var(--indigo); }
.mark-purple { background-color: #a346c9; fill: #a346c9; }   /* pinker than --purple: apart from indigo, like iOS purple */
.mark-gray { background-color: #7c8594; fill: #7c8594; }
.mark-brown { background-color: var(--brown); fill: var(--brown); }
.mark-secondary { background-color: #a9b1bd; fill: #a9b1bd; }
.mark-ink { background-color: var(--ink); fill: var(--ink); }
.chart-area-stop-top { stop-color: var(--teal); stop-opacity: 0.3; }
.chart-area-stop-bottom { stop-color: var(--teal); stop-opacity: 0; }

@media (max-width: 900px) {
  .report-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .chart-x.is-skip-sm { visibility: hidden; }
  .dash-hero .hero-stats { gap: 18px; }
  .dash-company { font-size: 1.25rem; }
  .notif-main { padding-left: 12px; }
  .audit-time { margin-left: 0; width: 100%; }
}

@media print {
  .chart-tip, .notif-actions { display: none !important; }
}
