:root {
  color-scheme: light;
  --navy-950: #071a2e;
  --navy-900: #0b2545;
  --navy-800: #123a63;
  --blue-700: #145da0;
  --blue-600: #1976b9;
  --blue-100: #dceefb;
  --blue-50: #eef7fd;
  --ink-900: #142333;
  --ink-700: #405266;
  --ink-500: #68798b;
  --line: #d9e2ec;
  --surface: #ffffff;
  --canvas: #f3f6f9;
  --red: #c62828;
  --red-soft: #fde8e8;
  --amber: #9a6700;
  --amber-soft: #fff1c2;
  --green: #237a47;
  --green-soft: #dff3e7;
  --gray: #596775;
  --gray-soft: #e8edf2;
  --shadow-sm: 0 2px 8px rgba(7, 26, 46, 0.08);
  --shadow-md: 0 10px 28px rgba(7, 26, 46, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  margin: 0;
  padding: 24px;
  color: var(--ink-900);
  background:
    linear-gradient(180deg, rgba(20, 93, 160, 0.05), transparent 260px),
    var(--canvas);
  line-height: 1.45;
}

.header {
  background: linear-gradient(120deg, var(--navy-950) 0%, var(--navy-900) 58%, var(--blue-700) 100%);
  color: white;
  padding: 28px 32px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 750;
  letter-spacing: -0.025em;
}

.subtitle {
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  letter-spacing: 0.01em;
}

.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  animation: riseIn 0.48s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--blue-600);
}

.stat-card:nth-child(2) { animation-delay: 45ms; }
.stat-card:nth-child(3) { animation-delay: 90ms; }
.stat-card:nth-child(4) { animation-delay: 135ms; }
.stat-card:nth-child(5) { animation-delay: 180ms; }

.stat-card:hover {
  transform: translateY(-3px);
  border-color: #b8c9d8;
  box-shadow: var(--shadow-md);
}

