:root {
  --red: #e02424;
  --red-dark: #b91c1c;
  --red-soft: #fdecec;
  --red-line: #f6c9c9;
  --ink: #1f2430;
  --muted: #6b7280;
  --bg: #ffffff;
  --panel: #ffffff;
  --line: #ececf0;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06), 0 8px 24px rgba(17, 24, 39, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--red-dark);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: #f4f4f6;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.85em;
}

/* ---------- App shell + sidebar ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: margin-left 0.25s ease;
  z-index: 30;
}
.app-shell.nav-collapsed .sidebar {
  margin-left: -248px;
}
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.brand:hover {
  text-decoration: none;
}
.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.brand-name {
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
}
.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 500;
}
.side-nav a:hover {
  background: #f6f6f8;
  text-decoration: none;
}
.side-nav a.active {
  background: var(--red-soft);
  color: var(--red-dark);
  font-weight: 600;
}
.sidebar-foot {
  margin-top: auto;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

/* topbar with toggle */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  z-index: 20;
}
.nav-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex: 0 0 auto;
}
.nav-toggle:hover {
  border-color: #d8d8e0;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}
.topbar-brand:hover {
  text-decoration: none;
}
.topbar-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 25;
}

.site-main {
  width: 100%;
  padding: 36px 24px 64px;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 22px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ---------- Hero ---------- */
.hero {
  text-align: center;
  padding: 28px 0 40px;
}
.hero-logo {
  width: 128px;
  height: 128px;
  object-fit: contain;
}
.hero h1 {
  font-size: 2.4rem;
  margin: 18px 0 8px;
  letter-spacing: -0.02em;
}
.hero-tagline {
  max-width: 620px;
  margin: 0 auto 22px;
  color: var(--muted);
  font-size: 1.08rem;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover {
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--red);
  color: #fff;
}
.btn-primary:hover {
  background: var(--red-dark);
}
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover {
  border-color: #d8d8e0;
}
.btn-sm {
  padding: 7px 13px;
  font-size: 0.85rem;
}

/* ---------- Cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin: 28px 0;
}
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}
.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.card-link {
  color: var(--ink);
  display: block;
}
.card-link:hover {
  text-decoration: none;
  border-color: var(--red-line);
}

/* ---------- Sections ---------- */
.how,
.status {
  margin-top: 36px;
}
.how h2,
.status h2 {
  font-size: 1.25rem;
  margin-bottom: 10px;
}
.link-list,
.status-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.link-list li,
.status-list li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}
.muted {
  color: var(--muted);
  font-size: 0.92rem;
}
.ok {
  color: #15803d;
}
.off {
  color: var(--red-dark);
}

/* ---------- Admin ---------- */
.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.admin-head h1 {
  margin: 0;
  font-size: 1.6rem;
}
.admin .cards {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.92rem;
}
.alert-ok {
  background: #ecfdf3;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.alert-error {
  background: var(--red-soft);
  color: var(--red-dark);
  border: 1px solid var(--red-line);
}
.alert-info {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.form {
  margin: 18px 0;
}
.form-inline {
  margin-top: 10px;
}
.field {
  display: block;
  margin-bottom: 16px;
}
.field > span {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.92rem;
}
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: #fff;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}
.code-area {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
}
.form-actions {
  display: flex;
  gap: 10px;
}

.error-list {
  margin: 6px 0 0;
  padding-left: 18px;
}

.model-list {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.model-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: #fff;
}

.model-row-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.radio-label,
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.model-id {
  margin-left: auto;
}

.model-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.model-fields .field {
  margin-bottom: 0;
}

.checkbox-field .checkbox-label {
  min-height: 42px;
}

.auth {
  max-width: 380px;
  margin: 20px auto;
}
.auth h1 {
  text-align: center;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
  font-size: 0.9rem;
}
.table th,
.table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}
.table thead th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.test-result {
  margin-top: 20px;
}
.output {
  background: #faf7f7;
  border: 1px solid var(--red-line);
  border-radius: var(--radius-sm);
  padding: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
}

