:root {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color-scheme: dark;
  --bg: #07090d;
  --bg-elevated: #0b0e14;
  --surface: #10141c;
  --surface2: #151a24;
  --surface3: #1a2030;
  --panel: rgba(16, 20, 28, 0.88);
  --panel-strong: #111721;
  --text: #f5f7fb;
  --text-soft: #d7dce6;
  --muted: #8f99aa;
  --line: #252c39;
  --line-strong: #343e50;
  --accent: #a8ff78;
  --accent-2: #78d9ff;
  --accent-soft: rgba(168, 255, 120, 0.1);
  --danger: #ff7b86;
  --warning: #ffc96b;
  --success: #84edb0;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.16);
  --sidebar: 276px;
  --control: #151a24;
  --backdrop: rgba(2, 5, 10, 0.72);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f8;
  --bg-elevated: #fff;
  --surface: #fff;
  --surface2: #f5f7f9;
  --surface3: #e9edf1;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #fff;
  --text: #152019;
  --text-soft: #34433a;
  --muted: #64726a;
  --line: #dce3df;
  --line-strong: #bdc9c2;
  --accent: #2f8f4e;
  --accent-2: #197aa4;
  --accent-soft: rgba(47, 143, 78, 0.1);
  --danger: #b72f43;
  --warning: #93610a;
  --success: #167342;
  --shadow: 0 18px 55px rgba(25, 42, 32, 0.12);
  --shadow-soft: 0 10px 30px rgba(25, 42, 32, 0.08);
  --control: #f5f7f9;
  --backdrop: rgba(23, 34, 28, 0.42);
}

* {
  box-sizing: border-box;
}
html {
  background: var(--bg);
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(
      900px 620px at 78% -15%,
      rgba(120, 217, 255, 0.08),
      transparent 62%
    ),
    radial-gradient(
      760px 560px at 18% 0%,
      rgba(168, 255, 120, 0.075),
      transparent 60%
    ),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
:root[data-theme="light"] body {
  background:
    radial-gradient(
      900px 620px at 78% -15%,
      rgba(25, 122, 164, 0.08),
      transparent 62%
    ),
    radial-gradient(
      760px 560px at 18% 0%,
      rgba(47, 143, 78, 0.09),
      transparent 60%
    ),
    var(--bg);
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
input,
textarea,
select {
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease,
    color 0.18s ease;
}
button {
  touch-action: manipulation;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
  padding: 20px 14px 16px;
  border-right: 1px solid rgba(255, 255, 255, 0.065);
  background: rgba(8, 11, 16, 0.88);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
:root[data-theme="light"] .sidebar {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--line);
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 8px 12px;
}
.brand strong,
.brand small {
  display: block;
}
.brand strong {
  font-size: 16px;
  letter-spacing: -0.02em;
}
.brand small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
}
.logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  background: linear-gradient(
    135deg,
    var(--accent),
    #d9ff92 55%,
    var(--accent-2)
  );
  color: #0a0d0b;
  font-weight: 900;
  box-shadow: 0 8px 26px rgba(168, 255, 120, 0.16);
}
nav {
  display: grid;
  gap: 4px;
  overflow: auto;
  padding: 2px 1px 12px;
  scrollbar-width: thin;
}
nav button {
  position: relative;
  border: 0;
  background: transparent;
  color: #aeb8c7;
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  min-height: 42px;
}
nav button::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  width: 3px;
  height: 18px;
  border-radius: 4px;
  transform: translateY(-50%) scaleY(0.35);
  opacity: 0;
  background: var(--accent);
  transition: 0.18s ease;
}
nav button:hover {
  background: rgba(255, 255, 255, 0.045);
  color: #fff;
}
nav button.active {
  background: linear-gradient(
    90deg,
    rgba(168, 255, 120, 0.11),
    rgba(120, 217, 255, 0.035)
  );
  color: #fff;
}
nav button.active::before {
  opacity: 1;
  transform: translateY(-50%) scaleY(1);
}
.tenant-card {
  margin-top: auto;
  border: 1px solid var(--line);
  padding: 13px 14px;
  border-radius: 15px;
  display: grid;
  gap: 5px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.012)
  );
  box-shadow: var(--shadow-soft);
}
.tenant-card strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}
.tenant-card small,
.tenant-card span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
}

