/**
 * Vibot Agency — B2B control plane (aligned with Volumen: navy + gold)
 */
:root {
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-display: "Syne", system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, monospace;
  --navy: #1c1e54;
  --navy-deep: #12133a;
  --navy-muted: #2d3070;
  --gold: #f0c429;
  --gold-soft: rgba(240, 196, 41, 0.14);
  --gold-text: #9b6829;
  --surface: #ffffff;
  --surface-2: #f8f7fc;
  --surface-3: #f0eff8;
  --border: #e4e2ef;
  --border-strong: #cdc9e0;
  --text: #12133a;
  --text-muted: #5c5a78;
  --text-soft: #8886a3;
  --success: #0d7a4e;
  --success-bg: rgba(13, 122, 78, 0.08);
  --danger: #b42318;
  --danger-bg: rgba(180, 35, 24, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-xs: 0 1px 2px rgba(28, 30, 84, 0.04);
  --shadow-sm: 0 4px 12px rgba(28, 30, 84, 0.06);
  --shadow-md: 0 12px 40px rgba(28, 30, 84, 0.1);
  --sidebar-w: 15.5rem;
  --topbar-h: 3.75rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --auth-cream: #f3f1ea;
  --auth-cream-line: #e5e2d8;
  --auth-shell-radius: 1.75rem;
  --auth-panel: #ebe8e1;
  --auth-panel-deep: #e0ddd5;
  --auth-panel-text: #3d3b36;
  --app-bg: #f4f4f5;
  --app-sidebar: #fafafa;
  --app-accent: #5b7fd4;
  --app-accent-soft: rgba(91, 127, 212, 0.12);
  --app-text: #1a1a1a;
  --app-muted: #6b6b6b;
  --app-radius: 1.25rem;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ── Sign in (split layout, warm form + visual panel) ── */
body.mode-login {
  min-height: 100dvh;
  background: #e8e6df;
}

.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
    max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.auth-shell {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
  max-width: 68rem;
  min-height: min(40rem, calc(100dvh - 2rem));
  background: var(--auth-cream);
  border-radius: var(--auth-shell-radius);
  box-shadow: 0 20px 50px rgba(28, 30, 84, 0.12), 0 4px 14px rgba(28, 30, 84, 0.06);
  overflow: hidden;
}

@media (min-width: 900px) {
  .auth-shell {
    grid-template-columns: minmax(20rem, 0.92fr) minmax(22rem, 1.08fr);
    align-items: stretch;
  }
}

.auth-form-col {
  display: flex;
  flex-direction: column;
  padding: 1.75rem 1.75rem 1.25rem;
  min-width: 0;
}

@media (min-width: 900px) {
  .auth-form-col {
    padding: 2.25rem 2.5rem 1.75rem;
  }
}

.auth-top {
  margin-bottom: 2rem;
}

.auth-pill-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem 0.4rem 0.45rem;
  border: 1px solid var(--auth-cream-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
}

.auth-pill-mark {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-pill-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--navy);
  letter-spacing: -0.02em;
}

.auth-pill-tag {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
  padding-left: 0.35rem;
  border-left: 1px solid var(--auth-cream-line);
  margin-left: 0.1rem;
}

.auth-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 22rem;
  width: 100%;
}

.auth-panel {
  width: 100%;
}

.auth-title {
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--navy);
  margin: 0 0 0.5rem;
  line-height: 1.15;
}

.auth-lead {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
  line-height: 1.55;
  max-width: 20rem;
}

.auth-form {
  padding-top: 0;
}

body.mode-login .field-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 0.35rem;
}

body.mode-login .auth-input {
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--auth-cream-line);
  padding: 0.8rem 1.1rem;
  margin-bottom: 1.1rem;
  box-shadow: 0 1px 2px rgba(28, 30, 84, 0.04);
}

body.mode-login .auth-pw-wrap {
  margin-bottom: 1.1rem;
}

body.mode-login .auth-pw-wrap .auth-input {
  margin-bottom: 0;
  padding-right: 2.85rem;
}

body.mode-login .auth-input:focus {
  border-color: var(--navy-muted);
  box-shadow: 0 0 0 3px var(--gold-soft);
  outline: none;
}

body.mode-login .auth-submit {
  margin-top: 0.35rem;
  border-radius: 999px;
  background: var(--gold);
  color: var(--navy-deep);
  font-weight: 700;
  min-height: 3rem;
  box-shadow: 0 4px 14px rgba(240, 196, 41, 0.45);
}

body.mode-login .auth-submit:hover:not(:disabled) {
  background: #e5b820;
  color: var(--navy-deep);
}

