.ec-agent-page {
  --agent-border: rgba(15, 23, 42, 0.1);
  --agent-muted: #64748b;
  display: grid;
  gap: 1rem;
  max-width: 1180px;
  margin: 0 auto;
  color: #0f172a;
}

.ec-agent-page-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  border: 1px solid var(--agent-border);
  border-radius: 1rem;
  background:
    radial-gradient(circle at 88% 0%, rgba(110, 198, 232, 0.2), transparent 35%),
    #fff;
  padding: 1rem 1.1rem;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.06);
}

.ec-agent-page-icon {
  display: grid;
  width: 3rem;
  height: 3rem;
  flex: 0 0 3rem;
  place-items: center;
  border-radius: 0.85rem;
  background: linear-gradient(145deg, #0284c7, #075985);
  color: #fff;
  box-shadow: 0 9px 22px rgba(2, 132, 199, 0.2);
}

.ec-agent-page-icon svg {
  width: 1.4rem;
  height: 1.4rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ec-agent-page-head small {
  color: #0284c7;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.ec-agent-page-head h2 {
  margin-top: 0.12rem;
  font-size: clamp(1.2rem, 2vw, 1.65rem);
  font-weight: 780;
  letter-spacing: -0.02em;
}

.ec-agent-page-head p {
  margin-top: 0.18rem;
  color: var(--agent-muted);
  font-size: 0.78rem;
}

.ec-agent-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  margin-left: auto;
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: 9999px;
  background: rgba(34, 197, 94, 0.08);
  padding: 0.35rem 0.6rem;
  color: #15803d;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.ec-agent-live-badge i {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
  animation: ec-agent-pulse 1.4s ease-in-out infinite;
}

.ec-agent-scope-card {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--agent-border);
  border-radius: 0.85rem;
  background: #fff;
}

.ec-agent-scope-card > div {
  min-width: 0;
  padding: 0.7rem 0.85rem;
}

.ec-agent-scope-card > div + div {
  border-left: 1px solid var(--agent-border);
}

.ec-agent-scope-card small,
.ec-agent-scope-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ec-agent-scope-card small {
  color: var(--agent-muted);
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ec-agent-scope-card strong {
  margin-top: 0.2rem;
  font-size: 0.7rem;
  font-weight: 720;
}

.ec-agent-tabs {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--agent-border);
  border-radius: 0.7rem;
  background: #fff;
  padding: 0.2rem;
}

.ec-agent-tabs button {
  border-radius: 0.5rem;
  padding: 0.5rem 0.9rem;
  color: #64748b;
  font-size: 0.67rem;
  font-weight: 700;
}

.ec-agent-tabs button.is-active {
  background: #0f172a;
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
}

.ec-agent-entry-form,
.ec-agent-upload-panel,
.ec-agent-history {
  border: 1px solid var(--agent-border);
  border-radius: 1rem;
  background: #fff;
  padding: clamp(1rem, 2vw, 1.35rem);
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.045);
}

.ec-agent-form-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--agent-border);
  padding-bottom: 0.8rem;
}

.ec-agent-form-title small {
  color: #0284c7;
  font-size: 0.56rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.ec-agent-form-title h3,
.ec-agent-history h3 {
  margin-top: 0.15rem;
  font-size: 0.95rem;
  font-weight: 760;
}

.ec-agent-form-title p {
  margin-top: 0.2rem;
  color: var(--agent-muted);
  font-size: 0.68rem;
}

.ec-agent-form-title > span {
  color: #64748b;
  font-size: 0.55rem;
  font-weight: 650;
}

.ec-agent-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.ec-agent-field {
  display: grid;
  gap: 0.28rem;
  color: #334155;
  font-size: 0.62rem;
  font-weight: 700;
}

.ec-agent-field input,
.ec-agent-field select,
.ec-agent-field textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 0.6rem;
  outline: none;
  background: #fff;
  padding: 0.62rem 0.68rem;
  color: #0f172a;
  font-size: 0.72rem;
  font-weight: 500;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ec-agent-field textarea {
  resize: vertical;
  min-height: 6.5rem;
}

.ec-agent-field input:focus,
.ec-agent-field select:focus,
.ec-agent-field textarea:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.1);
}

.ec-agent-field input[readonly] {
  background: #f1f5f9;
  color: #475569;
}

.ec-agent-field > small {
  color: #94a3b8;
  font-size: 0.53rem;
  font-weight: 500;
}