main {
  min-width: 0;
  padding: 0 34px 40px;
}
header {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  margin-bottom: 22px;
  padding: 18px 0 14px;
  background: linear-gradient(
    180deg,
    rgba(7, 9, 13, 0.97) 0%,
    rgba(7, 9, 13, 0.88) 70%,
    transparent 100%
  );
  backdrop-filter: blur(14px);
}
:root[data-theme="light"] header {
  background: linear-gradient(
    180deg,
    rgba(244, 246, 248, 0.97),
    rgba(244, 246, 248, 0.88) 70%,
    transparent
  );
}
header h1 {
  font-size: clamp(24px, 2vw, 34px);
  letter-spacing: -0.04em;
  margin-bottom: 0;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h2 {
  font-size: clamp(22px, 2.2vw, 32px);
  letter-spacing: -0.035em;
  margin-bottom: 8px;
}
h3 {
  letter-spacing: -0.02em;
}
.eyebrow {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.17em;
  color: var(--accent);
  margin-bottom: 7px;
}
.actions {
  display: flex;
  gap: 9px;
}

button,
.file-cta {
  border: 1px solid var(--line);
  background: rgba(21, 26, 36, 0.86);
  color: var(--text);
  border-radius: 11px;
  padding: 9px 13px;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.025) inset;
}
.compact-button {
  min-width: 42px;
  padding-inline: 11px;
}
button:hover,
.file-cta:hover {
  border-color: var(--line-strong);
  background: var(--surface3);
  transform: translateY(-1px);
}
button:active,
.file-cta:active {
  transform: translateY(0);
}
.primary {
  border-color: rgba(168, 255, 120, 0.72);
  background: linear-gradient(135deg, #b5ff88, var(--accent));
  color: #091008;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(168, 255, 120, 0.14);
}
.primary:hover {
  background: linear-gradient(135deg, #c2ff9e, #adff7f);
  border-color: #c9ffa9;
  box-shadow: 0 10px 30px rgba(168, 255, 120, 0.2);
}
.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  margin-top: 10px;
}
.full {
  width: 100%;
  margin-top: 5px;
}

.view {
  max-width: 1500px;
  margin: 0 auto;
  animation: viewIn 0.2s ease;
}
@keyframes viewIn {
  from {
    opacity: 0.45;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.view[hidden] {
  display: none !important;
}
.panel {
  border: 1px solid rgba(255, 255, 255, 0.075);
  background: linear-gradient(
    180deg,
    rgba(19, 24, 34, 0.94),
    rgba(13, 17, 24, 0.92)
  );
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}
.panel:hover {
  border-color: rgba(255, 255, 255, 0.105);
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(320px, 460px) minmax(340px, 1fr);
  gap: 22px;
  max-width: 1120px;
  margin: 4vh auto 0;
}
.auth-card,
.product-card {
  padding: 30px;
}
.auth-card {
  box-shadow: var(--shadow);
}
.auth-card form {
  display: grid;
  gap: 14px;
}
.auth-card label,
.purchase-form label,
.provisioning form label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  color: var(--text-soft);
}
.auth-card input,
.purchase-form input,
.purchase-form select,
.provisioning input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface2);
  color: var(--text);
  padding: 12px 13px;
  border-radius: 11px;
  outline: none;
}
.password-control {
  position: relative;
  display: block;
}
.password-control input {
  padding-right: 52px;
}
.password-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 40px;
  min-height: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}