.stat-label {
  margin-bottom: 8px;
  color: var(--ink-500);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.stat-value {
  color: var(--ink-900);
  font-size: 34px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
}

#stat-open { color: var(--red) !important; }
#stat-ack { color: var(--amber) !important; }
#stat-closed { color: var(--green) !important; }

.stat-subtext {
  margin-top: 7px;
  color: var(--ink-500);
  font-size: 12px;
}

.violation-breakdown {
  display: none;
  background: var(--surface);
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.violation-breakdown-title {
  margin-bottom: 14px;
  color: var(--navy-900);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#violation-filter-label { color: var(--blue-700) !important; }

.violation-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.violation-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--canvas);
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.violation-pill:hover {
  transform: translateY(-1px);
  border-color: #abc4d8;
  background: var(--blue-50);
  box-shadow: var(--shadow-sm);
}

.violation-pill.active {
  border-color: var(--blue-700);
  background: var(--blue-50);
  color: var(--blue-700);
}

.violation-pill .pill-count {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(7, 26, 46, 0.09);
  font-size: 12px;
  font-weight: 800;
}

.violation-pill.active .pill-count { background: var(--blue-100); }
.violation-pill.source-mobile { border-left: 3px solid var(--blue-600); }

.controls-panel,
.filter-panel {
  background: var(--surface);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  align-items: center;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  color: var(--ink-700);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

select,
input[type="number"],
input[type="date"],
input[type="text"] {
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #bdcad7;
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink-900);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

select:hover,
input:hover { border-color: #8fa7ba; }

select:focus,
input:focus {
  outline: none;
  border-color: var(--blue-600);
  box-shadow: 0 0 0 3px rgba(25, 118, 185, 0.16);
}

button {
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(7, 26, 46, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(7, 26, 46, 0.16);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(7, 26, 46, 0.12);
}

button:focus-visible,
a:focus-visible,
.violation-pill:focus-visible {
  outline: 3px solid rgba(25, 118, 185, 0.28);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--blue-700);
  color: white;
}

.btn-primary:hover { background: #0f4f8c; }

.btn-secondary,
.filter-toggle {
  background: white;
  color: var(--blue-700);
  border-color: var(--blue-700);
}

.btn-secondary:hover,
.filter-toggle:hover {
  background: var(--blue-50);
  color: var(--navy-900);
}

.btn-danger {
  background: var(--red);
  color: white;
}

#progress {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--blue-700);
  font-weight: 700;
}

#progressBar { background: linear-gradient(90deg, var(--blue-700), var(--blue-600)) !important; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 3px solid rgba(25, 118, 185, 0.22);
  border-top-color: var(--blue-700);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.table-container {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink-700);
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 13px 12px;
  border-bottom: 2px solid #c5d2de;
  background: #eaf0f5;
  color: var(--navy-900);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.045em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: background 0.18s ease, color 0.18s ease;
}

th:hover { background: #dce7f0; }
th.sortable::after { content: " ⇅"; opacity: 0.34; font-size: 10px; }
th.sort-asc::after { content: " ↑"; opacity: 1; color: var(--blue-700); }
th.sort-desc::after { content: " ↓"; opacity: 1; color: var(--blue-700); }

td {
  padding: 13px 12px;
  border-bottom: 1px solid #e7edf2;
  vertical-align: top;
}

tbody tr {
  animation: rowIn 0.34s ease both;
  transition: background 0.16s ease, box-shadow 0.16s ease;
}

tbody tr:nth-child(2n) { background: #fbfcfd; }

tbody tr:hover {
  background: var(--blue-50);
  box-shadow: inset 4px 0 0 var(--blue-600);
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.35;
  text-transform: uppercase;
}

.status-open { background: var(--red-soft); color: var(--red); }
.status-acknowledged { background: var(--amber-soft); color: var(--amber); }
.status-closed { background: var(--green-soft); color: var(--green); }
.status-archived { background: var(--gray-soft); color: var(--gray); }

.view-btn {
  padding: 6px 11px;
  border: 1px solid var(--blue-700);
  border-radius: 6px;
  background: var(--blue-700);
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.view-btn:hover { background: var(--navy-900); }

.thumbnail {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.thumbnail:hover {
  transform: scale(1.06);
  box-shadow: var(--shadow-md);
}

.no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--canvas);
  color: var(--ink-500);
  font-size: 10px;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100%;
  height: 100%;
  background: rgba(7, 26, 46, 0.72);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  overflow-y: auto;
  max-width: 800px;
  max-height: 85vh;
  margin: 5% auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(7, 26, 46, 0.3);
  animation: slideDown 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 25px;
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
}

.modal-title {
  margin: 0;
  color: var(--navy-900);
  font-size: 20px;
  font-weight: 750;
}

.close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: white;
  color: var(--ink-700);
  font-size: 20px;
}

.close-btn:hover { background: var(--blue-50); }
.modal-body { padding: 25px; }

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  overflow-y: auto;
  max-height: 400px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--canvas);
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: white;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.checkbox-item:hover {
  border-color: var(--line);
  background: var(--blue-50);
}

.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--blue-700);
  cursor: pointer;
}

.checkbox-item label {
  margin: 0;
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 500;
  text-transform: none;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 20px 25px;
  border-top: 1px solid var(--line);
  background: var(--canvas);
}

.filter-panel { display: none; }

.filter-panel.active {
  display: block;
  animation: panelIn 0.24s ease both;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.filter-input {
  flex: 1;
  min-width: 150px;
  padding: 8px 12px;
  font-size: 13px;
}

.filter-input::placeholder {
  color: #8291a0;
  font-style: normal;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
}

.filter-toggle.active {
  background: var(--blue-700);
  color: white;
}

.eo-counter {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding: 42px;
  border: 1px solid rgba(108, 172, 224, 0.28);
  border-radius: 20px;
  margin-bottom: 28px;
  background:
    linear-gradient(125deg, rgba(20, 93, 160, 0.32), transparent 48%),
    linear-gradient(135deg, #06182a 0%, #0b2545 55%, #123f69 100%);
  color: white;
  box-shadow: 0 18px 46px rgba(7, 26, 46, 0.28);
}

.eo-counter::before {
  content: "";
  position: absolute;
  top: -240px;
  right: -120px;
  z-index: -1;
  width: 540px;
  height: 540px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(55, 145, 218, 0.22), transparent 68%);
  pointer-events: none;
}

.eo-counter::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 42px 100%;
  mask-image: linear-gradient(90deg, black, transparent 75%);
  pointer-events: none;
}

.eo-counter-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 30px;
}

.eo-title {
  margin-bottom: 8px;
  color: #8dccff;
  font-size: clamp(19px, 2vw, 25px);
  font-weight: 800;
  letter-spacing: 0.055em;
  line-height: 1.2;
  text-transform: uppercase;
}

.eo-subtitle {
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px;
}

.eo-days-badge {
  padding: 11px 24px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 18px;
  font-weight: 850;
  letter-spacing: 0.06em;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(198, 40, 40, 0.36);
}