.ec-agent-vote-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
  border: 1px solid rgba(2, 132, 199, 0.15);
  border-radius: 0.8rem;
  background: rgba(2, 132, 199, 0.035);
  padding: 0.85rem;
}

.ec-agent-vote-grid legend {
  padding: 0 0.4rem;
  color: #0369a1;
  font-size: 0.62rem;
  font-weight: 800;
}

.ec-agent-total-box {
  display: grid;
  align-content: center;
  border-radius: 0.6rem;
  background: #0f172a;
  padding: 0.5rem 0.65rem;
  color: #fff;
}

.ec-agent-total-box small {
  font-size: 0.48rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ec-agent-total-box strong {
  margin-top: 0.12rem;
  font-size: 1rem;
}

.ec-agent-confirm {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin-top: 1rem;
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 0.65rem;
  background: rgba(245, 158, 11, 0.055);
  padding: 0.65rem;
  color: #475569;
  font-size: 0.62rem;
  line-height: 1.45;
}

.ec-agent-confirm input {
  margin-top: 0.12rem;
  accent-color: #0284c7;
}

.ec-agent-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
  margin-top: 1rem;
}

.ec-agent-btn,
.ec-agent-template-btn {
  border-radius: 0.62rem;
  padding: 0.58rem 0.85rem;
  font-size: 0.64rem;
  font-weight: 750;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.ec-agent-btn:hover,
.ec-agent-template-btn:hover {
  transform: translateY(-1px);
}

.ec-agent-btn.is-primary {
  background: linear-gradient(145deg, #0284c7, #0369a1);
  color: #fff;
  box-shadow: 0 7px 18px rgba(2, 132, 199, 0.18);
}

.ec-agent-btn.is-secondary,
.ec-agent-template-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #475569;
}

.ec-agent-btn.is-danger {
  background: linear-gradient(145deg, #dc2626, #b91c1c);
  color: #fff;
  box-shadow: 0 7px 18px rgba(220, 38, 38, 0.18);
}

.ec-agent-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.ec-agent-dropzone {
  display: grid;
  min-height: 10rem;
  place-items: center;
  align-content: center;
  gap: 0.35rem;
  border: 1.5px dashed #94a3b8;
  border-radius: 0.8rem;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
}

.ec-agent-dropzone:hover {
  border-color: #0284c7;
  background: rgba(2, 132, 199, 0.04);
}

.ec-agent-dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.ec-agent-drop-icon {
  display: grid;
  width: 2.6rem;
  height: 2.6rem;
  place-items: center;
  border-radius: 50%;
  background: rgba(2, 132, 199, 0.1);
  color: #0284c7;
  font-size: 1.3rem;
}

.ec-agent-dropzone strong {
  font-size: 0.75rem;
}

.ec-agent-dropzone small {
  color: #94a3b8;
  font-size: 0.56rem;
}

.ec-agent-upload-table {
  margin-top: 0.8rem;
  overflow: hidden;
  border: 1px solid var(--agent-border);
  border-radius: 0.7rem;
}

.ec-agent-upload-table > div {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(3, minmax(5rem, 0.7fr));
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid var(--agent-border);
  padding: 0.55rem 0.65rem;
  font-size: 0.62rem;
}

.ec-agent-upload-table > div:last-child {
  border-bottom: 0;
}

.ec-agent-upload-table .is-head {
  background: #f1f5f9;
  color: #64748b;
  font-size: 0.52rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ec-agent-check {
  width: fit-content;
  border-radius: 9999px;
  padding: 0.18rem 0.42rem;
  font-size: 0.5rem;
  font-weight: 800;
}

.ec-agent-check.is-valid {
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
}

.ec-agent-check.is-error {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
}

.ec-agent-preview-note,
.ec-agent-empty {
  margin-top: 0.7rem;
  color: #64748b;
  font-size: 0.62rem;
}

.ec-agent-history h3 {
  margin-bottom: 0.7rem;
}

.ec-agent-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.7rem;
  border-top: 1px solid var(--agent-border);
  padding: 0.68rem 0;
}

.ec-agent-history-row:first-child {
  border-top: 0;
}

.ec-agent-history-row strong,
.ec-agent-history-row small {
  display: block;
}

.ec-agent-history-row strong {
  font-size: 0.68rem;
}

.ec-agent-history-row small {
  margin-top: 0.16rem;
  color: #64748b;
  font-size: 0.54rem;
}

.ec-agent-history-row b {
  color: #334155;
  font-size: 0.6rem;
}

.ec-agent-status,
.ec-agent-severity {
  border-radius: 9999px;
  padding: 0.22rem 0.48rem;
  font-size: 0.5rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ec-agent-status.is-transmitting,
.ec-agent-status.is-received {
  background: rgba(2, 132, 199, 0.1);
  color: #0369a1;
}

.ec-agent-status.is-verified {
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
}

.ec-agent-status.is-escalated {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
}

.ec-agent-history-row.is-incident {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.ec-agent-severity.is-low {
  background: #f1f5f9;
  color: #475569;
}

.ec-agent-severity.is-medium {
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
}

.ec-agent-severity.is-high,
.ec-agent-severity.is-critical {
  background: rgba(220, 38, 38, 0.1);
  color: #b91c1c;
}

.ec-agent-emergency-note {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 0.7rem;
  background: rgba(220, 38, 38, 0.055);
  padding: 0.65rem 0.75rem;
  color: #7f1d1d;
  font-size: 0.62rem;
}

.ec-agent-emergency-note b {
  margin-left: auto;
  white-space: nowrap;
}

.ec-agent-access-denied {
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: 1rem;
  background: #fff;
  padding: 2rem;
  text-align: center;
}

.ec-agent-access-denied p {
  margin-top: 0.35rem;
  color: #64748b;
  font-size: 0.75rem;
}

html.dark .ec-agent-page {
  --agent-border: rgba(255, 255, 255, 0.1);
  --agent-muted: rgba(255, 255, 255, 0.52);
  color: #f8fafc;
}

html.dark .ec-agent-page-head,
html.dark .ec-agent-scope-card,
html.dark .ec-agent-entry-form,
html.dark .ec-agent-upload-panel,
html.dark .ec-agent-history,
html.dark .ec-agent-tabs,
html.dark .ec-agent-access-denied {
  background: rgba(8, 18, 36, 0.86);
}

html.dark .ec-agent-scope-card strong,
html.dark .ec-agent-form-title h3,
html.dark .ec-agent-history h3,
html.dark .ec-agent-history-row strong,
html.dark .ec-agent-history-row b {
  color: #f8fafc;
}

html.dark .ec-agent-field {
  color: rgba(255, 255, 255, 0.72);
}

html.dark .ec-agent-field input,
html.dark .ec-agent-field select,
html.dark .ec-agent-field textarea {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.24);
  color: #fff;
}

html.dark .ec-agent-field input[readonly],
html.dark .ec-agent-upload-table .is-head {
  background: rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.62);
}

html.dark .ec-agent-field select option {
  background: #0b1728;
}

html.dark .ec-agent-vote-grid,
html.dark .ec-agent-dropzone {
  border-color: rgba(110, 198, 232, 0.2);
  background: rgba(110, 198, 232, 0.045);
}

html.dark .ec-agent-dropzone,
html.dark .ec-agent-btn.is-secondary,
html.dark .ec-agent-template-btn {
  color: rgba(255, 255, 255, 0.72);
}

html.dark .ec-agent-btn.is-secondary,
html.dark .ec-agent-template-btn {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
}

html.dark .ec-agent-confirm {
  color: rgba(255, 255, 255, 0.62);
}

@keyframes ec-agent-pulse {
  50% { opacity: 0.45; }
}

@media (max-width: 900px) {
  .ec-agent-scope-card,
  .ec-agent-vote-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ec-agent-scope-card > div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--agent-border);
  }

  .ec-agent-scope-card > div:nth-child(4) {
    border-top: 1px solid var(--agent-border);
  }
}

@media (max-width: 640px) {
  .ec-agent-page-head {
    align-items: flex-start;
  }

  .ec-agent-live-badge {
    display: none;
  }

  .ec-agent-form-grid,
  .ec-agent-vote-grid,
  .ec-agent-scope-card {
    grid-template-columns: 1fr;
  }

  .ec-agent-scope-card > div + div {
    border-top: 1px solid var(--agent-border);
    border-left: 0;
  }

  .ec-agent-form-title,
  .ec-agent-emergency-note {
    align-items: flex-start;
    flex-direction: column;
  }

  .ec-agent-emergency-note b {
    margin-left: 0;
  }

  .ec-agent-history-row,
  .ec-agent-history-row.is-incident {
    grid-template-columns: 1fr;
  }

  .ec-agent-upload-table {
    overflow-x: auto;
  }

  .ec-agent-upload-table > div {
    min-width: 34rem;
  }
}
