:root {
  --bg: #0b1220;
  --panel: #101a2e;
  --panel2: #0f172a;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --line: rgba(255,255,255,.08);
  --chip: rgba(255,255,255,.08);

  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --na: #64748b;

  --accent: #38bdf8;
  --accent-dim: rgba(56,189,248,.12);
  --accent-glow: rgba(56,189,248,.25);
  --accent2: #818cf8;
  --accent2-dim: rgba(129,140,248,.12);

  --sidebar-w: 264px;
  --sidebar-bg: #090e1a;
  --sidebar-border: rgba(255,255,255,.06);

  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 999px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  height: 100%;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

body {
  overflow: hidden;
}

body.mobile-sidebar-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font: inherit;
}

.is-hidden {
  display: none !important;
}

/* Shell */
.shell {
  display: flex;
  height: 100dvh;
  min-height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 39;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 10;
}

.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, transparent, var(--accent-glow) 40%, transparent);
  pointer-events: none;
}

.sidebar-logo {
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.5px;
  flex-shrink: 0;
  box-shadow: 0 0 18px var(--accent-glow);
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.logo-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--text);
}

.logo-sub {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .8px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar {
  display: none;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--na);
  padding: 14px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
  user-select: none;
  border: 1px solid transparent;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: rgba(255,255,255,.04);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-dim);
  border-color: rgba(56,189,248,.2);
  color: var(--accent);
}

.nav-item .nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 700;
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--sidebar-border);
}

.env-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.2);
  font-size: 11px;
  color: var(--good);
}

.env-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 6px var(--good);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* Main */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg) 0%, #050816 100%);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(11,18,32,.8);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .2px;
}

.topbar-sub {
  font-size: 12px;
  color: var(--muted);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mobile-menu-btn {
  display: none;
}

.content {
  flex: 1;
  overflow: auto;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.content::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.content::-webkit-scrollbar-track {
  background: transparent;
}
.content::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.1);
  border-radius: 10px;
}

/* Shared */
.card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  min-width: 0;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
  letter-spacing: .3px;
}

.card-title-icon {
  font-size: 14px;
}

.panel {
  background: rgba(0,0,0,.15);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  min-width: 0;
}

/* Grids */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
}

.kpi-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .3px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.5px;
  word-break: break-word;
}

.kpi-change {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.kpi-change.up { color: var(--good); }
.kpi-change.down { color: var(--bad); }

.badge,
.chip,
.info-pill {
  max-width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--line);
}

.badge-good { background: rgba(34,197,94,.1); color: var(--good); border-color: rgba(34,197,94,.25); }
.badge-warn { background: rgba(245,158,11,.1); color: var(--warn); border-color: rgba(245,158,11,.25); }
.badge-bad  { background: rgba(239,68,68,.1); color: var(--bad); border-color: rgba(239,68,68,.25); }
.badge-na   { background: rgba(100,116,139,.1); color: #cbd5e1; }
.badge-accent { background: var(--accent-dim); color: var(--accent); border-color: rgba(56,189,248,.25); }
.badge-purple { background: var(--accent2-dim); color: var(--accent2); border-color: rgba(129,140,248,.25); }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--chip);
  border: 1px solid var(--line);
  font-size: 11px;
  white-space: nowrap;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--text);
  transition: all .15s;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255,255,255,.09);
}

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: transparent;
  box-shadow: 0 0 18px var(--accent-glow);
}

.btn-primary:hover {
  background: #7dd3fc;
  box-shadow: 0 0 26px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: rgba(255,255,255,.05);
  color: var(--text);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

.input,
.select,
.textarea {
  width: 100%;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(0,0,0,.2);
  color: var(--text);
  outline: none;
}

.input,
.select {
  padding: 9px 12px;
  font-size: 13px;
}

.input-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(56,189,248,.4);
}

.input::placeholder {
  color: var(--na);
}

.select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

.textarea {
  padding: 10px 12px;
  font-size: 12px;
  font-family: var(--font-ui);
  resize: vertical;
  min-height: 110px;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.form-help {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.table-wrapper {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

th {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255,255,255,.03);
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255,255,255,.02);
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-good { color: var(--good); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }

.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: 16px; }
.grid-12 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; }
.grid-21 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }

.divider {
  height: 1px;
  background: var(--line);
  margin: 16px 0;
}

