:root {
  --tz-primary: #2563eb;
  --tz-primary-dark: #1d4ed8;
  --tz-sidebar-bg: #111827;
  --tz-sidebar-text: #cbd5e1;
  --tz-sidebar-active: #1f2937;
  --tz-bg: #f3f4f6;
  --tz-card-bg: #ffffff;
  --tz-text: #111827;
  --tz-text-muted: #6b7280;
  --tz-border: #e5e7eb;
}

[data-theme="dark"] {
  --tz-bg: #0f172a;
  --tz-card-bg: #1e293b;
  --tz-text: #e2e8f0;
  --tz-text-muted: #94a3b8;
  --tz-border: #334155;
  --tz-sidebar-bg: #0b1220;
  --tz-sidebar-active: #1e293b;
}

body {
  background-color: var(--tz-bg);
  color: var(--tz-text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 0.9375rem;
}

.tz-sidebar {
  background-color: var(--tz-sidebar-bg);
  min-height: 100vh;
  width: 288px;
  flex: 0 0 288px;
  color: var(--tz-sidebar-text);
  transition: margin-left .2s ease;
}

.tz-sidebar .brand {
  padding: 1.1rem 1.25rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: .6rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.tz-sidebar .nav-section-title {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #64748b;
  padding: 1rem 1.25rem .35rem;
}

.tz-sidebar .nav-link {
  color: var(--tz-sidebar-text);
  padding: .62rem 1.25rem;
  border-radius: 0;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-left: 3px solid transparent;
}
.tz-sidebar .nav-link > i { flex: 0 0 1.25rem; text-align: center; font-size: 1.05rem; }
.tz-sidebar .nav-link .badge { margin-left: auto !important; flex: 0 0 auto; }

.tz-sidebar .nav-link.sub {
  padding-left: 1.6rem;
  font-size: .88rem;
}

.tz-sidebar .nav-link:hover {
  background-color: var(--tz-sidebar-active);
  color: #fff;
}

.tz-sidebar .nav-link.active {
  background-color: rgba(59,130,246,.18);
  border-left-color: var(--tz-primary);
  color: #fff;
  font-weight: 600;
}
.tz-sidebar { overflow-y: auto; scrollbar-width: thin; position: sticky; top: 0; height: 100vh; align-self: flex-start; }
.tz-sidebar .brand { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tz-topbar {
  background-color: var(--tz-card-bg);
  border-bottom: 1px solid var(--tz-border);
  padding: .65rem 1.25rem;
}

.tz-content {
  padding: 1.5rem;
}

.card {
  background-color: var(--tz-card-bg);
  border: 1px solid var(--tz-border);
  border-radius: .6rem;
}

.tz-kpi-card {
  border-radius: .75rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--tz-border);
  background: var(--tz-card-bg);
  transition: transform .15s ease, box-shadow .15s ease;
}

.tz-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -8px rgba(0,0,0,.15);
}

.tz-kpi-value {
  font-size: 1.85rem;
  font-weight: 700;
  line-height: 1.1;
}

.tz-kpi-label {
  color: var(--tz-text-muted);
  font-size: .8rem;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  color: #fff;
}

.table-responsive-tz {
  overflow-x: auto;
}

.tz-countdown {
  font-weight: 600;
  font-size: .8rem;
}

#reminderPopupOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

#reminderPopupOverlay .popup-card {
  background: var(--tz-card-bg);
  color: var(--tz-text);
  border-radius: .75rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,.5);
}

@media (max-width: 991.98px) {
  .tz-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1050;
    margin-left: -288px;
  }
  .tz-sidebar.show {
    margin-left: 0;
  }
}

/* ---- Performance alerts (Green / Orange / Red) ------------------------------------------ */
.tz-alert-green  { --c: #16a34a; }
.tz-alert-orange { --c: #f97316; }
.tz-alert-red    { --c: #dc2626; }

.tz-sidebar .tz-alert-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-weight: 600;
}
.tz-alert-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c);
  flex-shrink: 0;
}
.tz-alert-count {
  margin-left: auto;
  min-width: 1.7rem;
  text-align: center;
  font-size: .72rem;
  font-weight: 700;
  padding: .1rem .45rem;
  border-radius: 999px;
  background: var(--c);
  color: #fff;
}
.tz-sidebar .tz-alert-link.active { background-color: var(--c); color: #fff; }
.tz-sidebar .tz-alert-link.active .tz-alert-dot { background: #fff; }
.tz-sidebar .tz-alert-link.active .tz-alert-count { background: rgba(255,255,255,.28); }

/* Blink only while there is something to look at. */
.tz-alert-link.is-blinking .tz-alert-dot   { animation: tz-pulse 1.1s ease-out infinite; }
.tz-alert-link.is-blinking .tz-alert-count { animation: tz-blink 1.1s ease-in-out infinite; }
.tz-alert-link.is-blinking:not(.active)    { animation: tz-glow 1.6s ease-in-out infinite; }

@keyframes tz-blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes tz-pulse {
  0%   { box-shadow: 0 0 0 0 var(--c); }
  70%  { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes tz-glow {
  0%, 100% { background-color: transparent; }
  50%      { background-color: color-mix(in srgb, var(--c) 22%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .tz-alert-link.is-blinking,
  .tz-alert-link.is-blinking .tz-alert-dot,
  .tz-alert-link.is-blinking .tz-alert-count { animation: none !important; }
}

.tz-alert-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

/* ---- Operator auto-logout countdown ------------------------------------------------------ */
#tzSessionPill {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1900;
  background: var(--tz-card-bg);
  color: var(--tz-text);
  border: 1px solid var(--tz-border);
  border-radius: 999px;
  padding: .4rem .9rem;
  font-size: .8rem;
  box-shadow: 0 6px 20px -8px rgba(0, 0, 0, .35);
}
#tzSessionPill.is-soon { background: #dc2626; color: #fff; border-color: #dc2626; animation: tz-blink 1s ease-in-out infinite; }
