/* mail-server-monitor panel
 *
 * Layered on Bootstrap 5.3's color modes. Everything below is tokens + the
 * chart layer; Bootstrap supplies the grid, tables, forms and offcanvas.
 *
 * Chart colours are the validated categorical slots 1 and 2 (blue / orange),
 * which clear every CVD, normal-vision and contrast gate in both modes as an
 * adjacent pair. Failure tiles use single status colours, each paired with an
 * icon and a label so hue never carries the meaning alone.
 */

:root {
  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --ink-primary: #0b0b0b;
  --ink-secondary: #52514e;
  --ink-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --hairline: rgba(11, 11, 11, 0.10);

  --series-1: #2a78d6;
  --series-2: #eb6834;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --radius: 10px;
}

[data-bs-theme="dark"] {
  --surface-1: #1a1a19;
  --plane: #0d0d0d;
  --ink-primary: #ffffff;
  --ink-secondary: #c3c2b7;
  --ink-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --hairline: rgba(255, 255, 255, 0.10);

  --series-1: #3987e5;
  --series-2: #d95926;
}

body {
  background: var(--plane);
  color: var(--ink-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* -- shell ---------------------------------------------------------------- */

.navbar-mm {
  background: var(--surface-1);
  border-bottom: 1px solid var(--hairline);
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--series-1);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 14px;
  flex: none;
}

.nav-pills .nav-link {
  color: var(--ink-secondary);
  border-radius: 8px;
  padding: 0.3rem 0.7rem;
  font-size: 0.875rem;
}

.nav-pills .nav-link.active {
  background: color-mix(in srgb, var(--series-1) 14%, transparent);
  color: var(--series-1);
  font-weight: 600;
}

/* -- health pill ---------------------------------------------------------- */

.health {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  color: var(--ink-secondary);
  white-space: nowrap;
}

.health .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-muted);
  flex: none;
}

.health.is-ok .dot { background: var(--status-good); }
.health.is-behind .dot { background: var(--status-warning); }
.health.is-down .dot { background: var(--status-critical); }

/* -- cards ---------------------------------------------------------------- */

.card-mm {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
}

.card-mm > header {
  padding: 0.85rem 1rem 0.35rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-mm > header h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-secondary);
  margin: 0;
}

.card-mm > header .sub {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.card-body-mm { padding: 0.5rem 1rem 1rem; }

/* A card stretched to match its row neighbour carries no bottom margin of its
   own — the row supplies the gap — and lets its body take up the slack. */
.card-mm.h-100 {
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}

.card-mm.h-100 > .card-body-mm {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-mm.h-100 > .card-body-mm > .row { flex: 1; }

/* -- stat tiles ----------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.tile {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 0.8rem 0.9rem;
  min-width: 0;
}

.tile .label {
  font-size: 0.75rem;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}

.tile .label .ico {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex: none;
  background: var(--ink-muted);
}

.tile[data-tone="good"] .ico { background: var(--status-good); }
.tile[data-tone="warning"] .ico { background: var(--status-warning); }
.tile[data-tone="serious"] .ico { background: var(--status-serious); }
.tile[data-tone="critical"] .ico { background: var(--status-critical); }
.tile[data-tone="s1"] .ico { background: var(--series-1); }
.tile[data-tone="s2"] .ico { background: var(--series-2); }

.tile .value {
  font-size: 1.6rem;
  line-height: 1.15;
  font-weight: 600;
  color: var(--ink-primary);
}

.tile .foot {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 0.15rem;
  min-height: 1em;
}

.tile .spark { margin-top: 0.4rem; display: block; }

/* -- charts --------------------------------------------------------------- */

.chart-wrap { position: relative; }

.chart-wrap svg { display: block; width: 100%; overflow: visible; }

.grid line {
  stroke: var(--gridline);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.axis line { stroke: var(--baseline); stroke-width: 1; }

.axis text,
.tick text {
  fill: var(--ink-muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.series-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.series-area { opacity: 0.10; }

.crosshair {
  stroke: var(--baseline);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.hover-dot {
  stroke: var(--surface-1);
  stroke-width: 2;
}

/* 2px surface gap between stacked segments, per the mark spec */
.bar-seg { stroke: var(--surface-1); stroke-width: 2; }

.legend {
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--ink-secondary);
}

.legend .key {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.75rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  z-index: 5;
  min-width: 130px;
  opacity: 0;
  transition: opacity 0.08s linear;
}

.chart-tip.on { opacity: 1; }

.chart-tip .t-head {
  color: var(--ink-muted);
  margin-bottom: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.chart-tip .t-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: space-between;
  color: var(--ink-secondary);
}

.chart-tip .t-row b {
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
}

.chart-empty {
  color: var(--ink-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 2.5rem 0;
}

/* -- tables --------------------------------------------------------------- */

.table-mm {
  --bs-table-bg: transparent;
  font-size: 0.8125rem;
  margin: 0;
}

.table-mm th {
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom-color: var(--hairline) !important;
  white-space: nowrap;
}

.table-mm td {
  border-bottom-color: var(--hairline) !important;
  vertical-align: middle;
}

.table-mm .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-mm th.sortable {
  cursor: pointer;
  user-select: none;
}

.table-mm th.sortable:hover { color: var(--ink-primary); }

.table-mm th.sorted::after {
  content: " ↓";
  color: var(--series-1);
}

.row-link { cursor: pointer; }
.row-link:hover { background: color-mix(in srgb, var(--series-1) 7%, transparent); }

.mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.78em;
}

.truncate {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: bottom;
}

/* inline magnitude bar in a table cell */
.microbar {
  height: 4px;
  border-radius: 2px;
  background: var(--series-1);
  min-width: 2px;
  display: block;
}

/* -- status chips --------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 5px;
  border: 1px solid var(--hairline);
  color: var(--ink-secondary);
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-muted);
}

.chip.sent::before { background: var(--status-good); }
.chip.deferred::before { background: var(--status-warning); }
.chip.bounced::before { background: var(--status-serious); }
.chip.rejected::before,
.chip.expired::before,
.chip.failure::before { background: var(--status-critical); }
.chip.success::before { background: var(--status-good); }
.chip.in::before { background: var(--series-1); }
.chip.out::before { background: var(--series-2); }

/* -- login ---------------------------------------------------------------- */

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 1.6rem;
}

/* -- misc ----------------------------------------------------------------- */

.skeleton {
  background: linear-gradient(90deg, var(--gridline) 25%, var(--surface-1) 50%, var(--gridline) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 5px;
  height: 1em;
}

@keyframes shimmer {
  to { background-position: -200% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .chart-tip { transition: none; }
}

.section-gap { margin-bottom: 1rem; }

@media (max-width: 575.98px) {
  .tile .value { font-size: 1.35rem; }
  .card-body-mm { padding: 0.5rem 0.75rem 0.9rem; }
}