.spinner--dark {
  border-color: rgba(18, 19, 58, 0.2);
  border-top-color: var(--navy-deep);
}

.auth-help {
  margin: 1rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-soft);
  line-height: 1.5;
}

.auth-help--inline {
  margin-top: 1.25rem;
}

.auth-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--auth-cream-line);
  font-size: 0.8125rem;
}

.auth-foot-note {
  margin: 0;
  color: var(--text-muted);
  max-width: 14rem;
  line-height: 1.45;
}

.auth-foot-link {
  color: var(--navy-muted);
  font-weight: 600;
  text-decoration: none;
}

.auth-foot-link:hover {
  color: var(--navy);
  text-decoration: underline;
}

/* Visual panel — minimal copy, warm neutral + deco circles */
.auth-visual {
  position: relative;
  min-height: 8rem;
  overflow: hidden;
  background: var(--auth-panel);
}

@media (min-width: 900px) {
  .auth-visual {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100%;
  }
}

@media (max-width: 899px) {
  .auth-shell {
    min-height: auto;
    grid-template-rows: auto 1fr;
  }

  .auth-visual {
    order: -1;
  }

  .auth-form-col {
    padding: 1.5rem 1.35rem 1.25rem;
  }

  .auth-top {
    margin-bottom: 1.5rem;
  }

  .auth-visual-content {
    padding: 1.35rem 1.35rem 1.5rem;
  }

  .auth-visual-list,
  .auth-orbs {
    display: none;
  }

  .auth-blob--sm {
    opacity: 0.5;
  }
}

.auth-visual-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.auth-blob {
  position: absolute;
  border-radius: 50%;
}

.auth-blob--gold {
  width: 16rem;
  height: 16rem;
  top: -5rem;
  right: -4rem;
  background: #fff;
  opacity: 0.7;
}

.auth-blob--blue {
  width: 11rem;
  height: 11rem;
  bottom: -3rem;
  left: -2.5rem;
  background: var(--auth-panel-deep);
  opacity: 0.9;
}

.auth-blob--sm {
  width: 3.5rem;
  height: 3.5rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.auth-blob--tl {
  top: 2.5rem;
  left: 1.5rem;
}

.auth-blob--br {
  bottom: 3rem;
  right: 2rem;
  width: 2.25rem;
  height: 2.25rem;
  background: rgba(255, 255, 255, 0.45);
  border: none;
}

.auth-visual-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 20rem;
  padding: 1.75rem 2.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.75rem;
}

@media (min-width: 900px) {
  .auth-visual-content {
    padding: 2rem 2.25rem 2.75rem;
  }
}

.auth-visual-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2vw, 1.45rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--auth-panel-text);
}

.auth-visual-lead {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: rgba(61, 59, 54, 0.68);
}

.auth-visual-list {
  margin: 0.35rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.auth-visual-list li {
  font-size: 0.8125rem;
  font-weight: 500;
  color: rgba(61, 59, 54, 0.65);
  padding-left: 0.9rem;
  position: relative;
}

.auth-visual-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--auth-panel-text);
  opacity: 0.3;
}

.auth-orbs {
  display: flex;
  align-items: center;
  margin-top: 1.25rem;
}

.auth-orb {
  width: 2rem;
  height: 2rem;
  margin-left: -0.4rem;
  border-radius: 50%;
  border: 2px solid var(--auth-panel);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(61, 59, 54, 0.5);
}

.auth-orb:first-child {
  margin-left: 0;
}

.auth-orb--plus {
  background: #fff;
  color: var(--auth-panel-text);
  border-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 8px rgba(44, 42, 38, 0.12);
}

.field-note {
  font-size: 0.8125rem;
  color: var(--text-soft);
  margin: -0.65rem 0 1rem;
}