.eo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 18px;
}

.eo-metric {
  min-height: 132px;
  padding: 22px 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.075);
  text-align: center;
  backdrop-filter: blur(3px);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.eo-metric:hover {
  transform: translateY(-3px);
  border-color: rgba(141, 204, 255, 0.42);
  background: rgba(255, 255, 255, 0.12);
}

.eo-metric-label {
  margin-bottom: 9px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eo-metric-value {
  font-size: clamp(28px, 2.6vw, 38px);
  font-weight: 850;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.eo-metric-sub {
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
}

.eo-value-red { color: #ff8585; }
.eo-value-amber { color: #ffd166; }
.eo-value-green { color: #72d69a; }
.eo-value-white { color: #ffffff; }

.eo-zero-highlight {
  color: #ff8585;
  font-size: clamp(36px, 3.4vw, 48px);
  text-shadow: 0 0 24px rgba(255, 92, 92, 0.34);
}

.eo-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.eo-footer-text {
  color: rgba(255, 255, 255, 0.54);
  font-size: 12px;
}

.eo-footer-link {
  color: #8dccff;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: color 0.18s ease;
}

.eo-footer-link:hover { color: white; }

.privacy-badge {
  display: inline-block;
  margin-right: 4px;
  font-size: 14px;
  vertical-align: middle;
}

.privacy-badge.private { color: var(--red); }
.privacy-badge.public { color: var(--green); opacity: 0.75; }

.routed-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.routed-badge.routed { background: var(--green-soft); color: #1b653a; }
.routed-badge.unrouted { background: var(--amber-soft); color: var(--amber); }
.routed-badge.legacy { background: var(--gray-soft); color: var(--gray); }

.tenant-report-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--blue-700);
  color: white;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(-24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes riseIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes rowIn {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes panelIn {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 768px) {
  body { padding: 10px; }

  .header {
    padding: 22px 18px;
    border-radius: var(--radius-md);
  }

  h1 { font-size: 24px; }
  .subtitle { font-size: 12px; }

  .stats-container { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 17px 16px; }
  .stat-label { font-size: 10px; }
  .stat-value { font-size: 26px; }

  .controls-panel,
  .filter-panel { padding: 16px; }

  .control-row {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .control-group { width: 100%; }

  select,
  input[type="number"] { width: 100%; font-size: 16px; }

  button { width: 100%; padding: 12px; font-size: 16px; }

  .table-container {
    margin: 0 -10px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  table { font-size: 11px; }
  th, td { padding: 9px 6px; }
  th { top: 0; z-index: 100; background: #eaf0f5; }

  .status-badge { padding: 3px 7px; font-size: 9px; }
  .view-btn { padding: 5px 8px; font-size: 10px; }
  .thumbnail, .no-image { width: 40px; height: 40px; }
  .no-image { font-size: 8px; }

  .modal-content { margin: 10px; max-height: 90vh; border-radius: var(--radius-md); }
  .modal-header { padding: 15px; }
  .modal-title { font-size: 18px; }
  .modal-body { padding: 15px; }
  .checkbox-grid { grid-template-columns: 1fr; max-height: 300px; }
  .modal-actions { padding: 15px; flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }

  .mobile-hide { display: none; }
  #progressBarContainer { margin: 0 -10px 15px; }

  .eo-counter {
    padding: 28px 18px;
    border-radius: var(--radius-md);
  }

  .eo-title { font-size: 18px; letter-spacing: 0.035em; }
  .eo-subtitle { font-size: 13px; }
  .eo-days-badge { padding: 9px 18px; font-size: 15px; }
  .eo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .eo-metric { min-height: 118px; padding: 17px 8px; }
  .eo-metric-label { font-size: 10px; }
  .eo-metric-value { font-size: 23px; }
  .eo-zero-highlight { font-size: 31px; }
  .eo-metric-sub { font-size: 10px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .stats-container { grid-template-columns: repeat(3, 1fr); }
  .control-row { flex-wrap: wrap; }
  .eo-counter { padding: 34px; }
  .eo-grid { grid-template-columns: repeat(3, 1fr); }
  table { font-size: 12px; }
}

@media (hover: none) and (pointer: coarse) {
  button { min-height: 44px; }
  .view-btn { min-height: 36px; }
  .checkbox-item { padding: 12px; }
  .checkbox-item input[type="checkbox"] { width: 24px; height: 24px; }
  tr { cursor: pointer; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