.password-toggle:hover {
  transform: translateY(-50%);
  background: var(--surface3);
  color: var(--text);
}
.form-status {
  min-height: 18px;
  margin: -4px 0 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.4;
}
.auth-card input:hover,
.purchase-form input:hover,
.purchase-form select:hover,
.provisioning input:hover,
.composer textarea:hover {
  border-color: var(--line-strong);
}
.auth-card input:focus,
.purchase-form input:focus,
.purchase-form select:focus,
.provisioning input:focus,
.composer textarea:focus {
  border-color: rgba(168, 255, 120, 0.62);
  box-shadow: 0 0 0 4px rgba(168, 255, 120, 0.07);
}
.fine,
.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}
.product-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 440px;
  position: relative;
  background: linear-gradient(
    145deg,
    rgba(18, 24, 33, 0.97),
    rgba(11, 15, 21, 0.97)
  );
}
.product-card::after {
  content: "";
  position: absolute;
  width: 330px;
  height: 330px;
  border-radius: 50%;
  right: -130px;
  top: -130px;
  background: radial-gradient(
    circle,
    rgba(120, 217, 255, 0.13),
    transparent 68%
  );
  pointer-events: none;
}
.product-card h2 {
  max-width: 720px;
  font-size: clamp(28px, 3vw, 46px);
  line-height: 1.06;
}
.product-card p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
  max-width: 680px;
}
.orb {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid rgba(168, 255, 120, 0.32);
  background: linear-gradient(
    135deg,
    rgba(168, 255, 120, 0.1),
    rgba(120, 217, 255, 0.08)
  );
  border-radius: 18px;
  color: var(--accent);
  font-size: 24px;
  margin-bottom: 22px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.badges span {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  border-radius: 100px;
  padding: 7px 10px;
  color: #c6cfdb;
  font-size: 11px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin-bottom: 18px;
}
.section-head > div > p:last-child {
  color: var(--muted);
  margin-bottom: 0;
  max-width: 820px;
  line-height: 1.6;
}
.file-cta {
  display: inline-flex;
  font-weight: 800;
  align-items: center;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 18px;
}
.chat-card {
  min-height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.messages {
  flex: 1;
  padding: 28px;
  overflow: auto;
  max-height: calc(100vh - 300px);
  scrollbar-color: #303949 transparent;
}
.chat-empty {
  height: 100%;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--muted);
}
.chat-empty h2 {
  color: var(--text);
  font-size: clamp(28px, 3vw, 42px);
}
.chat-empty p {
  max-width: 520px;
  line-height: 1.6;
}
.message {
  max-width: min(78%, 780px);
  padding: 13px 15px;
  border-radius: 16px;
  margin: 10px 0;
  line-height: 1.55;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.1);
}
.message p {
  margin: 0;
  white-space: pre-wrap;
}
.message.user {
  margin-left: auto;
  background: linear-gradient(
    135deg,
    rgba(168, 255, 120, 0.14),
    rgba(168, 255, 120, 0.08)
  );
  border: 1px solid rgba(168, 255, 120, 0.23);
}
.message.assistant {
  background: rgba(20, 25, 35, 0.92);
  border: 1px solid var(--line);
}
.citations {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.citations span,
.citations button {
  font-size: 10px;
  padding: 5px 8px;
  border: 1px solid #344052;
  border-radius: 8px;
  color: #bcc7d6;
  background: rgba(255, 255, 255, 0.015);
}
.composer {
  border-top: 1px solid var(--line);
  padding: 14px;
  background: rgba(8, 11, 16, 0.66);
  backdrop-filter: blur(12px);
}
.composer textarea {
  width: 100%;
  min-height: 78px;
  max-height: 220px;
  resize: vertical;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  line-height: 1.5;
}
.composer-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
.icon-button {
  border: 1px solid var(--line);
  background: var(--surface2);
  border-radius: 10px;
  padding: 9px 13px;
  cursor: pointer;
}
.attachment-state {
  padding: 9px 16px;
  font-size: 12px;
  color: var(--accent);
  border-top: 1px solid var(--line);
  background: rgba(168, 255, 120, 0.035);
}
.insights {
  display: grid;
  gap: 14px;
  align-content: start;
}
.insights article {
  padding: 19px;
}
.insights small {
  display: block;
  color: var(--muted);
  margin-bottom: 7px;
}
.insights strong {
  font-size: 25px;
  letter-spacing: -0.03em;
}
.insights p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 0;
}