.btn-text {
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  color: var(--navy-muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-text:hover {
  color: var(--navy);
}

body.mode-login .btn-text {
  color: var(--gold-text);
}

body.mode-login .btn-text:hover {
  color: var(--navy);
}

.field-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.text-input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 1rem;
  margin-bottom: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s;
}

.text-input::placeholder {
  color: var(--text-soft);
}

.text-input:hover {
  border-color: var(--border-strong);
}

.text-input:focus {
  outline: none;
  border-color: var(--navy);
}

.pw-wrap {
  position: relative;
  margin-bottom: 1rem;
}

.pw-wrap .text-input {
  margin-bottom: 0;
  padding-right: 2.75rem;
}

.pw-toggle {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  padding: 0.5rem;
  min-width: 2.75rem;
  min-height: 2.75rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pw-toggle:hover {
  color: var(--text-muted);
  background: var(--surface-3);
}

.btn-submit {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: var(--navy);
  color: #fff;
  transition: background 0.15s, transform 0.1s;
}

.btn-submit:hover:not(:disabled) {
  background: var(--navy-muted);
}

.btn-submit:active:not(:disabled) {
  transform: scale(0.99);
}

.btn-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.auth-err,
.form-err {
  font-size: 0.8125rem;
  color: var(--danger);
  margin: 0 0 1rem;
  padding: 0.6rem 0.75rem;
  background: var(--danger-bg);
  border: 1px solid rgba(180, 35, 24, 0.15);
  border-radius: var(--radius-sm);
  display: none;
}

.auth-err.is-visible,
.form-err.is-visible {
  display: block;
}

.hint {
  font-size: 0.8125rem;
  color: var(--text-soft);
  margin: -0.5rem 0 1rem;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── App layout (light SaaS) ── */
body.mode-app {
  background: var(--app-bg);
  color: var(--app-text);
}

body.mode-login #app-shell {
  display: none !important;
}

/* Dashboard: loader until /me + data; then session-ready reveals shell */
.app-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: var(--app-bg);
  color: var(--app-muted);
  font-size: 0.875rem;
  font-weight: 600;
}

html.session-ready #app-loading {
  display: none !important;
}

html:not(.session-ready) #app-shell {
  display: none !important;
}

html.session-ready #app-shell {
  display: flex !important;
}

html.session-known #view-dashboard,
html.session-known #view-team,
html.session-known #view-api-keys,
html.session-known #view-settings {
  display: none !important;
}

html.session-known[data-boot-view='clients'] #view-dashboard {
  display: block !important;
}

html.session-known[data-boot-view='team'] #view-team {
  display: block !important;
}

html.session-known[data-boot-view='api-keys'] #view-api-keys {
  display: block !important;
}

html.session-known[data-boot-view='settings'] #view-settings {
  display: block !important;
}

html.session-known:not([data-boot-view='clients']) .sidebar-nav-item.is-active {
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
}

html.session-known:not([data-boot-view='clients']) .sidebar-nav-item.is-active svg {
  opacity: 0.7;
  stroke: currentColor;
}

html.session-known[data-boot-view='team'] .sidebar-nav-item[data-view='team'],
html.session-known[data-boot-view='api-keys'] .sidebar-nav-item[data-view='api-keys'],
html.session-known[data-boot-view='platform'] .sidebar-nav-item[data-view='platform'],
html.session-known[data-boot-view='settings'] .sidebar-nav-item[data-view='settings'] {
  background: var(--app-accent-soft);
  color: var(--app-accent);
  font-weight: 600;
}

html.session-known[data-boot-view='team'] .sidebar-nav-item[data-view='team'] svg,
html.session-known[data-boot-view='api-keys'] .sidebar-nav-item[data-view='api-keys'] svg,
html.session-known[data-boot-view='platform'] .sidebar-nav-item[data-view='platform'] svg,
html.session-known[data-boot-view='settings'] .sidebar-nav-item[data-view='settings'] svg {
  opacity: 1;
  stroke: var(--app-accent);
}

.app-layout {
  display: flex;
  min-height: 100dvh;
}

.sidebar-backdrop {
  display: none;
}

.sidebar {
  display: none;
  width: 15rem;
  flex-shrink: 0;
  flex-direction: column;
  background: var(--app-sidebar);
  border-right: 1px solid #ececec;
  padding: 1.35rem 1rem 1rem;
}

@media (max-width: 767px) {
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(18, 19, 58, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s var(--ease);
  }

  body.mobile-nav-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body.mobile-nav-open {
    overflow: hidden;
  }

  .sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(18.5rem, 88vw);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.28s var(--ease);
    box-shadow: none;
    padding-top: max(1.25rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    padding-left: max(1rem, env(safe-area-inset-left));
  }

  body.mobile-nav-open .sidebar {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(28, 30, 84, 0.14);
  }

  .sidebar-nav-item {
    min-height: 2.75rem;
    padding: 0.75rem 0.9rem;
  }

  .sidebar-brand {
    padding-bottom: 1.5rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid #ececec;
  }
}

@media (min-width: 768px) {
  .sidebar {
    display: flex;
  }
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 0.35rem 1.35rem;
  margin-bottom: 0.5rem;
}

.sidebar-mark {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 0.65rem;
  background: var(--app-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--app-text);
}

.sidebar-brand-text small {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--app-muted);
  margin-top: 0.1rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: none;
  border-radius: 0.75rem;
  background: transparent;
  color: var(--app-muted);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav-item:hover {
  background: #f0f0f0;
  color: var(--app-text);
}

