/* ============================================================
   DX — Dashboard design layer (compact / dense / interactive)
   Used by daily_dashboard.php and analytics.php.
   Namespaced with .dx- so every other page is untouched.
   ============================================================ */

.dx { --dx-line: rgba(15,23,42,.09); --dx-line-soft: rgba(15,23,42,.05); }

/* ---- page head ---- */
.dx-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 0 0 14px;
}
.dx-head h1 {
  margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em;
  color: var(--text-strong);
}
.dx-head .dx-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.dx-head-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---- surfaces ---- */
.dx-card {
  background: var(--glass-bg-strong);
  border: 1px solid var(--dx-line);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
  animation: none;
  margin: 0;
}
.dx-card:hover { background: var(--glass-bg-strong); box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.dx-pad { padding: 12px 14px; }

/* ---- sections ---- */
.dx-sec { margin: 0 0 16px; }
.dx-sec-hd {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 8px;
}
.dx-sec-hd h2 {
  margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted);
}
.dx-sec-hd .dx-note {
  font-size: 11px; color: var(--text-dim); font-weight: 500;
  text-transform: none; letter-spacing: 0;
}
.dx-spacer { flex: 1; }

/* ---- grids ---- */
.dx-grid { display: grid; gap: 8px; }
/* grid items default to min-width:auto, which lets a wide table push the whole
   grid past the container — pin them to 0 and let .dx-scroll do the scrolling */