.list {
  overflow: hidden;
}
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  min-height: 62px;
}
.list-row:last-child {
  border-bottom: 0;
}
.list-row:hover {
  background: rgba(255, 255, 255, 0.018);
}
.list-row strong,
.list-row small {
  display: block;
}
.list-row small {
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.4;
}
.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}
.row-actions button {
  padding: 7px 10px;
  font-size: 12px;
}
.inline-inspector,
pre {
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  color: #c7d0dc;
  background: #0b0f15;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font:
    12px/1.55 ui-monospace,
    SFMono-Regular,
    Menlo,
    Consolas,
    monospace;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.admin-panel {
  padding: 20px;
  min-height: 180px;
}
.admin-panel > h3 {
  margin-bottom: 16px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.metric {
  padding: 17px;
  min-height: 108px;
}
.metric small,
.metric strong {
  display: block;
}
.metric small {
  color: var(--muted);
  text-transform: capitalize;
}
.metric strong {
  font-size: 28px;
  margin-top: 8px;
  letter-spacing: -0.04em;
}

.current-plan {
  padding: 20px;
  margin-bottom: 18px;
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}
.current-plan p {
  margin: 0;
  color: var(--muted);
}
.plans-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.plan {
  padding: 21px;
  position: relative;
}
.plan.current {
  border-color: rgba(168, 255, 120, 0.42);
  box-shadow: 0 14px 40px rgba(168, 255, 120, 0.06);
}
.plan small {
  color: var(--accent);
}
.plan ul {
  padding-left: 18px;
  color: #bac3d0;
  line-height: 1.7;
}
.purchase-layout {
  display: grid;
  grid-template-columns: minmax(290px, 0.82fr) minmax(0, 2fr);
  gap: 18px;
}
.purchase-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: start;
  padding: 22px;
}
.form-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.public-plans {
  align-items: stretch;
}
.provisioning {
  margin-top: 18px;
  max-width: 760px;
  padding: 22px;
}
.provisioning form {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-top: 14px;
}
.provisioning form label {
  flex: 1;
}

.security-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.security-grid article {
  padding: 21px;
  min-height: 150px;
}
.security-grid p {
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 22px;
  top: 18px;
  z-index: 100;
  max-width: 420px;
  padding: 11px 14px;
  border-radius: 11px;
  background: #202837;
  border: 1px solid #465164;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: 0.2s;
}
.toast.show {
  opacity: 1;
  transform: none;
}
.toast.bad,
.error {
  color: #ffb1b1;
}
.toast.bad {
  border-color: #7f3e46;
}
:root[data-theme="light"] .toast.bad,
:root[data-theme="light"] .error {
  color: var(--danger);
}
.turnstile-box {
  min-height: 2px;
}

.nav-icon {
  width: 18px;
  height: 18px;
  vertical-align: -4px;
  margin-right: 9px;
  stroke-width: 1.8;
}
.action-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: min(82dvh, 760px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  color: var(--text);
  background: linear-gradient(180deg, var(--panel-strong), var(--surface));
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.42);
  overflow: auto;
}
.action-dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(8px);
}
.action-dialog form {
  padding: 24px;
}
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.dialog-heading h2 {
  margin-bottom: 7px;
}
.dialog-heading p:last-child {
  margin-bottom: 0;
}
.dialog-close {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  font-size: 24px;
  line-height: 1;
}
.dialog-fields {
  display: grid;
  gap: 15px;
}
.dialog-fields label {
  display: grid;
  gap: 7px;
  color: var(--text-soft);
  font-size: 12px;
}
.dialog-fields input,
.dialog-fields textarea,
.dialog-fields select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--control);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
}
.dialog-fields textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.5;
}
.dialog-fields input:focus,
.dialog-fields textarea:focus,
.dialog-fields select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.action-dialog.danger #dialogConfirm {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
  box-shadow: none;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 1000;
  background: var(--accent);
  color: #111;
  padding: 10px 14px;
  border-radius: 8px;
}
.skip-link:focus {
  top: 12px;
}
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 1100px) {
  :root {
    --sidebar: 232px;
  }
  main {
    padding-left: 24px;
    padding-right: 24px;
  }
  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .hero-grid {
    grid-template-columns: minmax(0, 1fr) 250px;
  }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: sticky;
    height: auto;
    top: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
    gap: 10px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    background: rgba(8, 11, 16, 0.96);
  }
  .brand {
    padding: 0;
  }
  .brand small {
    display: none;
  }
  .logo {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }
  nav {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 4px;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar {
    display: none;
  }
  nav button {
    flex: 0 0 auto;
    padding: 8px 10px;
    min-height: 38px;
    white-space: nowrap;
  }
  nav button::before {
    display: none;
  }
  .tenant-card {
    margin: 0;
    padding: 8px 10px;
    min-width: 125px;
    max-width: 180px;
  }
  .tenant-card small {
    display: none;
  }
  main {
    padding: 0 16px 28px;
  }
  header {
    min-height: 78px;
    margin-bottom: 14px;
  }
  .hero-grid,
  .auth-grid,
  .purchase-layout {
    grid-template-columns: 1fr;
  }
  .auth-grid {
    margin-top: 1vh;
  }
  .product-card {
    min-height: 320px;
  }
  .insights {
    grid-template-columns: repeat(2, 1fr);
  }
  .plans-grid {
    grid-template-columns: 1fr;
  }
  .security-grid {
    grid-template-columns: 1fr;
  }
  .admin-grid {
    grid-template-columns: 1fr;
  }
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .messages {
    max-height: none;
  }
  .chat-card {
    min-height: 620px;
  }
  .provisioning form {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 620px) {
  .sidebar {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .tenant-card {
    display: none;
  }
  .brand strong {
    display: none;
  }
  nav button span {
    display: none;
  }
  nav button {
    min-width: 38px;
    text-align: center;
    padding: 8px 9px;
  }
  header {
    align-items: flex-start;
    gap: 14px;
  }
  header h1 {
    font-size: 24px;
  }
  .actions {
    flex-shrink: 0;
  }
  .auth-card,
  .product-card {
    padding: 21px;
  }
  .product-card h2 {
    font-size: 30px;
  }
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .section-head > button,
  .section-head > .file-cta {
    width: 100%;
    justify-content: center;
  }
  .message {
    max-width: 92%;
  }
  .insights {
    grid-template-columns: 1fr;
  }
  .form-pair {
    grid-template-columns: 1fr;
  }
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
  .list-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .row-actions {
    justify-content: flex-start;
    width: 100%;
  }
  .row-actions button {
    flex: 1 1 auto;
  }
  .composer textarea {
    min-height: 92px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}

/* --------------------------------------------------------------------------
   RC9 UI/UX hardening
   - Defensive wrapping for untrusted/dynamic text
   - Predictable flex/grid shrinking
   - Mobile/tablet navigation that remains discoverable
   - Dynamic-viewport chat and touch-safe controls
   - Sticky-header collision removal on compact layouts
   -------------------------------------------------------------------------- */

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}
img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

/* Flex/grid children are allowed to shrink instead of forcing page overflow. */
.shell > *,
main > *,
.view > *,
.section-head > *,
.hero-grid > *,
.admin-grid > *,
.purchase-layout > *,
.security-grid > *,
.metric-grid > *,
.plans-grid > *,
.current-plan > *,
.list-row > *,
.composer-row > * {
  min-width: 0;
}

/* Dynamic content may contain URLs, hashes, UUIDs or imported names with no spaces. */
.message,
.message p,
.citations,
.citations button,
.attachment-state,
.toast,
.list-row,
.list-row strong,
.list-row small,
.list-row span,
.admin-panel,
.metric,
.metric small,
.metric strong,
.plan,
.plan h3,
.plan strong,
.plan p,
.current-plan,
.current-plan strong,
.current-plan span,
.insights,
.insights strong,
.insights p,
.security-grid article,
.section-head,
.section-head p,
.tenant-card,
.tenant-card strong,
.provisioning,
.inline-inspector,
pre,
.badges span,
.file-cta,
button,
label,
input,
textarea,
select {
  overflow-wrap: anywhere;
}

button,
.file-cta {
  max-width: 100%;
  white-space: normal;
  line-height: 1.25;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none !important;
  box-shadow: none;
}
input,
textarea,
select {
  min-width: 0;
  max-width: 100%;
}
textarea {
  overflow-wrap: anywhere;
}

/* Keep content readable and prevent action groups from squeezing primary text. */
.list-row > div:first-child,
.list-row > span:first-child {
  flex: 1 1 260px;
  min-width: 0;
}
.row-actions {
  min-width: 0;
  max-width: 100%;
}
.row-actions button {
  min-width: 0;
}
.list > .row-actions {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.012);
}
.list > p {
  padding: 16px 18px;
  margin: 0;
  color: var(--muted);
}

.feedback-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  flex-wrap: wrap;
}
.feedback-actions .icon-button {
  min-width: 40px;
  min-height: 38px;
  padding: 7px 10px;
}
.citations button {
  max-width: 100%;
  text-align: left;
  line-height: 1.35;
}