.sidebar-nav-item.is-active {
  background: var(--app-accent-soft);
  color: var(--app-accent);
  font-weight: 600;
}

.sidebar-nav-item.is-active svg {
  opacity: 1;
  stroke: var(--app-accent);
}

.sidebar-nav-item--platform {
  font-size: 0.8125rem;
  opacity: 0.72;
}

html.platform-admin .sidebar-nav-item--platform:not(.hidden) {
  opacity: 1;
}

.sidebar-nav-item--platform.is-active {
  background: #f4f0ff;
  color: #5b21b6;
}

.sidebar-nav-item--platform.is-active svg {
  stroke: #5b21b6;
}

.sidebar-bottom-group {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid #ececec;
}

.sidebar-bottom-group .sidebar-nav-item {
  margin-top: 0.35rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.5rem 0.65rem;
  min-width: 0;
}

.sidebar-user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.sidebar-user-email {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--app-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-role {
  font-size: 0.6875rem;
  color: var(--app-muted);
}

/* Settings — full-width layout + overview strip */
.settings-overview {
  margin-bottom: 1.35rem;
}

@media (min-width: 900px) {
  .settings-overview {
    grid-template-columns: repeat(3, 1fr);
  }
}

.settings-overview-card .stat-value {
  font-size: clamp(0.9rem, 1.5vw, 1.1rem);
  line-height: 1.25;
  word-break: break-word;
}

.settings-overview-avatar {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 0.75rem;
}

.settings-layout {
  display: grid;
  gap: 1.25rem;
  align-items: start;
}

@media (min-width: 1024px) {
  .settings-layout {
    grid-template-columns: minmax(0, 1fr) 17.5rem;
  }
}

.settings-card {
  min-width: 0;
}

.settings-card-body {
  padding: 0 1.25rem 0.5rem;
}

.settings-stack {
  display: flex;
  flex-direction: column;
}

.settings-row {
  display: grid;
  gap: 1rem 1.75rem;
  padding: 1.35rem 0;
  border-bottom: 1px solid #ececec;
}

.settings-row:last-child {
  border-bottom: none;
}

@media (min-width: 768px) {
  .settings-row {
    grid-template-columns: minmax(11rem, 16rem) minmax(0, 1fr);
    align-items: start;
  }
}

.settings-row-aside h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
  color: var(--app-text);
}

.settings-row-aside .muted {
  font-size: 0.8125rem;
  line-height: 1.5;
  margin: 0;
}

.settings-fields {
  display: grid;
  gap: 0;
}

@media (min-width: 520px) {
  .settings-fields--2 {
    grid-template-columns: 1fr 1fr;
    gap: 0 1.25rem;
  }
}

@media (min-width: 900px) {
  .settings-fields--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
  }
}

.settings-fields .field-label {
  color: var(--app-text);
}

.settings-readonly {
  margin-bottom: 0;
  background: var(--surface-2);
  border-color: var(--border);
  font-size: 0.9375rem;
  cursor: default;
  user-select: text;
}

.settings-readonly--mono {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.settings-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .settings-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.settings-links li {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.settings-links a {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--navy-muted);
  text-decoration: none;
}

.settings-links a:hover {
  color: var(--app-accent);
}

.settings-links-meta {
  font-size: 0.75rem;
  color: var(--text-soft);
}

.settings-row-body--actions {
  display: flex;
  align-items: flex-start;
}

.btn-logout-settings {
  border-color: #e8c4c4;
  color: var(--danger);
}

.btn-logout-settings:hover {
  background: var(--danger-bg);
  border-color: #d4a0a0;
  color: var(--danger);
}

.settings-rail {
  position: sticky;
  top: 1rem;
}

.settings-rail-body {
  padding: 1rem 1.25rem 1.25rem;
}

.settings-rail-lead {
  margin: 0 0 1.15rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--app-muted);
}

.settings-rail-dl {
  margin: 0 0 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.settings-rail-dl > div {
  display: grid;
  gap: 0.2rem;
}

.settings-rail-dl dt {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin: 0;
}

.settings-rail-dl dd {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--app-text);
  word-break: break-word;
}

.settings-rail-foot {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.settings-rail-foot a {
  color: var(--app-accent);
  font-weight: 600;
  text-decoration: none;
}

.settings-rail-foot a:hover {
  text-decoration: underline;
}

.main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  min-height: 3.25rem;
  padding: 0 0.5rem;
  padding-top: max(0, env(safe-area-inset-top));
  background: var(--app-bg);
  border-bottom: 1px solid #ececec;
  position: sticky;
  top: 0;
  z-index: 30;
}

