:root {
  --ds-bg: #f3f5fb;
  --ds-surface: #ffffff;
  --ds-surface-muted: #f8fafc;
  --ds-text: #111827;
  --ds-text-muted: #6b7280;
  --ds-border: #e5e7eb;
  --ds-line: #edf0f5;
  --ds-blue: #2563eb;
  --ds-blue-soft: #ebf2ff;
  --ds-success: #0d9b73;
  --ds-warning: #b45309;
  --ds-danger: #dc2626;
  --ds-card-shadow: 0 10px 25px rgb(15 23 42 / 10%);
  --ds-radius: 14px;
  --ds-radius-sm: 10px;
  --ds-sidebar-width: 270px;
  --ds-sidebar-bg: #454b52;
  --ds-sidebar-surface: #505760;
  --ds-sidebar-hover: #59616b;
  --ds-sidebar-text: #f5f7f9;
  --ds-sidebar-text-muted: #d0d5da;
  --ds-sidebar-divider: #646c75;
}

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

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

body.platform-system {
  margin: 0;
  background: radial-gradient(circle at 0% 0%, #f8fbff, var(--ds-bg) 45%, #eef2ff 100%);
  color: var(--ds-text);
  font-family: Inter, "SF Pro Text", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.platform-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--ds-sidebar-width) minmax(0, 1fr);
  gap: 0;
}

.platform-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--ds-sidebar-bg);
  color: var(--ds-sidebar-text);
  border-right: 1px solid var(--ds-sidebar-divider);
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.platform-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ds-sidebar-divider);
}

.platform-sidebar .platform-brand {
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
}

a.platform-brand {
  color: inherit;
  text-decoration: none;
}

a.platform-brand:hover .platform-brand-title {
  color: #fff;
}

a.platform-brand:focus-visible,
.platform-public-site-link:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 3px;
  border-radius: 5px;
}

.platform-brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1d4ed8, #06b6d4);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
}

.platform-sidebar .platform-brand-logo {
  width: min(100%, 196px);
  height: auto;
  padding: 7px 10px;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 9px;
  background: rgb(255 255 255 / 96%);
  box-sizing: border-box;
  display: block;
  font-size: 0;
}

.platform-brand-image-frame {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1296 / 272;
  overflow: hidden;
}

.platform-brand-image-frame img {
  position: absolute;
  top: -150%;
  left: -6.17284%;
  display: block;
  width: 111.728395%;
  max-width: none;
  height: auto;
}