.tech-grid {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 6px 12px;
  font-size: 12px;
}

.tech-grid .tg-k {
  color: var(--muted);
}

.tech-grid .tg-v {
  font-family: var(--font-mono);
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tech-grid .tg-sep {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--line);
  margin: 6px 0;
}

.builder-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  gap: 16px;
  min-height: calc(100dvh - 120px);
}

.builder-panel {
  background: rgba(255,255,255,.02);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.builder-panel-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,.15);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.builder-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}

.builder-panel-body::-webkit-scrollbar {
  width: 4px;
}
.builder-panel-body::-webkit-scrollbar-track {
  background: transparent;
}
.builder-panel-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.08);
  border-radius: 10px;
}

.module-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all .15s;
  background: rgba(0,0,0,.1);
}

.module-card:hover {
  border-color: rgba(56,189,248,.25);
  background: var(--accent-dim);
}

.module-card.selected {
  border-color: rgba(56,189,248,.4);
  background: var(--accent-dim);
}

.module-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.module-info {
  flex: 1;
  min-width: 0;
}

.module-name {
  font-size: 12px;
  font-weight: 600;
}

.module-desc {
  font-size: 11px;
  color: var(--muted);
}

.code-block {
  background: #050d1a;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: #cbd5e1;
  overflow: auto;
  white-space: pre;
}

.code-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.code-tab {
  padding: 5px 12px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all .15s;
}

.code-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(56,189,248,.25);
}

.code-tab:not(.active):hover {
  background: rgba(255,255,255,.04);
  color: var(--text);
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px 32px;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.service-card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color .15s;
  min-width: 0;
}

.service-card:hover {
  border-color: rgba(255,255,255,.14);
}

.service-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.service-info {
  flex: 1;
  min-width: 0;
}

.service-name {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
}

.service-desc {
  font-size: 11px;
  color: var(--muted);
}

.service-meta {
  text-align: right;
  flex-shrink: 0;
}

.infra-node {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  position: relative;
}

.infra-node-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .3px;
  margin-bottom: 10px;
  color: #cbd5e1;
}

.workload-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  font-size: 11px;
  margin: 2px;
  color: var(--muted);
}

.workload-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--good);
}

.progress-bar {
  height: 4px;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .4s ease;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 12px;
  margin-bottom: 12px;
}

.alert-info { background: var(--accent-dim); border: 1px solid rgba(56,189,248,.2); color: #bae6fd; }
.alert-warn { background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.2); color: #fcd34d; }
.alert-bad  { background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.2); color: #fca5a5; }

.info-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

.accent-line {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  margin: 20px 0;
  opacity: .4;
}

.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.3px;
  margin-bottom: 4px;
}

.section-header p {
  font-size: 13px;
  color: var(--muted);
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 10px;
}

.empty-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.empty-desc {
  font-size: 12px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--na);
  box-shadow: 0 0 6px rgba(100,116,139,.35);
}

.dot.good { background: var(--good); box-shadow: 0 0 8px rgba(34,197,94,.45); }
.dot.bad  { background: var(--bad);  box-shadow: 0 0 8px rgba(239,68,68,.35); }
.dot.warn { background: var(--warn); box-shadow: 0 0 8px rgba(245,158,11,.35); }

.tenant-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line);
  min-width: 0;
}

.tenant-switcher-label {
  font-size: 11px;
  color: var(--muted);
}

.tenant-switcher-select {
  width: 220px;
  padding: 6px 10px;
  font-size: 12px;
  border-radius: var(--r-md);
}

.table-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
  vertical-align: middle;
}

.switch input {
  display: none;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255,255,255,.10);
  border: 1px solid var(--line);
  transition: .2s;
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  top: 2px;
  background-color: rgba(255,255,255,.75);
  transition: .2s;
  border-radius: 50%;
}

.switch input:checked + .slider {
  background-color: rgba(34,197,94,.18);
  border-color: rgba(34,197,94,.25);
}

.switch input:checked + .slider:before {
  transform: translateX(18px);
  background-color: #eafff0;
}

.switch input:disabled + .slider {
  opacity: .5;
  cursor: not-allowed;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 18px;
}

.modal {
  width: min(720px, 100%);
  max-height: min(90dvh, 900px);
  background: rgba(16,26,46,.96);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0,0,0,.55);
  animation: fadeInUp .16s ease both;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-size: 14px;
  font-weight: 700;
}