@media (min-width: 768px) {
  .topbar {
    display: none;
  }
}

.btn-hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--app-text);
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.btn-hamburger:hover {
  background: #f0f0f0;
}

@media (min-width: 768px) {
  .btn-hamburger {
    display: none;
  }
}

.hamburger-icon {
  display: block;
}

.hamburger-line {
  transition: transform 0.2s var(--ease), opacity 0.2s;
  transform-origin: center;
}

body.mobile-nav-open .hamburger-line--top {
  transform: translateY(5px) rotate(45deg);
}

body.mobile-nav-open .hamburger-line--mid {
  opacity: 0;
}

body.mobile-nav-open .hamburger-line--bot {
  transform: translateY(-5px) rotate(-45deg);
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--app-accent-soft);
  color: var(--app-accent);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-ghost {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  color: var(--navy);
  background: var(--surface-2);
}

.app-main {
  flex: 1;
  padding: 1rem 1rem 2rem;
  background: var(--app-bg);
}

@media (min-width: 768px) {
  .app-main {
    padding: 1.5rem 1.75rem 2rem;
  }
}

.panel {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.page-header {
  margin-bottom: 1.25rem;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.5vw, 1.65rem);
  font-weight: 700;
  margin: 0 0 0.35rem;
  letter-spacing: -0.03em;
  color: var(--app-text);
}

.dash-greeting {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.dash-hello {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
  color: var(--app-text);
}

.dash-greeting-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.65rem;
}

.dash-date {
  font-size: 0.8125rem;
  color: var(--app-muted);
  white-space: nowrap;
}

.dashboard-grid {
  display: block;
}

@media (min-width: 1100px) {
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 17.5rem;
    gap: 1.25rem;
    align-items: start;
  }
}

.dashboard-rail {
  position: sticky;
  top: 1rem;
}

.rail-placeholder {
  padding: 1.25rem;
  background: #fafafa;
  border: 1px dashed #ddd;
  border-radius: var(--app-radius);
  text-align: center;
}

.rail-placeholder-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--app-text);
}

.rail-placeholder-text {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--app-muted);
}

.page-header .muted {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin: 0;
  max-width: 36rem;
}

.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.dash-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.35rem;
}

@media (min-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: var(--app-radius);
  padding: 1rem 1.1rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.stat-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon--blue {
  background: rgba(91, 127, 212, 0.15);
  color: var(--app-accent);
}

.stat-icon--green {
  background: rgba(13, 122, 78, 0.12);
  color: var(--success);
}

.stat-icon--violet {
  background: rgba(120, 90, 200, 0.12);
  color: #6b4fc7;
}

.stat-icon--amber {
  background: rgba(200, 140, 40, 0.12);
  color: #9b6829;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--app-muted);
  margin: 0 0 0.2rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--app-text);
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.card {
  background: #fff;
  border: 1px solid #ececec;
  border-radius: var(--app-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  overflow: hidden;
}

.card-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #ececec;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--app-text);
}

.card-head--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-head-hint {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--app-muted);
}

.card-foot {
  padding: 1.25rem 1rem;
  margin: 0;
  text-align: center;
  font-size: 0.875rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th,
td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background 0.12s;
}

tbody tr:hover {
  background: var(--surface-2);
}

th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--app-muted);
  background: #fafafa;
}

td strong {
  font-weight: 600;
  color: var(--navy);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.badge.on {
  background: var(--success-bg);
  color: var(--success);
}

.badge.off {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.role {
  background: var(--surface-3);
  color: var(--text-muted);
}

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.75rem;
  min-height: 14rem;
}

.card .empty-state {
  border-top: 1px solid #ececec;
}

.empty-state-icon {
  width: 3.25rem;
  height: 3.25rem;
  margin: 0 0 1rem;
  border-radius: 50%;
  background: var(--app-accent-soft);
  color: var(--app-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: var(--app-text);
}

.empty-state-desc {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--app-muted);
  max-width: 22rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.6rem 1.15rem;
  border-radius: 999px;
  border: none;
  background: var(--app-accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover:not(:disabled) {
  background: #4a6bc4;
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: var(--navy-muted);
  color: var(--navy);
}

.btn-link {
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--navy-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.btn-link:hover {
  background: var(--app-accent-soft);
  color: var(--app-accent);
}

.col-actions {
  text-align: right;
  white-space: nowrap;
}

.col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text-muted);
}

.col-num.is-hot {
  color: var(--navy);
  font-weight: 600;
}

.create-panel {
  margin-bottom: 1.25rem;
  padding: 1.35rem 1.25rem;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: var(--app-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.create-panel h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  color: var(--navy);
}

.create-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

@media (max-width: 640px) {
  .create-grid {
    grid-template-columns: 1fr;
  }
}

.create-grid .full {
  grid-column: 1 / -1;
}

.create-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

textarea.text-input {
  resize: vertical;
  min-height: 4rem;
}

.label-hint {
  font-weight: 400;
  color: var(--text-soft);
}

select.text-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c5a78' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}

.secret-banner {
  margin-bottom: 1.25rem;
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius-md);
  background: var(--gold-soft);
  border: 1px solid var(--border-strong);
}

.secret-banner-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9375rem;
  margin: 0 0 0.25rem;
  color: var(--navy);
}

.secret-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.65rem 0;
}