.dx-grid > * { min-width: 0; }
.dx-g6 { grid-template-columns: repeat(6, 1fr); }
.dx-g5 { grid-template-columns: repeat(5, 1fr); }
.dx-g4 { grid-template-columns: repeat(4, 1fr); }
.dx-g3 { grid-template-columns: repeat(3, 1fr); }
.dx-g2 { grid-template-columns: repeat(2, 1fr); }
.dx-g21 { grid-template-columns: 1.6fr 1fr; }
@media (max-width: 1100px) {
  .dx-g6 { grid-template-columns: repeat(3,1fr); }
  .dx-g5 { grid-template-columns: repeat(3,1fr); }
  .dx-g21 { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .dx-g6, .dx-g5, .dx-g4, .dx-g3, .dx-g2 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 480px) {
  .dx-g6, .dx-g5, .dx-g4, .dx-g3, .dx-g2 { grid-template-columns: 1fr; }
}

/* ---- stat tile (compact KPI) ---- */
.dx-stat {
  position: relative;
  background: var(--glass-bg-strong);
  border: 1px solid var(--dx-line);
  border-left: 3px solid var(--c, #94a3b8);
  border-radius: 9px;
  padding: 9px 11px 10px;
  min-width: 0;
  transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.dx-stat .k {
  font-size: 10px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dx-stat .v {
  font-size: 21px; font-weight: 700; line-height: 1.15; margin-top: 2px;
  color: var(--text-strong); font-variant-numeric: tabular-nums;
}
.dx-stat .v .u { font-size: 11px; font-weight: 600; color: var(--text-muted); margin-left: 2px; }
.dx-stat .s { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.35; }
.dx-stat.lg .v { font-size: 27px; }
.dx-stat.sm .v { font-size: 17px; }

/* clickable / selected / dimmed */
.dx-click { cursor: pointer; }
.dx-click:hover { background: #fff; box-shadow: 0 2px 8px rgba(15,23,42,.09); }
.dx-stat.on { border-color: var(--c); box-shadow: 0 0 0 1px var(--c) inset; background: #fff; }
.dx-dim { opacity: .45; }

/* capacity split — "6-KL: 10, 9-KL: 9, …", each tank size in its own colour */
.dx-cap {
  font-size: 10px; color: var(--text-muted); font-weight: 600;
  font-variant-numeric: tabular-nums; display: block; margin-top: 2px;
  line-height: 1.45; white-space: normal;
}
.dx-capk { white-space: nowrap; }
.dx-capk b { color: var(--ck, var(--text-muted)); font-weight: 700; }
.dx-capsep { font-style: normal; color: var(--text-dim); }
td .dx-cap, th .dx-cap { display: inline; margin: 0; white-space: nowrap; }

/* ---- composition bar ---- */
.dx-compo { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: rgba(15,23,42,.06); }
.dx-compo > span { transition: width .3s var(--ease); }
.dx-legend { display: flex; gap: 4px 10px; flex-wrap: wrap; margin-top: 7px; font-size: 11px; }
.dx-legend .li { display: flex; align-items: center; gap: 5px; cursor: pointer; padding: 1px 5px; border-radius: 5px; }
.dx-legend .li:hover { background: rgba(15,23,42,.05); }
.dx-legend .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.dx-legend .li.off { opacity: .38; }

/* inline bar inside table cells */
.dx-inbar { display: block; height: 4px; border-radius: 99px; background: rgba(15,23,42,.07); margin-top: 3px; overflow: hidden; }
.dx-inbar > i { display: block; height: 100%; border-radius: 99px; }

/* ---- filter chips ---- */
.dx-filters {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  padding: 8px 12px; border-radius: 9px; margin-bottom: 12px;
  background: rgba(2,132,199,.07); border: 1px solid rgba(2,132,199,.22);
}
.dx-filters .lbl {
  font-size: 10px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: #0369a1;
}
.dx-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: #fff; border: 1px solid var(--dx-line); color: var(--text-strong);
  border-radius: 99px; padding: 3px 9px; font-size: 11.5px; font-weight: 600;
  cursor: pointer; transition: all .15s var(--ease);
}
.dx-chip:hover { border-color: var(--bad); color: var(--bad); }
.dx-chip .x { font-size: 13px; line-height: 1; opacity: .55; }
.dx-chip.plain, .dx-chip.plain:hover { cursor: default; border-color: var(--dx-line); color: var(--text-strong); }

/* toggle-style chips (date / month pickers) */
.dx-tog {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  background: rgba(15,23,42,.05); color: var(--text-strong);
  border: 1px solid transparent; border-radius: 7px;
  padding: 4px 9px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  transition: all .15s var(--ease);
}
.dx-tog:hover { background: rgba(15,23,42,.1); }
.dx-tog.on { background: linear-gradient(135deg, #0369a1, #059669); color: #fff; }
.dx-tog.on:hover { filter: brightness(1.05); }
.dx-tog input { display: none; }

/* ---- calendar date picker ---- */
.dx-calwrap { position: relative; }
.dx-cal {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  width: 292px; max-width: calc(100vw - 34px); padding: 10px;
  background: #fff; border: 1px solid var(--dx-line); border-radius: 11px;
  box-shadow: 0 12px 34px rgba(15,23,42,.16);
}
.dx-cal[hidden] { display: none; }
.dx-cal-hd {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; margin-bottom: 8px;
}
.dx-cal-hd .mo { font-size: 12.5px; font-weight: 700; color: var(--text-strong); }
.dx-cal-nav {
  border: 1px solid var(--dx-line); background: #fff; border-radius: 6px;
  width: 24px; height: 24px; line-height: 1; cursor: pointer;
  color: var(--text-muted); font-size: 13px; padding: 0;
  transition: all .15s var(--ease);
}
.dx-cal-nav:hover:not(:disabled) { background: rgba(2,132,199,.1); color: var(--accent); }
.dx-cal-nav:disabled { opacity: .3; cursor: default; }
.dx-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dx-cal-dow {
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-dim); text-align: center; padding: 2px 0 4px;
}
.dx-cal-day {
  height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: 7px; font-size: 11.5px; color: var(--text-dim);
  font-variant-numeric: tabular-nums; user-select: none;
}
.dx-cal-day.has {
  cursor: pointer; font-weight: 600; color: var(--text-strong);
  background: rgba(2,132,199,.09);
}
.dx-cal-day.has:hover { background: rgba(2,132,199,.22); }
.dx-cal-day.on { background: linear-gradient(135deg, #0369a1, #059669); color: #fff; }
.dx-cal-day.on:hover { filter: brightness(1.06); }
.dx-cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.dx-cal-ft {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--dx-line);
}
.dx-cal-hint { font-size: 10px; color: var(--text-dim); line-height: 1.45; margin-top: 7px; }
.dx-cal-presets { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 9px; }
.dx-cal-presets .btn { padding: 4px 9px; font-size: 11px; }

/* ---- tables ---- */
.dx-tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.dx-tbl th, .dx-tbl td {
  padding: 6px 9px; font-size: 12px; border-bottom: 1px solid var(--dx-line-soft);
  white-space: nowrap; text-align: left; color: var(--text);
}
.dx-tbl thead th {
  background: rgba(248,252,255,.96); position: sticky; top: 0; z-index: 2;
  font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid var(--dx-line);
  cursor: pointer; user-select: none;
}
.dx-tbl thead th:hover { color: var(--text-strong); }
.dx-tbl thead th.na { cursor: default; }
.dx-tbl thead th .ar { opacity: .3; font-size: 9px; margin-left: 2px; }
.dx-tbl thead th.srt { color: var(--accent); }
.dx-tbl thead th.srt .ar { opacity: 1; }
.dx-tbl tbody tr { transition: background .12s var(--ease); }
.dx-tbl tbody tr:hover td { background: rgba(2,132,199,.06); }
.dx-tbl tbody tr.on td { background: rgba(2,132,199,.12); }
.dx-tbl tbody tr.on td:first-child { box-shadow: inset 2px 0 0 var(--accent); }
.dx-tbl tbody tr.rowclick { cursor: pointer; }
.dx-tbl tfoot td {
  padding: 7px 9px; font-size: 12px; font-weight: 700; color: var(--text-strong);
  background: rgba(15,23,42,.045); border-top: 1px solid var(--dx-line);
  position: sticky; bottom: 0;
}
.dx-tbl .r { text-align: right; }
.dx-tbl .z { color: var(--text-dim); font-weight: 400; }
.dx-scroll { overflow: auto; max-height: 430px; border-radius: 0 0 10px 10px; }
.dx-tblhd {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 12px; border-bottom: 1px solid var(--dx-line);
}
.dx-tblhd strong { font-size: 12.5px; color: var(--text-strong); }
.dx-tblhd .dx-note { font-size: 11px; color: var(--text-dim); }
.dx-tblhd input[type=search] {
  width: 180px; padding: 4px 9px; font-size: 12px; border-radius: 6px;
  background: #fff; border: 1px solid var(--dx-line);
}

/* ---- charts ---- */
.dx-chart { position: relative; height: 200px; }
.dx-chart.tall { height: 255px; }
.dx-chart.short { height: 160px; }
.dx-chart canvas { cursor: pointer; }
.dx-chart-hd {
  font-size: 12px; font-weight: 700; color: var(--text-strong);
  margin: 0 0 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.dx-chart-hd .hint { font-size: 10px; font-weight: 500; color: var(--text-dim); }

/* ---- misc ---- */
.dx-empty { padding: 26px; text-align: center; color: var(--text-muted); font-size: 12.5px; }
.dx-pill { display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 10px; font-weight: 700; background: rgba(15,23,42,.06); color: var(--text-muted); }
.dx-warn { font-size: 11px; color: #b45309; margin-top: 6px; }
.dx-seg { display: inline-flex; background: rgba(15,23,42,.05); border-radius: 7px; padding: 2px; gap: 2px; }
.dx-seg button {
  border: 0; background: transparent; cursor: pointer; font: inherit;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  padding: 3px 10px; border-radius: 5px; transition: all .15s var(--ease);
}
.dx-seg button.on { background: #fff; color: var(--text-strong); box-shadow: 0 1px 3px rgba(15,23,42,.12); }

/* the dashboard pages don't want the heavy ambient orbs */
body.dxpage::before, body.dxpage::after { opacity: .3; }

/* ============ print (A4) ============
   The dashboards print as a report, not a screenshot: a centred title
   block, flat summary tiles, and ruled tables where only text columns
   wrap. Screen-only aids (charts, pickers, hints, search) are dropped. */
.dx-phead { display: none; }

@media print {
  @page {
    size: A4 portrait; margin: 11mm 10mm 12mm;
    @bottom-right { content: "Page " counter(page) " of " counter(pages); font: 7pt Arial, sans-serif; color: #555; }
  }
  html, body.dxpage { background: #fff !important; }
  body.dxpage::before, body.dxpage::after { display: none !important; }
  .dx { font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; color: #000; font-size: 8pt; }
  .dx, .dx * { animation: none !important; transition: none !important; box-shadow: none !important; }
  .dx .dx-dim { opacity: 1 !important; color: #888 !important; }
  .dx .dx-dim * { color: #888 !important; }

  /* ---- title block (replaces the screen head) ---- */
  .dx .print-header, .dx .dx-head { display: none !important; }
  .dx .dx-phead {
    display: block !important; text-align: center;
    border-bottom: 1.5pt solid #000; padding-bottom: 5pt; margin-bottom: 9pt;
  }
  .dx-phead .t { font-size: 13pt; font-weight: bold; letter-spacing: .02em; }
  .dx-phead .s { font-size: 11pt; font-weight: bold; margin-top: 2pt; }
  .dx-phead .p { font-size: 9pt; font-weight: bold; margin-top: 3pt; }
  .dx-phead .g { font-size: 7pt; color: #555; margin-top: 2pt; }

  /* ---- hidden in print ---- */
  .dx .no-print, .dx .dx-sec.no-print, .dx .dx-grid.no-print,
  .dx .dx-chart, .dx canvas, .dx .dx-chart-hd,
  .dx .dx-sec-hd .dx-note:not([id]), .dx .dx-tblhd .dx-note:not([id]),
  .dx .dx-tblhd input, .dx .dx-tblhd .dx-seg, .dx .dx-tblhd button,
  .dx .dx-chip .x, .dx .dx-warn, .dx .dx-inbar,
  .dx .dx-tbl th .ar { display: none !important; }
  .dx .dx-sec[style*="display:none"], .dx .dx-sec[style*="display: none"] { display: none !important; }

  /* ---- sections ---- */
  .dx .dx-sec { display: block !important; margin: 0 0 9pt !important; }
  .dx .dx-sec-hd {
    display: flex !important; align-items: baseline; gap: 6pt; margin: 0 0 4pt !important;
    border-bottom: .75pt solid #000; padding-bottom: 1.5pt; break-after: avoid;
  }
  .dx .dx-sec-hd h2 { display: block !important; font-size: 8.5pt !important; color: #000 !important; letter-spacing: .06em !important; margin: 0 !important; }
  .dx .dx-sec-hd .dx-note { font-size: 7pt !important; color: #444 !important; }
  .dx-pagebreak { break-before: page; }

  /* active filters line */
  .dx .dx-filters { display: flex !important; background: none !important; border: .75pt solid #999 !important; border-radius: 0 !important; padding: 3pt 6pt !important; margin-bottom: 8pt !important; }
  .dx .dx-filters .lbl { color: #000 !important; }
  .dx .dx-chip { border: .5pt solid #999 !important; border-radius: 2pt !important; padding: 0 4pt !important; font-size: 7.5pt !important; }

  /* ---- cards & tiles: flat, ruled, equal height per row ---- */
  .dx .dx-card { background: #fff !important; border: .75pt solid #999 !important; border-radius: 0 !important; overflow: visible !important; }
  .dx .dx-pad { padding: 5pt 7pt !important; }
  .dx .dx-grid { display: grid !important; gap: 4pt !important; break-inside: avoid; }
  .dx .dx-g6 { grid-template-columns: repeat(6,1fr) !important; }
  .dx .dx-g5 { grid-template-columns: repeat(5,1fr) !important; }
  .dx .dx-g4 { grid-template-columns: repeat(4,1fr) !important; }
  .dx .dx-g3 { grid-template-columns: repeat(3,1fr) !important; }
  .dx .dx-g2, .dx .dx-g21 { grid-template-columns: repeat(2,1fr) !important; }
  .dx .dx-stat {
    display: block !important; background: #fff !important;
    border: .75pt solid #999 !important; border-left: 2.5pt solid var(--c, #999) !important; border-radius: 0 !important;
    padding: 3pt 5pt 4pt !important; break-inside: avoid;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .dx .dx-stat .k { font-size: 6.5pt !important; color: #333 !important; white-space: normal !important; overflow: visible !important; letter-spacing: .04em !important; }
  .dx .dx-stat .v { font-size: 12pt !important; color: #000 !important; margin-top: 1pt !important; }
  .dx .dx-stat .v .u { font-size: 7pt !important; color: #333 !important; }
  .dx .dx-stat .s, .dx .dx-cap { font-size: 6.5pt !important; color: #444 !important; line-height: 1.35 !important; }
  .dx .dx-capk b { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .dx .dx-compo, .dx .dx-legend .sw { display: flex !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .dx .dx-legend .sw { display: block !important; }
  .dx .dx-legend { display: flex !important; font-size: 7pt !important; margin-top: 4pt !important; }
  .dx #dxTotal, .dx #axTotal { font-size: 22pt !important; color: #000 !important; }

  /* ---- tables ---- */
  .dx .dx-card:has(> .dx-scroll) { border: none !important; }
  .dx .dx-tblhd { display: flex !important; padding: 0 0 2pt !important; border: none !important; break-after: avoid; }
  .dx .dx-tblhd strong { font-size: 8.5pt !important; color: #000 !important; }
  .dx .dx-tblhd .dx-note { font-size: 7pt !important; color: #444 !important; }
  .dx .dx-scroll { max-height: none !important; overflow: visible !important; border-radius: 0 !important; }
  .dx .dx-tbl { display: table !important; width: 100% !important; font-size: 7.5pt !important; border-collapse: collapse !important; }
  .dx .dx-tbl thead { display: table-header-group; }
  .dx .dx-tbl tr { break-inside: avoid; }
  .dx .dx-tbl th, .dx .dx-tbl td {
    border: .5pt solid #888 !important; padding: 2pt 4pt !important;
    white-space: nowrap !important; word-break: normal !important; overflow-wrap: normal !important;
    vertical-align: middle !important; background: #fff !important; position: static !important;
  }
  .dx .dx-tbl th {
    background: #e4e4e4 !important; color: #000 !important; font-size: 6.5pt !important;
    letter-spacing: .03em !important; -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .dx .dx-tbl td.wrap { white-space: normal !important; }
  .dx .dx-tbl tbody tr.on td { background: #eef4fb !important; box-shadow: none !important; }
  .dx .dx-tbl tfoot td { background: #e4e4e4 !important; font-weight: bold !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* the capacity split under a row label sits on its own line */
  .dx .dx-tbl td .dx-cap { display: block !important; margin: 1pt 0 0 !important; white-space: normal !important; font-size: 6pt !important; }
  .dx .dx-pill { background: none !important; padding: 0 !important; font-size: 7pt !important; }
  .dx .dx-empty { padding: 6pt !important; }
}