/* More robust chat sizing; the message area, not the whole page, receives the scroll. */
.chat-card {
  min-width: 0;
}
.messages {
  min-width: 0;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
.message {
  min-width: 0;
}
.composer {
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.composer-row {
  min-width: 0;
}
.attachment-state {
  white-space: normal;
}

/* Toasts must remain fully inside narrow screens even with long server errors. */
.toast {
  width: min(420px, calc(100vw - 32px));
  max-height: min(46vh, 360px);
  overflow: auto;
  right: max(16px, env(safe-area-inset-right));
  top: max(16px, env(safe-area-inset-top));
}

/* Horizontal nav is intentionally swipeable and keeps labels for discoverability. */
nav {
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}
nav button {
  scroll-snap-align: start;
}

@media (max-width: 900px) {
  .sidebar {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "brand tenant" "nav nav";
    padding: max(10px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right)) 9px
      max(14px, env(safe-area-inset-left));
    row-gap: 8px;
  }
  .brand {
    grid-area: brand;
    min-width: 0;
  }
  nav {
    grid-area: nav;
    width: 100%;
    padding: 1px 0 2px;
  }
  .tenant-card {
    grid-area: tenant;
    justify-self: end;
    width: min(210px, 45vw);
    min-width: 0;
    max-width: none;
    padding: 7px 10px;
    box-shadow: none;
  }
  .tenant-card strong {
    font-size: 12px;
  }
  /* The sidebar owns sticky positioning on compact screens. Avoid two top:0 layers. */
  header {
    position: relative;
    top: auto;
    z-index: 1;
    backdrop-filter: none;
    background: transparent;
  }
  main {
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }
  .chat-card {
    min-height: calc(100dvh - 190px);
  }
  .messages {
    min-height: 320px;
  }
  .row-actions button {
    min-height: 42px;
  }
}

@media (max-width: 620px) {
  .sidebar {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "brand tenant" "nav nav";
  }
  .brand strong {
    display: block;
    font-size: 14px;
  }
  .tenant-card {
    display: grid;
    width: min(190px, 56vw);
  }
  .tenant-card span {
    display: none;
  }
  nav button span {
    display: inline;
  }
  nav button {
    min-width: auto;
    min-height: 44px;
    text-align: left;
    padding: 9px 11px;
    font-size: 12px;
  }
  header {
    min-height: auto;
    padding: 18px 0 12px;
    flex-wrap: wrap;
  }
  header > div:first-child {
    min-width: 0;
    flex: 1 1 180px;
  }
  .actions {
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .actions button {
    min-height: 42px;
  }
  .message {
    max-width: 96%;
    padding: 12px 13px;
  }
  .messages {
    padding: 18px 14px;
    min-height: 300px;
  }
  .chat-card {
    min-height: calc(100dvh - 182px);
  }
  .composer {
    padding: 11px;
  }
  .composer textarea {
    min-height: 76px;
    max-height: 180px;
    resize: none;
    font-size: 16px;
  }
  .composer-row {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
  }
  .icon-button,
  #clearAttachment,
  .send {
    min-height: 44px;
  }
  .icon-button,
  #clearAttachment {
    min-width: 44px;
    padding: 8px 10px;
  }
  .send {
    padding-inline: 15px;
  }
  .section-head {
    gap: 12px;
    margin-bottom: 15px;
  }
  .admin-panel {
    padding: 16px;
  }
  .list-row {
    padding: 14px 15px;
    gap: 12px;
  }
  .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .row-actions button {
    width: 100%;
    min-height: 44px;
  }
  .list > .row-actions {
    display: flex;
    padding: 10px 14px;
  }
  .list > .row-actions button {
    width: auto;
    flex: 1 1 180px;
  }
  .metric {
    min-height: 96px;
    padding: 15px;
  }
  .metric strong {
    font-size: 24px;
  }
  .current-plan {
    align-items: flex-start;
    gap: 10px;
    padding: 17px;
  }
  .plan {
    padding: 18px;
  }
  .security-grid article {
    padding: 18px;
    min-height: auto;
  }
  .auth-card,
  .product-card {
    padding: 20px;
  }
  .purchase-form {
    padding: 18px;
  }
  .action-dialog form {
    padding: 19px;
  }
  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .dialog-actions button {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 420px) {
  main {
    padding-left: 12px;
    padding-right: 12px;
  }
  .sidebar {
    padding-left: 10px;
    padding-right: 10px;
  }
  .brand strong {
    font-size: 13px;
  }
  .tenant-card {
    width: min(170px, 57vw);
    padding: 6px 8px;
  }
  .tenant-card strong {
    font-size: 11px;
  }
  header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 10px;
  }
  header h1 {
    font-size: 22px;
    line-height: 1.1;
  }
  .eyebrow {
    font-size: 9px;
    letter-spacing: 0.13em;
  }
  .actions {
    gap: 6px;
  }
  .actions button {
    padding: 8px 10px;
  }
  .product-card h2 {
    font-size: 27px;
  }
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .row-actions {
    grid-template-columns: 1fr;
  }
  .message {
    max-width: 100%;
  }
  .chat-empty {
    min-height: 270px;
  }
  .chat-empty h2 {
    font-size: 27px;
  }
  .composer-row {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    gap: 6px;
  }
  .send {
    padding-inline: 12px;
  }
  .toast {
    width: calc(100vw - 20px);
    right: 10px;
  }
}

@media (pointer: coarse) {
  button,
  .file-cta,
  input,
  select {
    min-height: 44px;
  }
  nav button {
    min-height: 44px;
  }
}

/* NEXA PLATFORM SUPER ADMIN */
.platform-admin-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  white-space: nowrap;
}
.platform-scope-card {
  display: grid;
  gap: 10px;
}
.platform-scope-card strong {
  font-size: 16px;
}
.platform-scope-card code,
.platform-list-row code {
  display: block;
  overflow-wrap: anywhere;
  opacity: .78;
  font-size: 11px;
}
.platform-list-row {
  align-items: flex-start;
}
.platform-list-row > div:first-child {
  min-width: 0;
  display: grid;
  gap: 7px;
  flex: 1;
}
.platform-entitlements {
  max-height: 220px;
  overflow: auto;
  margin: 4px 0 0;
  font-size: 11px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.platform-view .metric strong {
  font-variant-numeric: tabular-nums;
}

/* NEXA SUPERADMIN COMPANIES V2 */
.section-actions,
.platform-toolbar,
.company-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.section-actions { flex-wrap: wrap; }

.platform-toolbar input {
  width: min(520px, 100%);
}

.company-grid {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.company-card {
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border-radius: 18px;
  padding: 18px;
}

.company-card h3 {
  margin: 0 0 4px;
}

.company-card small,
.subtle {
  color: var(--muted);
}

.company-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 10px;
}

.company-meta > div,
.workspace-line {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 0;
}

.workspace-line {
  margin-bottom: 14px;
}

.workspace-line code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}

.status-pill.ok { color: var(--accent); }
.status-pill.warn { color: var(--muted); }

.empty-state {
  min-height: 250px;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  gap: 10px;
  color: var(--muted);
}
.empty-state h3 {
  margin: 0;
  color: var(--text);
}

@media (max-width: 900px) {
  .company-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .company-meta { grid-template-columns: 1fr; }
  .company-card-head,
  .platform-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