.secret-code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  word-break: break-all;
  flex: 1;
  min-width: 12rem;
  padding: 0.55rem 0.7rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  margin: 0.4rem 0;
  cursor: pointer;
  color: var(--text-muted);
}

.section-sub {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 1.5rem 0 0.75rem;
  color: var(--navy);
}

.activity-panel {
  margin-top: 0;
  padding: 1.15rem 1.2rem;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: var(--app-radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

@media (max-width: 1099px) {
  .activity-panel:not(.hidden) {
    margin-top: 1.25rem;
  }

  .dashboard-rail {
    position: static;
  }
}

.activity-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.activity-head h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  margin: 0;
  color: var(--app-text);
}

.activity-list {
  list-style: none;
  margin: 0.85rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.activity-msg {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: 0.875rem;
  border: 1px solid var(--border);
}

.activity-msg--user {
  border-left: 3px solid var(--gold);
}

.activity-msg--assistant {
  border-left: 3px solid var(--navy-muted);
}

.activity-meta {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-soft);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.activity-msg p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  line-height: 1.45;
}

.dash-head code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  padding: 0.1em 0.35em;
  background: var(--surface-3);
  border-radius: 4px;
}

/* ── Mobile ── */
.topbar {
  padding-left: max(0.75rem, env(safe-area-inset-left));
  padding-right: max(0.75rem, env(safe-area-inset-right));
}

.app-main {
  padding-left: max(0.85rem, env(safe-area-inset-left));
  padding-right: max(0.85rem, env(safe-area-inset-right));
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}

@media (max-width: 767px) {
  .dash-greeting {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    margin-bottom: 1.15rem;
  }

  .dash-greeting-meta {
    align-items: stretch;
    width: 100%;
  }

  .dash-greeting-meta .btn-primary {
    width: 100%;
    justify-content: center;
    min-height: 2.75rem;
  }

  .dash-hello {
    font-size: 1.45rem;
  }

  .page-header h1 {
    font-size: 1.35rem;
  }

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

  .settings-rail {
    position: static;
  }

  .settings-overview .stat-value {
    font-size: 0.95rem;
  }

  .card-head--row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }

  .dashboard-rail {
    margin-top: 0.5rem;
  }
}

@media (max-width: 639px) {
  .dash-head {
    flex-direction: column;
    align-items: stretch;
  }

  .dash-actions {
    width: 100%;
  }

  .dash-actions .btn-primary {
    width: 100%;
    min-height: 2.75rem;
  }

  .stat-card {
    padding: 0.85rem 0.95rem;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .btn-ghost,
  .btn-primary,
  .btn-secondary {
    min-height: 2.75rem;
  }

  .btn-link {
    min-height: 2.5rem;
    padding: 0.5rem 0.65rem;
  }

  .activity-head {
    flex-direction: column;
    align-items: stretch;
  }

  .activity-head .btn-secondary {
    width: 100%;
  }

  .secret-row {
    flex-direction: column;
    align-items: stretch;
  }

  .secret-code {
    min-width: 0;
  }

  .create-actions .btn-primary,
  .create-actions .btn-ghost {
    flex: 1;
    min-width: calc(50% - 0.25rem);
  }
}

@media (max-width: 767px) {
  .table-wrap {
    overflow-x: visible;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody tr {
    display: block;
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border);
  }

  .data-table tbody tr:last-child {
    border-bottom: none;
  }

  .data-table tbody tr:hover {
    background: var(--surface);
  }

  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: none;
    text-align: right;
  }

  .data-table td::before {
    content: attr(data-label);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-soft);
    text-align: left;
    flex-shrink: 0;
    max-width: 42%;
  }

  .data-table td[data-label=""]::before,
  .data-table td:not([data-label])::before {
    display: none;
  }

  .data-table td strong {
    text-align: right;
  }

  .data-table td.col-num {
    font-variant-numeric: tabular-nums;
  }

  .data-table td.col-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
    padding-top: 0.75rem;
    margin-top: 0.35rem;
    border-top: 1px solid var(--border);
  }

  .data-table td.col-actions::before {
    display: none;
  }
}

