/* ==========================================================================
   Mail Dashboard v9 — Production polish layer.
   Additive only — does not replace any rule in dashboard.css.
   ========================================================================== */

/* ----- 1. Cleaner cards ------------------------------------------------ */
.card {
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover {
  border-color: rgba(108,140,255,0.25);
  box-shadow: 0 10px 30px -22px rgba(108,140,255,0.4);
}
.card.metric { padding: 14px 16px; }
.card.metric .big { font-variant-numeric: tabular-nums; }
.card.compact { padding: 12px 14px; }

/* sticky page header on long pages */
.page > .card-head.sticky,
.page .sticky-bar {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(180deg, rgba(17,20,29,0.96) 60%, rgba(17,20,29,0.7));
  backdrop-filter: blur(6px);
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

/* ----- 2. Loading skeletons ------------------------------------------- */
.skel {
  display: inline-block;
  background: linear-gradient(90deg,
    rgba(255,255,255,0.05) 0%,
    rgba(255,255,255,0.12) 50%,
    rgba(255,255,255,0.05) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 6px;
}
.skel.line { height: 12px; width: 100%; }
.skel.line.short { width: 40%; }
.skel.line.med   { width: 65%; }
.skel.h1 { height: 22px; width: 60%; }
.skel.block { height: 80px; width: 100%; }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ----- 3. Modern modals ----------------------------------------------- */
.v9-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease;
}
.v9-modal.show { opacity: 1; pointer-events: auto; }
.v9-modal .v9-modal-box {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: min(640px, 92vw);
  max-height: 86vh;
  overflow: auto;
  padding: 22px 24px;
  transform: translateY(8px) scale(.98);
  transition: transform .2s cubic-bezier(.2,.7,.3,1);
  box-shadow: 0 24px 60px -20px rgba(0,0,0,0.6);
}
.v9-modal.show .v9-modal-box { transform: none; }
.v9-modal .v9-modal-head {
  display:flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.v9-modal .v9-modal-close {
  background: transparent; border: 0; color: var(--muted);
  font-size: 22px; cursor: pointer; padding: 0 4px;
}

/* ----- 4. Filter chips ------------------------------------------------ */
.v9-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.v9-chip {
  user-select: none;
  cursor: pointer;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-1);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .02em;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.v9-chip:hover { color: var(--text); border-color: rgba(108,140,255,.35); }
.v9-chip.on {
  background: rgba(108,140,255,.16);
  color: var(--text);
  border-color: rgba(108,140,255,.55);
}
.v9-chip.danger.on { background: rgba(243,112,112,.18); border-color: rgba(243,112,112,.55); }
.v9-chip.warn.on   { background: rgba(245,184,90,.18);  border-color: rgba(245,184,90,.55); }
.v9-chip.ok.on     { background: rgba(52,211,153,.18);  border-color: rgba(52,211,153,.55); }

/* ----- 5. Compact stat grid -------------------------------------------- */
.v9-statgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.v9-stat {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-1);
}
.v9-stat .lbl { color: var(--muted); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; }
.v9-stat .val { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.v9-stat .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.v9-stat.ok   { border-color: rgba(52,211,153,.4); }
.v9-stat.warn { border-color: rgba(245,184,90,.4); }
.v9-stat.bad  { border-color: rgba(243,112,112,.4); }

/* ----- 6. Animated progress bar --------------------------------------- */
.v9-progress {
  width: 100%;
  height: 8px;
  background: var(--bg-1);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}
.v9-progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--info));
  border-radius: inherit;
  transition: width .6s cubic-bezier(.2,.7,.3,1);
  box-shadow: 0 0 12px rgba(108,140,255,0.4);
}
.v9-progress.indeterminate > i {
  width: 35%;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: indet 1.4s linear infinite;
}
@keyframes indet {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

/* ----- 7. Status badges (health monitor) ------------------------------ */
.v9-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px;
  font-size: 11.5px;
  border-radius: 999px;
  border: 1px solid;
  background: var(--bg-1);
  font-weight: 500;
}
.v9-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  display: inline-block;
}
.v9-badge.up   { color: var(--success); border-color: rgba(52,211,153,.4); }
.v9-badge.up::before   { background: var(--success); box-shadow: 0 0 6px rgba(52,211,153,.7); }
.v9-badge.warn { color: var(--warning); border-color: rgba(245,184,90,.4); }
.v9-badge.warn::before { background: var(--warning); }
.v9-badge.down { color: var(--danger);  border-color: rgba(243,112,112,.4); }
.v9-badge.down::before { background: var(--danger); box-shadow: 0 0 6px rgba(243,112,112,.7); }
.v9-badge.idle { color: var(--muted);   border-color: var(--line); }
.v9-badge.idle::before { background: var(--muted); }