/* ---------- Pod (iframe-friendly) ---------- */
.pod-body {
  background: #faf7f8;
}
.pod {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px;
}
.pod-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--red);
  margin-bottom: 14px;
}
.pod-logo {
  width: 46px;
  height: 46px;
  object-fit: contain;
}
.pod-headings {
  min-width: 0;
}
.pod-title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--red-dark);
}
.pod-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pod-ticket {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.ticket-row {
  display: flex;
  gap: 10px;
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.ticket-label {
  color: var(--muted);
  min-width: 70px;
}
.ticket-id {
  font-weight: 700;
  color: var(--red-dark);
}
.ticket-summary {
  font-weight: 600;
}

.pod-loading {
  text-align: center;
  padding: 28px 0;
  color: var(--muted);
}
.pod-loading-gif {
  display: block;
  width: 96px;
  height: 96px;
  object-fit: contain;
  margin: 0 auto 12px;
}

.pod-error {
  background: var(--red-soft);
  border: 1px solid var(--red-line);
  color: var(--red-dark);
  padding: 14px;
  border-radius: var(--radius);
  text-align: center;
}
.pod-error p {
  margin: 0 0 10px;
}

.pod-recommendation {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.rec-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.rec-actions {
  display: flex;
  gap: 8px;
}
.rec-badge {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
}
.rec-badge-live {
  background: #ecfdf3;
  color: #15803d;
}
.provider-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 18px;
}
.status-pill {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.status-ok {
  background: #ecfdf3;
  color: #15803d;
}
.status-off {
  background: var(--red-soft);
  color: var(--red-dark);
}
.status-warn {
  background: #fef3c7;
  color: #92400e;
}
.provider-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  margin: 22px 0 8px;
}
.rec-section {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.rec-section:first-child {
  border-top: none;
}
.rec-section h3 {
  margin: 0 0 5px;
  font-size: 0.95rem;
  color: var(--red-dark);
}
.rec-body {
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
  max-width: 80ch;
}

/* --- Pod menu (the two action options shown on load) --------------------- */
.pod-menu {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.menu-title {
  margin: 0 0 12px;
  font-size: 1rem;
  color: var(--ink);
}
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.menu-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.menu-btn:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
}
.menu-btn:disabled,
.menu-btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.78;
}
.menu-btn:disabled:hover,
.menu-btn[aria-disabled="true"]:hover {
  background: var(--red);
  border-color: var(--red);
  transform: none;
}
.menu-btn-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.menu-btn-title {
  font-size: 0.95rem;
  font-weight: 700;
}
.menu-btn-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff;
  color: var(--red-dark);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1;
}
.menu-btn-desc {
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.85;
  white-space: normal;
}

/* --- Resolution-notes result -------------------------------------------- */
.res-banner {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.res-banner-ok {
  background: #ecfdf3;
  color: #15803d;
}
.res-banner-warn {
  background: var(--red-soft);
  color: var(--red-dark);
}
.rec-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.rec-section-head h3 {
  margin: 0 0 5px;
}
.res-list {
  margin: 4px 0 0;
  padding-left: 20px;
  font-size: 0.92rem;
  color: var(--ink);
}
.res-list li {
  margin-bottom: 4px;
  word-break: break-word;
}
.res-why {
  color: var(--muted);
  font-weight: 400;
}
.res-source {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 10px;
}
.res-source-info {
  color: #15803d;
  font-weight: 600;
}
.res-source-warn {
  color: var(--red-dark);
  font-weight: 600;
}
.res-addinfo textarea {
  margin-top: 4px;
}
.res-addinfo-actions {
  margin-top: 10px;
}
.res-inject {
  margin-top: 4px;
}
.res-inject .alert {
  margin-top: 12px;
  margin-bottom: 0;
}
.res-question {
  margin: 0 0 14px;
}
.res-question-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}
.res-question-section {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2, #f1f5f9);
  border-radius: 999px;
  vertical-align: middle;
}
.res-question-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.res-question-input {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.9rem;
  padding: 8px 10px;
  border: 1px solid var(--border, #d4dae3);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
.res-question-input:focus {
  outline: none;
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.res-question-skip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}
.res-question-skip input {
  margin: 0;
}
textarea.res-question-input {
  resize: vertical;
  min-height: 64px;
}
.res-advisory-head {
  margin: 6px 0 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.res-questions-error {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--red-dark);
  margin: 6px 0;
}
.res-advisory {
  background: #f8fafc;
  border-radius: var(--radius);
  padding: 12px;
}
.res-advisory-item {
  display: block;
}
.res-advisory-label {
  margin-top: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}
.res-advisory-detail {
  font-weight: 600;
  color: var(--ink);
}
.res-advisory-reason {
  display: block;
}
.res-advisory-answer {
  margin-top: 10px;
}

@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    margin-left: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow);
  }
  .app-shell:not(.nav-collapsed) .sidebar {
    transform: translateX(0);
  }
  .nav-backdrop {
    display: block;
  }
  .app-shell:not(.nav-collapsed) .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}