.platform-slug {
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.text-input--compact {
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  min-width: 7rem;
}

.badge.master {
  margin-left: 0.35rem;
  background: #ede9fe;
  color: #5b21b6;
  font-size: 0.6875rem;
  vertical-align: middle;
}

.platform-creds-dl {
  margin: 0.75rem 0 1rem;
  display: grid;
  gap: 0.65rem;
}

.platform-creds-dl dt {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--app-muted);
  margin-bottom: 0.2rem;
}

.platform-creds-dl dd {
  margin: 0;
}

/* ── Platform admin (master-detail, viewport-fit) ── */
html.platform-view-active,
html.platform-view-active body {
  height: 100%;
  overflow: hidden;
}

html.platform-view-active .app-layout {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

html.platform-view-active .main-column {
  min-height: 0;
  overflow: hidden;
}

html.platform-view-active .app-main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 1rem;
}

.panel--platform {
  max-width: none;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.platform-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
  margin-bottom: 0.65rem;
}

.platform-header-main {
  min-width: 0;
}

.platform-crumb {
  font-size: 0.75rem;
  margin: 0 0 0.15rem;
}

.platform-crumb-sep {
  margin: 0 0.35rem;
  opacity: 0.5;
}

.platform-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
  color: var(--text);
  line-height: 1.2;
}

.platform-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-primary--compact {
  padding: 0.5rem 0.9rem;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.platform-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 11.5rem;
}

.platform-search-wrap svg {
  color: var(--text-soft);
  flex-shrink: 0;
}

.platform-search {
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  width: 100%;
  min-width: 0;
  color: var(--text);
}

.platform-kpis {
  margin-bottom: 0.65rem;
  flex-shrink: 0;
}

.panel--platform .platform-kpis.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.panel--platform .platform-kpis .stat-card {
  padding: 0.55rem 0.75rem;
  gap: 0;
}

.panel--platform .platform-kpis .stat-label {
  font-size: 0.6875rem;
  margin-bottom: 0.1rem;
}

.panel--platform .platform-kpis .stat-value {
  font-size: 1.2rem;
  line-height: 1.1;
}

