/* ============================================================
   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) ============ */
@media print {
  .dx, .dx * { animation: none !important; }
  .dx .dx-card, .dx .dx-stat { background: #fff !important; border: 1px solid #bbb !important; box-shadow: none !important; }
  .dx .dx-grid { display: grid !important; gap: 4px !important; }
  .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; padding: 4px 6px !important; }
  .dx .dx-stat .v { font-size: 12pt !important; }
  .dx .dx-stat .k { font-size: 6.5pt !important; }
  .dx .dx-stat .s, .dx .dx-cap { font-size: 6pt !important; color: #555 !important; }
  .dx .dx-sec { display: block !important; break-inside: avoid; margin-bottom: 7px !important; }
  .dx .dx-sec-hd { display: flex !important; margin-bottom: 3px !important; }
  .dx .dx-sec-hd h2 { display: block !important; font-size: 8pt !important; color: #000 !important; margin: 0 !important; }
  .dx .dx-head { display: flex !important; }
  .dx .dx-head h1 { display: block !important; font-size: 13pt !important; }
  .dx .dx-scroll { max-height: none !important; overflow: visible !important; }
  .dx .dx-tbl { display: table !important; font-size: 7.5pt !important; }
  .dx .dx-tbl th { background: #e8e8e8 !important; font-size: 6.5pt !important; padding: 3px 5px !important; border: 1px solid #bbb !important; position: static !important; }
  .dx .dx-tbl td { padding: 2.5px 5px !important; border: 1px solid #ddd !important; }
  .dx .dx-tbl tfoot td { background: #e8e8e8 !important; position: static !important; }
  .dx .dx-compo { display: flex !important; }
  .dx .dx-legend { display: flex !important; font-size: 6.5pt !important; }
  .dx .dx-chart, .dx canvas, .dx .dx-chart-hd { display: none !important; }
  .dx .dx-filters { display: flex !important; background: #f2f2f2 !important; border: 1px solid #ccc !important; }
  .dx .dx-chip .x { display: none !important; }
  .dx .dx-tblhd { display: flex !important; padding: 4px 6px !important; }
  .dx .dx-tblhd input, .dx .dx-tblhd .dx-seg, .dx .dx-tblhd button { display: none !important; }
  .dx-pagebreak { break-before: page; }
}