@media (max-width: 600px) {
  .hero h1 {
    font-size: 1.9rem;
  }
}

/* --- AI usage & cost dashboard -------------------------------------------- */
.ai-usage .muted.disclaimer {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  border-top: 1px solid #e5e7eb;
  padding-top: 0.75rem;
}

.ai-usage-filters .filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin: 1rem 0 1.25rem;
}
.ai-usage-filters label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
  gap: 0.25rem;
}
.ai-usage-filters input,
.ai-usage-filters select {
  padding: 0.4rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 400;
}

.ai-usage-summary {
  margin-bottom: 1.5rem;
}
.stat-card {
  text-align: left;
}
.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
}
.stat-card .stat-label {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 0.25rem;
}
.stat-card.stat-accent {
  border-color: #6366f1;
  background: #eef2ff;
}
.stat-card.stat-accent .stat-value {
  color: #4338ca;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 1rem;
}
.tabs .tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
}
.tabs .tab:hover {
  color: #0f172a;
}
.tabs .tab.active {
  color: #4338ca;
  border-bottom-color: #4338ca;
}

.tab-panel {
  overflow-x: auto;
}
.tab-panel .rate-input {
  width: 7rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 0.85rem;
}
.ai-pricing-actions {
  margin: 0.5rem 0 1rem;
}
.pricing-history {
  margin-top: 1.25rem;
}
.pricing-history summary {
  cursor: pointer;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.75rem;
}

/* --- Resolution diagnostics ------------------------------------------------ */
.diagnostics-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.diagnostics-settings label {
  display: flex;
  flex-direction: column;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  gap: 0.25rem;
}
.diagnostics-settings .checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.diagnostics-settings input[type="checkbox"] {
  width: auto;
}
.diagnostics-settings input[type="number"] {
  width: 9rem;
}
.diagnostics-list,
.diagnostics-detail {
  min-width: 0;
}
.diagnostics-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.diagnostics-section-head h2 {
  margin-bottom: 0.25rem;
}
.diagnostics-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}
.diagnostics-table {
  margin-bottom: 0;
  min-width: 980px;
}
.diagnostics-table tbody tr {
  cursor: pointer;
}
.diagnostics-table tbody tr:hover,
.diagnostics-table tbody tr.selected {
  background: #f8fafc;
}
.diagnostics-detail {
  margin-top: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 1rem;
}
.diagnostics-detail h2,
.diagnostics-detail h3 {
  margin-top: 0;
}
.diagnostics-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.85rem;
}
.diagnostics-detail-head p {
  margin: 0.25rem 0 0;
}
.diagnostics-tabs {
  margin-bottom: 1rem;
}
.diagnostics-tab-panel {
  overflow: visible;
}
.diagnostics-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}
.diagnostics-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  background: #fff;
}
.diagnostics-card h3 {
  margin-bottom: 0.75rem;
}
.diagnostics-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.diagnostics-card-head h3 {
  margin-bottom: 0;
}
.compact-table th {
  width: 13rem;
  color: #475569;
  vertical-align: top;
}
.compact-table td {
  word-break: break-word;
}
.diagnostics-pre {
  max-height: 62vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 0.85rem;
  font-size: 0.8rem;
  line-height: 1.45;
  margin: 0;
}
.diagnostics-pre-card + .diagnostics-pre-card {
  margin-top: 1rem;
}
.diagnostics-question-list {
  margin: 0;
  padding-left: 1.2rem;
}
.diagnostics-question-list li + li {
  margin-top: 0.5rem;
}
@media (max-width: 720px) {
  .diagnostics-detail-head {
    align-items: stretch;
    flex-direction: column;
  }
  .diagnostics-detail-head .btn {
    align-self: flex-start;
  }
  .diagnostics-summary-grid {
    grid-template-columns: 1fr;
  }
  .compact-table th {
    width: 9rem;
  }
}