.modal-body {
  padding: 18px;
  overflow: auto;
}

.modal-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  background: rgba(255,255,255,.02);
}

/* Toasts */
#toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  min-width: 260px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: auto;
  background: rgba(16,26,46,.96);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  color: var(--text);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,.35);
}

.toast.good { border-left-color: var(--good); }
.toast.warn { border-left-color: var(--warn); }
.toast.bad  { border-left-color: var(--bad); }

.toast-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
}

.toast-body {
  font-size: 12px;
  color: var(--muted);
}

/* Auth */
.auth-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(56,189,248,.12), transparent 30%),
    radial-gradient(circle at bottom right, rgba(129,140,248,.14), transparent 28%),
    linear-gradient(180deg, #07101d 0%, #0b1220 100%);
}

.auth-card {
  width: min(460px, 100%);
  background: rgba(16,26,46,.95);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.38);
}

.auth-card-wide {
  width: min(720px, 100%);
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
}

.auth-sub {
  font-size: 13px;
  color: var(--muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-submit {
  width: 100%;
  margin-top: 8px;
}

.auth-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* Utility */
.section-view {
  animation: fadeInUp .2s ease both;
  min-width: 0;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 1200px) {
  .builder-shell {
    grid-template-columns: 240px minmax(0, 1fr) 280px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  body.mobile-sidebar-open .mobile-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .shell {
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    min-width: min(82vw, 320px);
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 40;
  }

  body.mobile-sidebar-open .sidebar {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .topbar {
    padding: 14px 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-left,
  .topbar-actions {
    width: 100%;
  }

  .topbar-actions {
    margin-left: 0;
    justify-content: flex-start;
  }

  .tenant-switcher {
    width: 100%;
  }

  .tenant-switcher-select {
    width: 100%;
  }

  .content {
    padding: 16px;
  }

  .grid-2,
  .grid-3,
  .grid-12,
  .grid-21,
  .builder-shell {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .service-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .service-meta {
    text-align: left;
  }

  .tech-grid {
    grid-template-columns: 1fr;
  }

  .tech-grid .tg-k {
    font-weight: 700;
    color: #cbd5e1;
  }

  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .table-toolbar > * {
    width: 100%;
  }

  .modal-backdrop {
    padding: 10px;
    align-items: flex-end;
  }

  .modal {
    width: 100%;
    max-height: 92dvh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding-left: 14px;
    padding-right: 14px;
  }

  #toast-root {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }

  .toast {
    min-width: 0;
    max-width: 100%;
  }

  .auth-screen {
    padding: 16px;
  }

  .auth-card {
    padding: 20px;
    border-radius: 20px;
  }
}

@media (max-width: 560px) {
  html, body {
    font-size: 13px;
  }

  .topbar-title {
    font-size: 15px;
  }

  .topbar-sub {
    font-size: 11px;
  }

  .btn,
  .input,
  .select,
  .textarea {
    font-size: 16px;
  }

  .btn-sm {
    font-size: 12px;
  }

  .card,
  .panel {
    padding: 14px;
  }

  .auth-title {
    font-size: 18px;
  }

  .logo-name {
    font-size: 12px;
  }

  table {
    min-width: 640px;
  }
}

.page-heading {
  margin-bottom: 18px;
}

.page-heading h1 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
}

.page-heading p {
  color: var(--muted);
  font-size: 13px;
}

.feedback-error {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
  color: #fca5a5;
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.feedback-success {
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.2);
  color: #bbf7d0;
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.toolbar-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stack-md > * + * {
  margin-top: 14px;
}

.auth-card .card {
  margin-top: 8px;
}

.auth-card .input[style] {
  min-height: 42px;
}

.info-block {
  margin-bottom: 14px;
}

.info-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.info-value {
  display: flex;
  align-items: center;
  min-height: 20px;
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}

.info-value-muted {
  color: var(--muted);
}

.info-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  font-size: 12px;
  color: var(--text);
  width: fit-content;
  max-width: 100%;
}

.password-checklist {
  display: grid;
  gap: 6px;
  margin-top: 6px;
}

.password-rule {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.password-rule.ok {
  color: var(--good);
}

.password-rule-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  flex-shrink: 0;
}

.password-rule.ok .password-rule-dot {
  background: var(--good);
  box-shadow: 0 0 8px rgba(34,197,94,.35);
}