@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Backgrounds */
  --bg-main: #F4F6FB;
  --bg-secondary: #EEF2F6;
  
  /* Typography */
  --text-main: #334155;
  --text-muted: #64748B;
  
  /* Core Gradients */
  --grad-mint: linear-gradient(135deg, #10B981, #34D399);
  --grad-blue: linear-gradient(135deg, #0284C7, #38BDF8);
  --grad-violet: linear-gradient(135deg, #8B5CF6, #C084FC);
  --grad-orange: linear-gradient(135deg, #F97316, #FDBA74);
  --grad-red: linear-gradient(135deg, #EF4444, #F87171);
  
  /* Shadows */
  --shadow-soft: 0 16px 32px rgba(18, 38, 63, 0.06);
  --shadow-inner: inset 0 2px 4px rgba(255, 255, 255, 0.8), inset 0 -2px 4px rgba(18, 38, 63, 0.05);
  
  /* Border Radiuses */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg-main);
}

body {
  margin: 0;
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 400;
}

h1, h2, h3, h4, p {
  margin: 0;
}

h1 {
  font-size: 19px;
  font-weight: 700;
}

h2 {
  font-size: 13px;
  font-weight: 700;
}

p {
  color: var(--text-muted);
}

.gradient-text-blue {
  background: var(--grad-blue);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 212px;
  max-height: 100vh;
  padding: 12px 10px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border-right: 1px solid rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px 12px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.1);
}

.brand-logo {
  display: block;
  width: 96px;
  max-width: 100%;
  height: auto;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: flex-start;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-btn {
  width: 100%;
  min-height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

nav > .nav-btn {
  margin-bottom: 6px;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-main);
  transform: translateX(4px);
}

.nav-btn.active {
  background: var(--grad-blue);
  color: #ffffff;
  box-shadow: var(--shadow-soft);
}

.nav-group {
  display: grid;
  gap: 2px;
  align-content: start;
}

.nav-group summary {
  min-height: 26px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  list-style: none;
  position: relative;
  text-transform: uppercase;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group summary::after {
  content: '';
  width: 6px;
  height: 6px;
  position: absolute;
  right: 11px;
  top: 9px;
  border-right: 1.5px solid rgba(100, 116, 139, 0.68);
  border-bottom: 1.5px solid rgba(100, 116, 139, 0.68);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.nav-group summary::before {
  content: '';
  width: 6px;
  height: 6px;
  position: absolute;
  right: 11px;
  top: 5px;
  border-right: 1.5px solid rgba(100, 116, 139, 0.68);
  border-bottom: 1.5px solid rgba(100, 116, 139, 0.68);
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.nav-group[open] summary::before,
.nav-group[open] summary::after {
  transform: rotate(225deg);
}

.nav-group[open] summary::before {
  top: 10px;
}

.nav-group[open] summary::after {
  top: 6px;
}

.nav-group summary:hover {
  background: rgba(255, 255, 255, 0.5);
}

.nav-group-items {
  display: grid;
  gap: 2px;
  padding: 2px 0 4px 8px;
}

.nav-btn.child {
  min-height: 28px;
  padding-left: 10px;
}

.session-bar {
  margin: 0 4px;
  padding-top: 14px;
  border-top: 1px solid rgba(18, 38, 63, 0.1);
  display: grid;
  gap: 8px;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.session-bar a {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
}

.shell {
  min-height: 100vh;
  margin-left: 212px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 18px;
  background: rgba(244, 246, 251, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

#view-subtitle {
  margin-top: 3px;
  font-size: 11px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Glass Cards mapped to metrics and panels */
.metric, .panel {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft), var(--shadow-inner);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
  opacity: 0;
  animation: slideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.metric:hover, .panel:hover {
  transform: translateY(-5px) scale(1.005);
  box-shadow: 0 24px 48px rgba(18, 38, 63, 0.1), var(--shadow-inner);
}

.metric {
  padding: 12px;
  min-height: 78px;
}

.metric strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text-main);
  font-size: 20px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.metric span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.route-path-originator {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

@media (max-width: 900px) {
  .route-path-originator {
    grid-template-columns: 1fr;
  }
}

.panel {
  overflow: hidden;
}

.panel-head {
  min-height: 38px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(18, 38, 63, 0.05);
  background: rgba(255, 255, 255, 0.4);
}

.bind-tabs {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  padding-top: 4px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.08);
}

.bind-tabs button {
  border-radius: 10px 10px 0 0;
  box-shadow: none;
}

.bind-tabs button.active {
  background: var(--grad-blue);
  color: #fff;
}

.bind-tab-panel {
  display: none;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 4px 0;
}

.bind-tab-panel.active {
  display: grid;
}

.form-hint {
  grid-column: 1 / -1;
  font-size: 12px;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 4px;
}

.bind-status {
  grid-column: 1 / -1;
  min-height: 18px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.bind-status.ok {
  color: #047857;
}

.bind-status.fail {
  color: #dc2626;
}

.bind-status.pending {
  color: #0f766e;
}

button {
  border: 0;
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  background: #ffffff;
  border: 1px solid rgba(18, 38, 63, 0.1);
  color: var(--text-main);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(18, 38, 63, 0.1);
}

button::after {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: all 0.5s ease;
}

button:hover::after {
  left: 150%;
}

button.primary {
  background: var(--grad-blue);
  color: #ffffff;
  border: none;
}

button.link-btn {
  min-height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: #0284C7;
  box-shadow: none;
}

button.link-btn:hover {
  transform: translateY(-1px);
}

.form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 9px;
  padding: 11px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.05);
  align-items: end;
}

.form label,
.form .field {
  display: grid;
  gap: 5px;
}

.form label span,
.form .field > span {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  min-height: 30px;
  border: 1px solid rgba(18, 38, 63, 0.1);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  font: inherit;
  transition: all 0.2s ease;
}

.date-shell {
  position: relative;
}

.date-shell input[data-date-text] {
  padding-right: 40px;
}

.date-picker-trigger {
  position: absolute;
  inset: 0 0 0 auto;
  z-index: 2;
  width: 36px;
  min-height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: transparent;
  box-shadow: none;
}

.date-picker-trigger:hover {
  transform: none;
  box-shadow: none;
}

.date-picker-trigger::after {
  display: none;
}

.date-shell::after {
  content: "";
  position: absolute;
  right: 11px;
  top: 50%;
  z-index: 1;
  width: 13px;
  height: 13px;
  pointer-events: none;
  transform: translateY(-50%);
  border: 2px solid #111827;
  border-radius: 2px;
  box-sizing: border-box;
  background:
    linear-gradient(#111827, #111827) 2px 3px / 7px 1px no-repeat,
    linear-gradient(#111827, #111827) 2px -2px / 2px 5px no-repeat,
    linear-gradient(#111827, #111827) 8px -2px / 2px 5px no-repeat;
}

.native-date-picker {
  position: absolute;
  inset: 0 0 0 auto;
  width: 36px;
  min-height: 100%;
  padding: 0;
  border: 0;
  opacity: 0.01;
  pointer-events: none;
}

.panel:has(.date-shell) {
  overflow: visible;
}

textarea {
  min-height: 132px;
  grid-column: 1 / -1;
  resize: vertical;
}

.csv-text-field {
  align-self: end;
}

.csv-text-field textarea {
  min-height: 66px;
  max-height: 92px;
  overflow-y: auto;
  resize: vertical;
  line-height: 1.2;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.pill, .status-dot {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  padding: 0.25rem 0.75rem;
  font-size: 12px;
  font-weight: 600;
}

.pill.active, .pill.delivered, .pill.completed, .pill.approved, .pill.ok, .pill.settled, .pill.posted, .status-dot:not(.error) {
  background: rgba(16, 185, 129, 0.1);
  color: #10B981;
}

.pill.scheduled, .pill.pending, .pill.received, .pill.open {
  background: rgba(249, 115, 22, 0.1);
  color: #F97316;
}

.pill.archived, .pill.void, .pill.disabled {
  background: rgba(100, 116, 139, 0.1);
  color: var(--text-muted);
}

.pill.failed, .pill.rejected, .pill.dead, .pill.mismatch, .status-dot.error {
  background: rgba(239, 68, 68, 0.1);
  color: #EF4444;
}

.pill.processing, .pill.retrying, .pill.provider_credit {
  background: rgba(139, 92, 246, 0.1);
  color: #8B5CF6;
}

.pill.attention {
  background: rgba(249, 115, 22, 0.1);
  color: #F97316;
}

.pill.ignored {
  background: rgba(100, 116, 139, 0.1);
  color: var(--text-muted);
}

.alerts, .content {
  width: min(100%, 1560px);
  margin: 0 auto;
  padding: 14px 18px;
}

.alerts {
  padding-bottom: 0;
}

.alerts:empty {
  display: none;
}

.content {
  display: grid;
  gap: 0.9rem;
}

.agent-preview-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid rgba(2, 132, 199, 0.16);
  border-radius: var(--radius-md);
  background: rgba(2, 132, 199, 0.06);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.agent-preview-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #38BDF8;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.14);
}

.agents-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: stretch;
}

.agent-card,
.agent-hero {
  position: relative;
}

.agent-card:hover {
  transform: none;
}

.agent-card::before,
.agent-hero::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: var(--agent-accent);
}

.agent-tone-blue {
  --agent-accent: #0284C7;
  --agent-soft: rgba(2, 132, 199, 0.1);
}

.agent-tone-red {
  --agent-accent: #EF4444;
  --agent-soft: rgba(239, 68, 68, 0.1);
}

.agent-tone-orange {
  --agent-accent: #F97316;
  --agent-soft: rgba(249, 115, 22, 0.1);
}

.agent-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.agent-card .panel-head {
  gap: 12px;
  align-items: flex-start;
}

.agent-card .panel-head .pill {
  flex: 0 0 auto;
  margin-top: 4px;
}

.agent-identity,
.agent-hero-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.agent-identity > div,
.agent-hero-main > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.agent-card-kicker {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.agent-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border-radius: 11px;
  background: var(--agent-soft);
  color: var(--agent-accent);
  font-size: 11px;
  font-weight: 800;
}

.agent-avatar.large {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 14px;
}

.agent-card-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  flex: 1;
}

.agent-description {
  min-height: 0;
  padding: 0;
  border: 0;
  font-size: 12px;
  line-height: 1.5;
}

.agent-card-activity {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  border: 1px solid rgba(18, 38, 63, 0.06);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.45);
  overflow: hidden;
}

.agent-card-activity-list {
  height: 280px;
  min-height: 280px;
  overflow-x: hidden;
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-color: rgba(100, 116, 139, 0.45) rgba(238, 242, 246, 0.8);
  scrollbar-width: thin;
}

.agent-card-activity-list::-webkit-scrollbar {
  width: 8px;
}

.agent-card-activity-list::-webkit-scrollbar-track {
  background: rgba(238, 242, 246, 0.8);
}

.agent-card-activity-list::-webkit-scrollbar-thumb {
  border-radius: var(--radius-pill);
  background: rgba(100, 116, 139, 0.45);
}

.agent-card-activity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.05);
  background: rgba(255, 255, 255, 0.4);
}

.agent-card-activity-head h3 {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.agent-card-activity-head span,
.agent-card-activity .empty-state {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.agent-card-activity .empty-state {
  padding: 16px 12px;
}

.agent-card-foot {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px;
  border-top: 1px solid rgba(18, 38, 63, 0.05);
  background: rgba(255, 255, 255, 0.4);
}

.agent-action-list {
  display: grid;
}

.agent-action {
  min-width: 0;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 8px 12px;
  align-items: start;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.05);
}

.agent-action:last-child {
  border-bottom: 0;
}

.agent-action-marker {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  border-radius: 50%;
  background: #64748B;
}

.agent-action-marker.completed {
  background: #10B981;
}

.agent-action-marker.pending {
  background: #8B5CF6;
}

.agent-action-marker.attention {
  background: #F97316;
}

.agent-action-marker.ignored,
.agent-action-marker.archived {
  background: #94A3B8;
}

.agent-action-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.agent-action-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.agent-action-title strong {
  flex: 1 1 160px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.agent-action-copy p {
  font-size: 12px;
  line-height: 1.5;
}

.agent-action.compact p {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-action.compact .agent-action-meta {
  display: flex;
  flex-wrap: wrap;
  grid-template-columns: none;
}

.agent-action.compact .agent-action-meta-item {
  min-width: 96px;
}

.agent-action-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 8px;
}

.agent-action-meta-item {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgba(238, 242, 246, 0.72);
}

.agent-action-meta-item span {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.agent-action-meta-item strong {
  font-size: 12px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.agent-action time {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  white-space: normal;
}

.agent-page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.agent-hero {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.agent-hero-main {
  min-width: 260px;
  flex: 1 1 520px;
  max-width: 680px;
}

.agent-hero-main h2 {
  font-size: 17px;
}

.agent-stats {
  width: min(100%, 320px);
  flex: 0 1 320px;
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 8px;
}

.agent-stats > div {
  min-width: 90px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.58);
}

.agent-stats strong,
.agent-stats span {
  display: block;
}

.agent-stats strong {
  margin-bottom: 3px;
  font-size: 16px;
}

.agent-stats span,
.agent-history-count {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.agent-workflow {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 0;
  padding: 14px;
}

.agent-workflow-step {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-workflow-step:not(:last-child)::after {
  content: "";
  height: 1px;
  flex: 1;
  margin-right: 8px;
  background: rgba(18, 38, 63, 0.14);
}

.agent-workflow-step span {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
}

.agent-workflow-step strong {
  font-size: 10px;
}

.agent-action-list.detailed .agent-action {
  padding: 12px 14px;
}

.agent-action-list.detailed .agent-action-meta {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.billing-agent-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: stretch;
}

.noc-agent-live {
  min-width: 0;
  display: grid;
  gap: 0.9rem;
  align-content: start;
}

.billing-agent-settings {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.9rem;
  align-content: start;
}

.billing-agent-disclosure {
  overflow: hidden;
}

.billing-agent-disclosure > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.billing-agent-disclosure > summary::-webkit-details-marker {
  display: none;
}

.billing-agent-disclosure > summary::after {
  content: "⌄";
  margin-left: 2px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.billing-agent-disclosure[open] > summary::after {
  transform: rotate(180deg);
}

.billing-agent-disclosure > summary .configuration-state {
  margin-left: auto;
}

.billing-agent-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.billing-agent-hint {
  padding: 0 11px 10px;
}

.configuration-state {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.agent-test-row,
.agent-settings-actions,
.agent-enable,
.agent-policy {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-test-row {
  justify-content: space-between;
  padding: 10px 11px;
}

.agent-test-row span,
.agent-settings-actions span,
.agent-enable small,
.agent-policy span {
  color: var(--text-muted);
  font-size: 11px;
}

.agent-enable {
  margin: 11px;
  padding: 11px;
  border: 1px solid rgba(18, 38, 63, 0.08);
  border-radius: var(--radius-sm);
  background: rgba(238, 242, 246, 0.5);
}

.agent-enable input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--agent-accent, #EF4444);
}

.agent-enable > span {
  display: grid;
  gap: 2px;
}

.agent-policy {
  align-items: flex-start;
  margin: 0 11px 11px;
  padding: 10px;
  border-left: 3px solid #EF4444;
  background: rgba(239, 68, 68, 0.05);
}

.agent-policy strong {
  flex: 0 0 auto;
  font-size: 11px;
}

.agent-settings-actions {
  justify-content: flex-end;
  padding: 2px 0;
}

.billing-agent-history {
  min-height: 0;
  max-height: 760px;
  overflow-y: auto;
}

.billing-agent-live-panel {
  min-width: 0;
  min-height: 680px;
  display: flex;
  flex-direction: column;
}

.billing-agent-live-panel .billing-agent-history {
  flex: 1 1 auto;
}

.billing-agent-live-panel .agent-action-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.compact-grid {
  margin-bottom: 12px;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: start;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 0.9rem;
  align-items: start;
}

.chart-body {
  padding: 12px 14px 14px;
}

.chart-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.chart-summary strong {
  color: var(--text-main);
  font-size: 18px;
  line-height: 1;
}

.chart-summary span,
.empty-state {
  color: var(--text-muted);
  font-size: 12px;
}

.chart-plot {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.chart-y-axis {
  height: 146px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding-top: 10px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}

.chart-area {
  position: relative;
  height: 146px;
}

.chart-frame {
  min-width: 0;
  direction: ltr;
}

.chart-grid {
  position: absolute;
  inset: 10px 0 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.chart-grid span {
  display: block;
  border-top: 1px solid rgba(18, 38, 63, 0.08);
}

.minute-chart {
  position: absolute;
  inset: 10px 0 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(2px, 1fr);
  direction: ltr;
  align-items: flex-end;
  gap: 2px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.16);
}

.minute-bar {
  min-width: 2px;
  border-radius: 2px 2px 0 0;
  background: #0284C7;
  opacity: 0.78;
}

.minute-bar:hover {
  opacity: 1;
}

.chart-x-axis {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}

.empty-state {
  padding: 10px 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 38, 63, 0.28);
  backdrop-filter: blur(8px);
}

.modal-panel {
  width: min(980px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-lg);
  box-shadow: 0 28px 70px rgba(18, 38, 63, 0.22), var(--shadow-inner);
}

.modal-head {
  min-height: 46px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.08);
}

.modal-head h2 {
  margin: 0;
  color: var(--text-main);
  font-size: 16px;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-body {
  padding: 12px 14px;
  overflow: auto;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid rgba(18, 38, 63, 0.08);
}

.icon-button {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  box-shadow: none;
  color: var(--text-muted);
  font-size: 14px;
}

.recent-stack {
  display: grid;
  gap: 0.9rem;
}

.recent-block {
  overflow: hidden;
}

.recent-summary {
  min-height: 38px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(18, 38, 63, 0.05);
  background: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.recent-summary::-webkit-details-marker {
  display: none;
}

.recent-summary strong {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

.recent-row-positive td {
  background: rgba(16, 185, 129, 0.1);
}

.recent-row-negative td {
  background: rgba(239, 68, 68, 0.1);
}

.recent-row-neutral td {
  background: rgba(255, 255, 255, 0.5);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

th, td {
  max-width: 220px;
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(18, 38, 63, 0.05);
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

td {
  color: var(--text-main);
  white-space: nowrap;
}

td.names-cell {
  white-space: normal;
  vertical-align: top;
}

.name-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  line-height: 1.35;
}

.name-stack span {
  display: block;
  overflow-wrap: anywhere;
}

tbody tr {
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.5);
}

tbody tr.selected-row {
  background: rgba(47, 128, 237, 0.12);
}

.inline-input {
  width: 100%;
  min-width: 5rem;
  box-sizing: border-box;
  border: 1px solid rgba(18, 38, 63, 0.16);
  border-radius: 8px;
  padding: 6px 8px;
  font: inherit;
  background: #fff;
}

.inline-input-num {
  width: 5.5rem;
  min-width: 5.5rem;
}

td.row-actions {
  white-space: nowrap;
}

td.row-actions button {
  margin-right: 6px;
}

tbody tr.total-row {
  background: rgba(18, 38, 63, 0.06);
  font-weight: 700;
}

tbody tr.company-total-row {
  background: rgba(16, 185, 129, 0.12);
  font-weight: 800;
}

tbody tr.grand-total-row {
  background: rgba(2, 132, 199, 0.16);
  font-weight: 900;
}

tbody tr.company-gap-row td {
  height: 14px;
  padding: 0;
  border-bottom: 0;
  background: transparent;
}

.alert {
  padding: 12px 14px;
  background: rgba(249, 115, 22, 0.1);
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: var(--radius-sm);
  color: #F97316;
  font-weight: 600;
}

.alert.success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.28);
  color: #047857;
}

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

.metric:nth-child(1) { animation-delay: 0.05s; }
.metric:nth-child(2) { animation-delay: 0.1s; }
.metric:nth-child(3) { animation-delay: 0.15s; }
.metric:nth-child(4) { animation-delay: 0.2s; }

.panel:nth-child(1) { animation-delay: 0.1s; }
.panel:nth-child(2) { animation-delay: 0.2s; }
.panel:nth-child(3) { animation-delay: 0.3s; }

@media (max-width: 1120px) {
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    min-height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.9);
  }

  .brand {
    flex: 0 0 auto;
    padding-bottom: 0;
    border-bottom: 0;
  }

  nav {
    display: flex;
    flex: 1 0 auto;
    overflow: visible;
    padding-right: 0;
  }

  .nav-btn {
    width: auto;
    white-space: nowrap;
  }

  .nav-group {
    flex: 0 0 auto;
    min-width: 150px;
  }

  .nav-group-items {
    padding-left: 0;
  }

  .shell {
    margin-left: 0;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .agents-grid {
    grid-template-columns: 1fr;
  }

  .billing-agent-layout {
    grid-template-columns: 1fr;
  }

  .billing-agent-live-panel {
    min-height: 520px;
  }

  .agent-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-workflow {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .agent-workflow-step:not(:last-child)::after {
    display: none;
  }
}

@media (max-width: 680px) {
  body {
    font-size: 13px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .alerts,
  .content {
    padding-left: 12px;
    padding-right: 12px;
  }

  .grid,
  .two-col,
  .split-grid,
  .form,
  .bind-tab-panel {
    grid-template-columns: 1fr;
  }

  .agent-stats {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .agent-action {
    grid-template-columns: 10px minmax(0, 1fr);
  }

  .agent-action-list.detailed .agent-action-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .billing-agent-form {
    grid-template-columns: 1fr;
  }

  .agent-test-row,
  .agent-settings-actions,
  .agent-policy {
    align-items: flex-start;
    flex-direction: column;
  }

th,
td {
  padding: 9px 10px;
}
}