/* ---------- N-central device enrichment ---------- */
.ncentral-panel,
.ncentral-select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fafafb;
}
.ncentral-device-select {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--bg);
}
.ncentral-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.ncentral-fields {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
}
.ncentral-fields dt {
  color: var(--muted);
  font-weight: 600;
}
.ncentral-fields dd {
  margin: 0;
  color: var(--ink);
  word-break: break-word;
}
.ncentral-change {
  margin-top: 0.6rem;
}
@media (max-width: 720px) {
  .ncentral-fields {
    grid-template-columns: 1fr;
    gap: 0.1rem 0;
  }
  .ncentral-fields dd {
    margin-bottom: 0.4rem;
  }
}

/* ---------- Ticket Quality & Closure ---------- */
.zq-status { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: -4px 0 14px; }
.zq-enf { display: inline-flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 700; padding: 6px 12px; border-radius: 999px; border: 1px solid; }
.zq-enf-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.zq-enf-on { background: var(--red); color: #fff; border-color: var(--red-dark); }
.zq-enf-off { background: #fff; color: var(--red-dark); border-color: var(--red-line); }
.zq-enf-off .zq-enf-dot { background: transparent; box-shadow: inset 0 0 0 2px currentColor; }
.zq-enf-unknown { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.zq-enf-stale { font-weight: 500; }
.zq-switch { position: relative; display: inline-flex; align-items: center; gap: 10px; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.zq-switch input { position: absolute; opacity: 0; width: 42px; height: 24px; margin: 0; cursor: pointer; }
.zq-switch-track { width: 42px; height: 24px; border-radius: 999px; background: #d9d9e0; position: relative; transition: background 0.15s ease; flex: 0 0 auto; pointer-events: none; }
.zq-switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform 0.15s ease; }
.zq-switch input:checked + .zq-switch-track { background: var(--red); }
.zq-switch input:checked + .zq-switch-track::after { transform: translateX(18px); }
.zq-switch input:focus-visible + .zq-switch-track { box-shadow: 0 0 0 3px var(--red-soft), 0 0 0 4px var(--red); }
.zq-switch input:disabled ~ * { opacity: 0.55; cursor: not-allowed; }

.pod-quality { display: block; }
.zq-tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin-bottom: 12px; }
.zq-tabs-spacer { flex: 1; }
.zq-tab { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -2px; padding: 8px 12px; font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.zq-tab:hover { color: var(--ink); }
.zq-tab.active { color: var(--red-dark); border-bottom-color: var(--red); }
.zq-tab:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.zq-body { display: flex; flex-direction: column; gap: 12px; }
.zq-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.zq-card-title { margin: 0 0 10px; font-size: 0.95rem; color: var(--red-dark); }
.zq-card h4 { margin: 0; font-size: 0.9rem; }
.zq-small { font-size: 0.8rem; }
.zq-meta { display: grid; grid-template-columns: max-content 1fr max-content 1fr; gap: 4px 12px; margin: 0; font-size: 0.86rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.zq-meta dt { color: var(--muted); }
.zq-meta dd { margin: 0; font-weight: 600; word-break: break-word; }
.zq-card .zq-meta { border: 0; padding: 0; }
.zq-setup, .zq-blockers { background: var(--red-soft); border: 1px solid var(--red-line); border-left: 4px solid var(--red); color: var(--red-dark); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.86rem; margin-bottom: 10px; }
.zq-setup ul, .zq-blockers ul { margin: 4px 0 0; padding-left: 18px; }
.zq-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.zq-choices-sub { margin-top: 8px; padding-left: 12px; border-left: 2px solid var(--red-line); }
.zq-choice { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 600; cursor: pointer; background: #fff; }
.zq-choice.selected { border-color: var(--red); background: var(--red-soft); color: var(--red-dark); }
.zq-choice input { accent-color: var(--red); margin: 0; }
.zq-confirm, .zq-ack { margin-top: 12px; align-items: flex-start; font-weight: 500; line-height: 1.4; }
.zq-ack input, .zq-confirm input { accent-color: var(--red); margin-top: 3px; }
.zq-hash { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.zq-actions { flex-wrap: wrap; margin-top: 12px; align-items: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary:disabled:hover { background: var(--red); }
.zq-state { font-size: 0.86rem; font-weight: 600; padding: 8px 12px; border-radius: var(--radius-sm); margin: 0 0 10px; }
.zq-state-pending { background: #fef3c7; color: #92400e; }
.zq-state-error { background: var(--red-soft); color: var(--red-dark); }
.zq-score-row { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 4px 14px; align-items: center; margin-bottom: 12px; }
.zq-score { grid-row: 1 / span 2; display: flex; align-items: baseline; color: var(--red-dark); }
.zq-score.full { color: #15803d; }
.zq-score-num { font-size: 2.6rem; font-weight: 800; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.zq-score-den { font-size: 1rem; font-weight: 700; color: var(--muted); margin-left: 2px; }
.zq-score-meter { height: 8px; border-radius: 999px; background: var(--red-soft); overflow: hidden; }
.zq-score-meter span { display: block; height: 100%; background: var(--red); transform-origin: left; transition: transform 0.4s ease; }
.zq-score.full + .zq-score-meter span { background: #15803d; }
.zq-score-label { font-size: 0.85rem; font-weight: 600; }
.zq-sections { list-style: none; margin: 0; padding: 0; counter-reset: zq; }
.zq-section { padding: 10px 0 10px 12px; border-top: 1px solid var(--line); border-left: 3px solid #15803d; margin-bottom: 2px; }
.zq-section.fail { border-left-color: var(--red); background: linear-gradient(90deg, var(--red-soft), transparent 60%); }
.zq-section-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.9rem; }
.zq-mark { font-weight: 800; width: 1.1em; text-align: center; }
.pass .zq-mark { color: #15803d; }
.fail .zq-mark { color: var(--red); }
.zq-points { margin-left: auto; font-size: 0.78rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.zq-section .rec-body { margin-top: 4px; }
.zq-why { margin: 6px 0 0; font-size: 0.85rem; color: var(--red-dark); }
.zq-section-questions { margin-top: 12px; padding-right: 10px; }
.zq-section-questions .res-question:last-child { margin-bottom: 0; }
.zq-answer-tools { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.zq-additional summary { cursor: pointer; font-weight: 600; font-size: 0.86rem; }
.zq-additional[open] summary { margin-bottom: 10px; }
.zq-sections.compact .zq-section { padding: 6px 0 6px 10px; }
.zq-limits { margin-top: 12px; font-size: 0.86rem; background: #fafafb; border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.zq-draft { margin-top: 14px; }
.zq-draft-body { white-space: pre-wrap; word-break: break-word; background: #faf7f7; border: 1px solid var(--red-line); border-radius: var(--radius-sm); padding: 12px; font-family: inherit; font-size: 0.88rem; max-height: 420px; overflow: auto; margin: 8px 0 0; }
.zq-prior { margin-top: 10px; font-size: 0.86rem; }
.zq-prior summary { cursor: pointer; font-weight: 600; color: var(--red-dark); }
.zq-prior-list { list-style: none; padding: 0; margin: 8px 0 0; }
.zq-prior-list li { padding: 8px 0; border-top: 1px dashed var(--line); }
.zq-prior-q { font-weight: 600; }
.zq-field { margin-bottom: 0; }
.zq-warn { font-size: 0.86rem; color: #92400e; background: #fef3c7; border-radius: var(--radius-sm); padding: 8px 12px; margin: 10px 0 0; }
.zq-closure { border-color: var(--red-line); border-top: 3px solid var(--red); }
.zq-closure textarea { margin-top: 10px; }
.zq-op { border-left: 4px solid var(--red); }
.zq-empty { text-align: center; padding: 28px 16px; background: #fff; border: 1px dashed var(--red-line); border-radius: var(--radius); }
.zq-empty p { margin: 6px 0 0; }
.zq-skeleton { display: flex; flex-direction: column; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.zq-skeleton span { height: 12px; border-radius: 6px; background: linear-gradient(90deg, #f3eded 25%, #fbf6f6 50%, #f3eded 75%); background-size: 200% 100%; animation: zq-shimmer 1.2s linear infinite; }
.zq-skeleton span.short { width: 55%; }
@keyframes zq-shimmer { to { background-position: -200% 0; } }
.zq-target { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.zq-target-num { font-size: 0.95rem; margin-bottom: 8px; }
.zq-target-num strong { font-size: 1.8rem; color: var(--red-dark); font-variant-numeric: tabular-nums; }
.zq-counts { display: grid; grid-template-columns: repeat(4, auto); gap: 2px 14px; margin: 12px 0 0; font-size: 0.82rem; }
.zq-counts dt { color: var(--muted); grid-row: 1; }
.zq-counts dd { margin: 0; grid-row: 2; font-weight: 700; font-size: 1.05rem; }
.zq-caption { text-align: left; font-weight: 600; padding: 6px 0; }
.zq-records { min-width: 640px; margin: 0; }
.zq-filters { display: flex; gap: 10px; }
@media (prefers-reduced-motion: reduce) { .zq-skeleton span, .zq-score-meter span, .zq-switch-track::after { animation: none; transition: none; } }
@media (max-width: 560px) {
  .pod { padding: 12px; }
  .zq-meta { grid-template-columns: max-content 1fr; }
  .zq-counts { grid-template-columns: repeat(2, auto); }
  .zq-counts dt, .zq-counts dd { grid-row: auto; }
  .zq-points { margin-left: 0; width: 100%; }
}

/* Admin quality */
.zqa-status-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 16px; background: var(--red-soft); border: 1px solid var(--red-line); border-radius: var(--radius); margin-bottom: 18px; }
.zqa [hidden] { display: none !important; }
.zqa-status-bar .zq-status { margin: 0; }
.zqa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.zqa-wide { grid-column: 1 / -1; }
.zqa-card h2 { margin: 0 0 4px; font-size: 1.05rem; }
.zqa-card > .muted { margin-bottom: 12px; }
.zqa-mapping { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow: auto; }
.zqa-map-row { display: grid; grid-template-columns: 1fr 180px; gap: 10px; align-items: center; font-size: 0.9rem; }
.zqa-members { display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow: auto; margin-top: 10px; }
.zqa-member { font-weight: 500; }
.zqa-rubrics { display: grid; gap: 8px; }
.zqa-rubric { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.zqa-rubric summary { cursor: pointer; font-weight: 700; color: var(--red-dark); }
.zqa-rubric-list { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 10px; }
.zqa-rubric-list textarea { margin-top: 6px; }
.zqa-checks { display: grid; gap: 8px; margin-bottom: 14px; }
.zqa-checks .checkbox-label { font-weight: 500; }
.zqa-checks input, .zqa-member input { accent-color: var(--red); width: auto; }
.zqa-sub { font-size: 0.95rem; margin: 18px 0 4px; }
.zqa-inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.zqa-inline input { max-width: 220px; }
.zqa-section { margin-top: 32px; }
@media (max-width: 600px) { .zqa-map-row { grid-template-columns: 1fr; } }
.zq-state-ok { background: #ecfdf3; color: #15803d; }
.zq-op textarea { margin-top: 4px; }

/* --- One-click quality assessment ------------------------------------ */
.zq-sources { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 8px 12px; margin-bottom: 12px; border-left: 3px solid var(--red); background: #fbf7f6; border-radius: var(--radius-sm); font-size: 0.84rem; }
.zq-sources.incomplete { border-left-color: #b45309; background: #fff7ea; }
.zq-sources-label { font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.72rem; color: var(--red-dark, var(--red)); }
.zq-sources-count { font-weight: 600; }
.zq-sources-ids { color: #6b5b5b; font-variant-numeric: tabular-nums; word-break: break-word; }
.zq-clarify { border-color: var(--red); }
.zq-clarify .zq-choices { margin: 10px 0 4px; }
.zq-answer-actions { margin-top: 10px; }
.zq-result .zq-score-row { margin-top: 2px; }
@media (max-width: 480px) {
  .zq-meta { grid-template-columns: max-content 1fr; }
  .zq-choices { flex-direction: column; }
  .zq-choice { width: 100%; }
  .zq-actions .btn { width: 100%; justify-content: center; }
  .zq-score-row { flex-wrap: wrap; }
  .zq-tabs { flex-wrap: wrap; }
}
.zq-limits-alert { border: 1px solid #e7b9a8; background: #fff4ef; border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 10px; }