.platform-split {
  display: grid;
  grid-template-columns: minmax(13rem, 18rem) minmax(0, 1fr);
  gap: 0.65rem;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 960px) {
  html.platform-view-active,
  html.platform-view-active body {
    height: auto;
    overflow: auto;
  }

  html.platform-view-active .app-layout {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  html.platform-view-active .app-main {
    overflow: visible;
  }

  .panel--platform {
    overflow: visible;
  }

  .platform-split {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .platform-header {
    flex-wrap: wrap;
  }

  .platform-toolbar {
    width: 100%;
  }

  .platform-search-wrap {
    flex: 1;
    width: auto;
  }
}

.platform-filter-select {
  max-width: 8.5rem;
}

.platform-list.card,
.platform-detail.card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  margin-bottom: 0;
}

.platform-list .card-head {
  flex-shrink: 0;
  padding: 0.65rem 0.85rem;
}

.platform-agency-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0.35rem 0.35rem;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.platform-agency-item {
  margin-bottom: 0.25rem;
}

.platform-agency-btn {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-md);
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.platform-agency-item.is-selected .platform-agency-btn,
.platform-agency-btn:hover {
  background: var(--app-accent-soft);
  border-color: rgba(91, 127, 212, 0.2);
}

.platform-agency-item-name {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.platform-agency-item-slug {
  display: block;
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-top: 0.1rem;
}

.platform-agency-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.platform-agency-item-stat {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pill {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.pill-paid { background: var(--success-bg); color: var(--success); }
.pill-trial { background: var(--gold-soft); color: var(--gold-text); }
.pill-unpaid { background: #f3f4f6; color: var(--text-muted); }
.pill-overdue { background: var(--danger-bg); color: var(--danger); }

.platform-detail {
  min-height: 0;
}

.platform-detail-empty {
  padding: 2rem 1rem;
  text-align: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.platform-detail-empty-title {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.platform-detail-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.platform-detail-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.platform-detail-hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.65rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  align-items: center;
  flex-shrink: 0;
}

.platform-detail-hero--compact .platform-detail-avatar {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 0.8rem;
}

.platform-detail-hero--compact .platform-detail-title-row h2 {
  font-size: 1.05rem;
}

.platform-detail-hero--compact .platform-detail-slug {
  margin: 0.1rem 0 0.35rem;
  font-size: 0.75rem;
}

.platform-detail-hero--compact .platform-score strong {
  font-size: 1rem;
}

@media (max-width: 720px) {
  .platform-detail-hero {
    grid-template-columns: 1fr;
  }
}

.platform-detail-avatar {
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius-md);
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

.platform-detail-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.platform-detail-title-row h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}

.platform-detail-slug {
  margin: 0.2rem 0 0.65rem;
  font-size: 0.8125rem;
}

.platform-detail-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.platform-detail-controls .field-label {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1;
  flex-shrink: 0;
}

.platform-detail-controls .text-input {
  margin: 0;
  flex: 1;
  min-width: 0;
  max-width: 11rem;
  height: 1.875rem;
  line-height: 1.2;
}

.platform-detail-scores {
  display: flex;
  gap: 1rem;
}

.platform-score {
  text-align: center;
  min-width: 3.5rem;
}

.platform-score-label {
  display: block;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  margin-bottom: 0.15rem;
}

.platform-score strong {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.platform-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem 0.35rem;
}

.platform-section-head--team {
  padding-top: 0.35rem;
}

.platform-section-head h3 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
}

.platform-table-wrap {
  margin: 0 1rem 0.5rem;
  width: calc(100% - 2rem);
}

.platform-agents-table,
.platform-team-table {
  margin: 0;
  width: 100%;
}

.data-table--dense th,
.data-table--dense td {
  padding: 0.45rem 0.55rem;
  font-size: 0.8125rem;
}

.platform-danger-zone {
  margin: 0;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.platform-danger-hint {
  margin: 0;
  font-size: 0.75rem;
  text-align: right;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(180, 35, 24, 0.25);
  background: var(--danger-bg);
  color: var(--danger);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(180, 35, 24, 0.12);
}

.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

body.modal-open {
  overflow: hidden;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 19, 58, 0.45);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(26rem, 100%);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.35rem 1.35rem 1.15rem;
  border: 1px solid var(--border);
}

.modal-card--wide {
  width: min(32rem, 100%);
}

.modal-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-body {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal-extra {
  margin-bottom: 1rem;
}

.modal-extra .text-input.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.12);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ── Platform agent analytics ── */
.platform-agent-row {
  cursor: pointer;
  transition: background 0.12s;
}

.platform-agent-row:hover td {
  background: rgba(91, 127, 212, 0.06);
}

.platform-agent-row.is-selected td {
  background: var(--app-accent-soft);
}

.platform-agent-panel {
  margin: 0.5rem 1rem 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.platform-agent-panel-head {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.btn-agent-back {
  flex-shrink: 0;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

.platform-agent-panel-title h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.platform-agent-panel-title p {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
}

.platform-agent-kpis {
  margin-bottom: 0.65rem;
}

.platform-agent-kpis .stat-card {
  padding: 0.5rem 0.65rem;
}

.platform-agent-kpis .stat-value {
  font-size: 1.1rem;
}

.platform-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

@media (max-width: 800px) {
  .platform-charts {
    grid-template-columns: 1fr;
  }
}

.platform-chart-card {
  padding: 0.75rem 0.85rem;
  margin: 0;
  box-shadow: var(--shadow-xs);
}

.platform-chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.platform-chart-head h4 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
}

.platform-chart-sub {
  font-size: 0.6875rem;
}

.platform-bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 3px;
  height: 7.5rem;
  padding: 0.25rem 0 0;
}

.platform-bar-chart--green .bar-chart-bar,
.bar-chart-bar--green {
  background: var(--success);
  opacity: 0.85;
}

.platform-chart-empty {
  margin: 0;
  font-size: 0.8125rem;
  padding: 1.5rem 0;
  text-align: center;
}

.bar-chart-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 0.2rem;
}

.bar-chart-value {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
  min-height: 0.75rem;
}

.bar-chart-bar {
  width: 100%;
  max-width: 1.25rem;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--app-accent);
  transition: height 0.2s var(--ease);
}

.bar-chart-label {
  font-size: 0.5625rem;
  color: var(--text-soft);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.platform-role-split {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

.platform-role-chip {
  font-size: 0.6875rem;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
}

.platform-agent-recent {
  padding: 0.75rem 0.85rem;
  margin: 0;
}

.platform-agent-recent h4 {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

.platform-activity-list {
  max-height: 10rem;
  overflow-y: auto;
  margin: 0;
  padding: 0;
}