.platform-brand-title {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.platform-brand-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.platform-brand-copy:has(.platform-brand-title[hidden]) {
  display: block;
}

.platform-brand-tagline {
  margin: 0;
  color: var(--ds-text-muted);
  font-size: 10px;
  line-height: 1.25;
}

.platform-sidebar .platform-brand-tagline {
  color: var(--ds-sidebar-text-muted);
}

.company-switcher {
  margin: 0 0 14px;
  padding: 11px 12px;
  border: 1px solid var(--ds-sidebar-divider);
  border-radius: 11px;
  background: var(--ds-sidebar-surface);
}

.company-switcher[hidden],
.company-switcher [hidden] {
  display: none;
}

.company-switcher strong,
.company-switcher select {
  width: 100%;
  color: var(--ds-sidebar-text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.company-switcher strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-switcher select {
  border: 0;
  padding: 0 20px 0 0;
  outline: none;
  background: transparent;
  cursor: pointer;
}

.company-switcher select option {
  color: #111827;
}

.platform-workspace-mode {
  display: grid;
  gap: 3px;
  padding: 3px;
  margin: -4px 0 10px;
  border: 1px solid var(--ds-sidebar-divider);
  border-radius: 10px;
  background: var(--ds-sidebar-surface);
}

.platform-workspace-mode a {
  display: block;
  padding: 8px 9px;
  border-radius: 7px;
  color: var(--ds-sidebar-text-muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  transition: color 150ms ease, background 150ms ease;
}

.platform-workspace-mode strong {
  display: block;
  padding: 8px 9px 5px;
  color: var(--ds-sidebar-text);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.35;
  text-align: center;
}

.platform-workspace-mode a:hover {
  color: var(--ds-sidebar-text);
  background: var(--ds-sidebar-hover);
}

.platform-workspace-mode .platform-admin-link {
  color: #f8fbff;
  background: #2563eb;
  box-shadow: inset 0 0 0 1px rgb(147 197 253 / 42%);
}

.platform-workspace-mode .platform-admin-link:hover {
  color: #fff;
  background: #1d4ed8;
}

.platform-workspace-mode a.active,
.platform-workspace-mode a[aria-current="page"] {
  color: #fff;
  background: #2563eb;
  box-shadow: inset 0 0 0 1px rgb(147 197 253 / 42%);
}

.platform-workspace-mode.platform-customer-mode {
  margin: 0 0 10px;
  padding: 0;
  border: 0;
  background: transparent;
}

.platform-workspace-mode.platform-customer-mode .platform-admin-link {
  padding: 9px 11px;
  border: 1px solid rgb(147 197 253 / 45%);
}

.owner-back-link {
  display: inline-flex;
  margin: 0 0 8px;
  color: var(--ds-blue);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.owner-back-link:hover {
  text-decoration: underline;
}

.platform-nav {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.platform-nav a {
  position: relative;
  color: var(--ds-sidebar-text);
  text-decoration: none;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px;
  display: block;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.platform-nav a[hidden] {
  display: none;
}

.platform-nav a:hover {
  color: #fff;
  background: var(--ds-sidebar-hover);
}

.platform-nav a.active,
.platform-nav a[aria-current="page"],
.platform-nav a.active:hover,
.platform-nav a[aria-current="page"]:hover {
  color: #fff;
  background: #2563eb;
  box-shadow: inset 0 0 0 1px rgb(147 197 253 / 42%);
  font-weight: 700;
}

.platform-nav a.active::before,
.platform-nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 3px;
  border-radius: 0 999px 999px 0;
  background: #bfdbfe;
}

.platform-sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--ds-sidebar-divider);
  display: grid;
  gap: 8px;
}

.platform-sidebar-footer > .btn {
  width: 100%;
  text-align: center;
}

.platform-public-site-link {
  width: fit-content;
  color: var(--ds-sidebar-text-muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  text-decoration: none;
}

.platform-public-site-link:hover {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.platform-user-block {
  display: grid;
  gap: 2px;
  padding-bottom: 12px;
}

.platform-user-name {
  font-weight: 600;
  font-size: 14px;
  margin: 0;
}

.platform-user-company {
  color: var(--ds-sidebar-text-muted);
  margin: 0;
  font-size: 12px;
}

.language-switch {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: var(--ds-sidebar-surface);
}

.language-switch-button {
  appearance: none;
  border: 0;
  border-radius: 7px;
  padding: 6px 8px;
  color: var(--ds-sidebar-text-muted);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 650;
}

.language-switch-button.active {
  color: #0f172a;
  background: #ffffff;
  box-shadow: 0 1px 3px rgb(15 23 42 / 18%);
}

.platform-sidebar-footer .language-switch {
  margin: 0;
  width: max-content;
}

.platform-sidebar-footer > .btn-outline {
  color: var(--ds-sidebar-text);
  background: var(--ds-sidebar-surface);
  border-color: var(--ds-sidebar-divider);
}

.platform-sidebar-footer > .btn-outline:hover {
  color: #fff;
  background: var(--ds-sidebar-hover);
  border-color: #67717b;
}

.platform-main {
  padding: 18px;
  min-width: 0;
}

.platform-topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.platform-topbar h1 {
  margin: 0;
  font-size: 27px;
  letter-spacing: -0.02em;
}

.platform-topbar p {
  margin: 5px 0 0;
  color: var(--ds-text-muted);
  font-size: 13px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.btn-primary {
  color: #f8fafc;
  background: var(--ds-blue);
}

.btn-outline {
  color: #0f172a;
  background: #ffffff;
  border-color: var(--ds-border);
}

.btn-danger {
  color: #fff1f2;
  background: #dc2626;
}

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

.panel {
  background: var(--ds-surface);
  border: 1px solid var(--ds-line);
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-card-shadow);
  padding: 14px;
}

.panel h2,
.panel h3 {
  margin: 0 0 10px;
}

.panel-head p {
  color: var(--ds-text-muted);
  margin: 0;
  font-size: 13px;
}

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

.kpi-card {
  border: 1px solid var(--ds-line);
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #fbfdff, #f8fafc);
}

.kpi-value {
  margin: 6px 0 0;
  font-size: 27px;
  letter-spacing: -0.025em;
  font-weight: 760;
}

.kpi-label {
  color: var(--ds-text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.list-row {
  padding: 12px;
  border: 1px solid var(--ds-line);
  border-radius: 11px;
  background: var(--ds-surface-muted);
}

.list-row h4,
.list-row h5 {
  margin: 0;
  font-size: 14px;
}

.list-row p {
  margin: 6px 0 0;
  color: var(--ds-text-muted);
  font-size: 12px;
}

.list-row .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.badge {
  border-radius: 999px;
  padding: 4px 9px;
  border: 1px solid var(--ds-line);
  font-size: 11px;
  color: var(--ds-text-muted);
  background: white;
}

.badge-ok {
  color: var(--ds-success);
  border-color: #dcfce7;
  background: #f0fdf4;
}

.badge-warn {
  color: var(--ds-warning);
  border-color: #fde68a;
  background: #fffbeb;
}

.badge-alert {
  color: var(--ds-danger);
  border-color: #fecaca;
  background: #fef2f2;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.agent-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 11px;
  border: 1px solid var(--ds-line);
  background: #f8fbff;
}

.agent-url {
  color: var(--ds-blue);
  text-decoration: none;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.lead-card {
  border: 1px dashed var(--ds-border);
  border-radius: 11px;
  padding: 12px;
  background: #fdfcff;
}

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

  .platform-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--ds-sidebar-divider);
  }

  .platform-sidebar,
  .platform-main {
    padding: 14px;
  }

  .platform-main {
    padding-top: 16px;
  }
}

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

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column {
    grid-template-columns: 1fr;
  }

  .platform-topbar h1 {
    font-size: 22px;
  }
}
:root .platform-profile-link { display: block; text-decoration: none; color: inherit; cursor: pointer; text-underline-offset: 4px; }
:root .platform-profile-link:hover { text-decoration: underline; }
:root .platform-profile-link:focus-visible { outline: 2px solid #93c5fd; outline-offset: 3px; border-radius: 3px; }
@media (max-width: 520px) {
  .platform-sidebar-footer:has(.platform-public-site-link) .platform-public-site-link {
    grid-column: 1 / -1;
  }

  /* Keep the profile entry reachable: legal links must not squeeze its column to zero. */
  .platform-sidebar-footer:has(.platform-profile-link) .platform-legal-links-sidebar { grid-column: 1 / -1; grid-row: 2; }
  .platform-sidebar-footer:has(.platform-public-site-link) .platform-legal-links-sidebar { grid-row: auto; }
}