/* ----- 8. Cleaner tables ---------------------------------------------- */
.table-tools {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center; margin-bottom: 10px;
}
.table-tools .grow { flex: 1; }
.data-row-selectable { cursor: default; }
.data-row-selectable input[type="checkbox"] { transform: translateY(1px); }
.data tbody tr {
  transition: background .12s ease;
}
.data tbody tr.selected { background: rgba(108,140,255,0.07); }
.data tbody tr:hover    { background: rgba(255,255,255,0.03); }

/* ----- 9. Logs ---------------------------------------------------------- */
.logbox.v9 {
  background: #0a0c12;
  border: 1px solid var(--line);
  padding: 12px;
  border-radius: 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  max-height: 70vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.logbox.v9 .line { display: block; cursor: copy; padding: 0 4px; border-radius: 4px; }
.logbox.v9 .line:hover { background: rgba(255,255,255,0.04); }
.logbox.v9 .line.collapsed::after {
  content: " · " attr(data-count) "× repeated";
  color: var(--muted); font-style: italic;
}
.logbox.v9 .qid { color: var(--info); font-weight: 600; }
.logbox.v9 .l-sent     { color: #7ee8c4; }
.logbox.v9 .l-deferred { color: #f5c074; }
.logbox.v9 .l-bounced  { color: #ff8d8d; font-weight: 600; }
.logbox.v9 .l-error    { color: #ff8d8d; }
.logbox.v9 .l-warmup   { color: #c0a3ff; }
.logbox.v9 .l-track    { color: #5dd6f2; }

/* ----- 10. Heatmap ---------------------------------------------------- */
.v9-heatmap { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; margin-top: 8px; }
.v9-heatmap .cell {
  aspect-ratio: 1 / 1;
  background: var(--bg-1);
  border-radius: 3px;
  position: relative;
}
.v9-heatmap .cell[data-v="1"] { background: rgba(108,140,255,0.15); }
.v9-heatmap .cell[data-v="2"] { background: rgba(108,140,255,0.30); }
.v9-heatmap .cell[data-v="3"] { background: rgba(108,140,255,0.55); }
.v9-heatmap .cell[data-v="4"] { background: rgba(108,140,255,0.85); }
.v9-heatmap .cell[data-v="5"] { background: rgba(93,214,242,1); box-shadow: 0 0 6px rgba(93,214,242,.5); }
.v9-heatmap-legend { font-size:11px; color: var(--muted); display:flex; gap:6px; align-items:center; margin-top:6px; }

/* ----- 11. Cards / sections with icons -------------------------------- */
.v9-section { margin: 20px 0; }
.v9-section > h2 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }

/* ----- 12. Mobile responsive sweep ----------------------------------- */
@media (max-width: 900px) {
  .sidebar { width: 100%; position: static; height: auto; padding: 8px 12px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .sidebar nav .nav-section { width: 100%; padding-top: 6px; }
  .content { padding: 14px; }
  .grid-2col, .grid-cards { grid-template-columns: 1fr !important; }
  .topbar-actions { flex-wrap: wrap; }
  .v9-statgrid { grid-template-columns: repeat(2, 1fr); }
}

/* ----- 13. Subtle fade-in for new cards ------------------------------ */
.card { animation: v9-fadein .35s ease both; }
@keyframes v9-fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* ----- 14. Compact toolbar buttons ------------------------------------ */
.btn.xs { padding: 4px 9px; font-size: 11.5px; }
.btn.icon { padding: 4px 8px; font-size: 13px; }

/* ----- 15. Toast (v9) ------------------------------------------------- */
.v9-toast {
  position: fixed; bottom: 18px; right: 18px; z-index: 300;
  background: var(--bg-2); border:1px solid var(--line);
  border-radius: 12px; padding: 10px 14px;
  box-shadow: 0 18px 40px -16px rgba(0,0,0,0.55);
  font-size: 13px;
  transform: translateY(20px); opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}
.v9-toast.show { transform: none; opacity: 1; }
.v9-toast.ok   { border-color: rgba(52,211,153,.5); }
.v9-toast.bad  { border-color: rgba(243,112,112,.5); }

/* ----- 16. Search input variant -------------------------------------- */
input.v9-search {
  background: var(--bg-1);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  min-width: 220px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input.v9-search:focus {
  outline: none;
  border-color: rgba(108,140,255,0.55);
  box-shadow: 0 0 0 3px rgba(108,140,255,0.18);
}

/* ----- 17. Spinner ---------------------------------------------------- */
.v9-spin {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  animation: v9-spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes v9-spin { to { transform: rotate(360deg); } }
