:root {
  --bg: #0b1016;
  --surface: #121923;
  --surface-alt: #172130;
  --border: #253347;
  --text: #e6edf5;
  --muted: #93a4b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

.app-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px 20px 48px;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

.muted {
  color: var(--muted);
  margin: 4px 0 0;
}

.mt-12 {
  margin-top: 12px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
}

.hero-copy, .panel, .subcard, .kpi-card {
  min-width: 0;
  max-width: 100%;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.brand-group > div {
  min-width: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #2563eb, #0d9488);
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
}

.brand-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.brand-title-row h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.status-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.status-pill, .tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
}

.data-table .tag, .data-table td .btn, .data-table th {
  white-space: nowrap;
}

.data-table td.mono {
  overflow-wrap: break-word;
  word-break: normal;
}

.tag-accent { border-color: #1d4ed8; background: rgba(37, 99, 235, 0.16); color: #93c5fd; }
.tag-ok, .pill-ok { border-color: rgba(16, 185, 129, 0.45); background: rgba(16, 185, 129, 0.14); color: #6ee7b7; }
.tag-warn, .pill-warn { border-color: rgba(245, 158, 11, 0.45); background: rgba(245, 158, 11, 0.14); color: #fcd34d; }
.tag-danger, .pill-danger { border-color: rgba(239, 68, 68, 0.45); background: rgba(239, 68, 68, 0.14); color: #fca5a5; }

.hero-strip {
  display: grid;
  grid-template-columns: 1.4fr 1.2fr;
  gap: 16px;
  margin-bottom: 16px;
}

.hero-copy, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}

.hero-copy h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.kpi-label {
  font-size: 11.5px;
  color: var(--muted);
}

.kpi-val {
  font-size: 22px;
  font-weight: 700;
  margin-top: 2px;
}

.kpi-warn { color: var(--warn); }
.kpi-danger { color: var(--danger); }
.kpi-ok { color: var(--ok); }

.tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 15.5px;
}

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

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

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.subcard {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.subcard h3 {
  margin: 0 0 8px;
  font-size: 13.5px;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}

.text-input, .select-input, .code-input {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0d131c;
  color: var(--text);
  font-size: 13px;
}

.select-input {
  width: auto;
  max-width: 100%;
  min-width: 0;
  margin-top: 0;
}

.role-switcher {
  max-width: 100%;
  min-width: 0;
}

.code-input {
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  min-width: 0;
  max-width: 100%;
}

.preset-bar, .action-row, .followup-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  min-width: 0;
  max-width: 100%;
}

.btn {
  padding: 7px 13px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-alt);
  text-decoration: none;
  max-width: 100%;
  white-space: normal;
  text-align: center;
}

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-alt); }
.btn-danger { background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.45); color: #fca5a5; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-chip { font-size: 11.5px; padding: 5px 10px; background: #0d131c; text-align: left; }
.btn-sm { padding: 4px 8px; font-size: 11.5px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.notice {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.notice-ok { border-color: rgba(16, 185, 129, 0.5); background: rgba(16, 185, 129, 0.12); color: #6ee7b7; }
.notice-err { border-color: rgba(239, 68, 68, 0.5); background: rgba(239, 68, 68, 0.12); color: #fca5a5; }

.empty-state, .scan-output {
  padding: 14px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: #0d131c;
}

.code-output {
  margin-top: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #090d13;
  border: 1px solid var(--border);
  overflow-x: auto;
  max-height: 360px;
  white-space: pre-wrap;
  word-break: break-word;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

code, .check-list li, .dd-summary {
  overflow-wrap: break-word;
}

.mono {
  overflow-wrap: break-word;
  word-break: break-word;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table.compact th,
.data-table.compact td {
  padding: 7px 6px;
  font-size: 12px;
}

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

.check-list li {
  margin-bottom: 10px;
}

.banner-info {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.1);
  color: #bfdbfe;
  font-size: 12.5px;
  margin-bottom: 12px;
}

.banner-warn {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.1);
  color: #fde68a;
  font-size: 12.5px;
  margin-bottom: 12px;
}

.kpi-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.auth-drawer, .freeze-drawer {
  margin-bottom: 16px;
}

.mb-16 {
  margin-bottom: 16px;
}

.showcase-hero {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 18px;
  align-items: start;
}

.showcase-hero > * {
  min-width: 0;
  max-width: 100%;
}

.showcase-headline {
  margin: 12px 0 8px;
  font-size: 24px;
  line-height: 1.25;
}

.showcase-lead {
  font-size: 14.5px;
  line-height: 1.6;
}

.arch-diagram {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

@media (max-width: 960px) {
  .hero-strip, .grid-2, .grid-3, .grid-4, .form-grid, .showcase-hero, .kpi-grid-3 {
    grid-template-columns: 1fr;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 540px) {
  .app-shell {
    padding: 10px 10px 36px;
  }
  .topbar {
    padding: 12px;
  }
  .topbar-controls {
    width: 100%;
  }
  .role-switcher, .select-input {
    width: 100%;
  }
  .showcase-headline {
    font-size: 20px;
  }
  .hero-copy h2 {
    font-size: 15px;
  }
  .tab-btn {
    padding: 7px 10px;
    font-size: 12px;
  }
  .panel, .hero-copy {
    padding: 12px;
  }
  .panel-header {
    flex-direction: column;
  }
  .code-output {
    font-size: 11px;
    padding: 10px;
  }
}
