:root {
  color-scheme: light;
  --page: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f3f6fa;
  --ink: #101828;
  --muted: #667085;
  --muted-strong: #48566f;
  --line: #d8e1ee;
  --line-soft: #edf2f7;
  --accent: #0f3768;
  --accent-press: #0a2a51;
  --accent-soft: #e8f1fb;
  --accent-tint: #f3f7fc;
  --gold: #b88722;
  --gold-soft: #fbf3dd;
  --danger: #b42318;
  --success: #157347;
  --shadow: 0 18px 50px rgba(15, 55, 104, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--page);
  color: var(--ink);
}

body {
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

[hidden] {
  display: none !important;
}

.app-shell {
  min-height: 100dvh;
  background: var(--page);
}

.auth-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(320px, 420px);
  gap: 48px;
  align-items: center;
  padding: clamp(24px, 5vw, 64px);
  justify-content: center;
  background:
    linear-gradient(120deg, rgba(15, 55, 104, 0.045), transparent 34%),
    var(--surface);
}

.auth-brand {
  position: fixed;
  top: 24px;
  left: clamp(20px, 5vw, 56px);
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 17px;
}

.auth-brand strong,
.sidebar-header strong {
  color: var(--accent);
}

.auth-brand span,
.sidebar-header small,
.content-header span {
  color: var(--muted);
  font-size: 13px;
}

.auth-copy {
  max-width: 560px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.auth-copy h1,
.detail-empty h2,
.product-heading h2,
.settings-panel h2,
.notification-panel h2,
.offline-panel h2 {
  margin: 0;
  line-height: 1.04;
  font-weight: 760;
}

.auth-copy h1 {
  max-width: 13ch;
  font-size: 50px;
}

.auth-copy p:not(.eyebrow),
.detail-empty p,
.notification-panel p,
.offline-panel p,
.product-heading p {
  margin: 18px 0 0;
  max-width: 52ch;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.auth-panel {
  display: grid;
  gap: 15px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 16px 44px rgba(16, 24, 40, 0.08);
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.segmented-control button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segmented-control button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(16, 24, 40, 0.08);
}

.auth-panel-copy {
  display: grid;
  gap: 5px;
}

.auth-panel-copy h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
}

.auth-panel-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.claim-notice {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid rgba(15, 55, 104, 0.16);
  border-radius: 10px;
  background: var(--accent-soft);
}

.claim-notice strong {
  color: var(--accent);
  font-size: 13px;
}

.claim-notice span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.field,
.claim-strip label,
.search-field {
  display: grid;
  gap: 7px;
}

.field span,
.claim-strip span,
.field small {
  color: var(--muted);
  font-size: 13px;
}

.field span,
.claim-strip span {
  font-weight: 700;
}

.field input,
.claim-strip input,
.search-field input {
  width: 100%;
  min-width: 0;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.field input:focus,
.claim-strip input:focus,
.search-field input:focus {
  border-color: rgba(15, 55, 104, 0.45);
  box-shadow: 0 0 0 3px rgba(15, 55, 104, 0.08);
}

.primary-action,
.secondary-action,
.danger-action,
.claim-strip button,
.text-button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 750;
}

.primary-action,
.claim-strip button {
  border: 0;
  background: var(--accent);
  color: white;
}

.primary-action:active,
.claim-strip button:active {
  background: var(--accent-press);
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.danger-action,
.text-button {
  border: 0;
  background: transparent;
}

.danger-action {
  color: var(--danger);
}

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

.inline-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.inline-status[data-tone="error"] {
  color: var(--danger);
}

.inline-status[data-tone="success"] {
  color: var(--success);
}

.workspace-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(308px, 368px) minmax(0, 1fr);
  background: var(--surface);
}

.sidebar {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-right: 1px solid var(--line);
  background: #f8fafc;
  padding: 16px;
  overflow-y: auto;
}

.sidebar-header,
.content-header,
.product-heading,
.product-actions,
.permission-row,
.settings-row {
  display: flex;
  align-items: center;
}

.sidebar-header,
.content-header {
  justify-content: space-between;
  gap: 14px;
}

.sidebar-header div,
.content-header div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-lockup {
  display: flex !important;
  align-items: center;
  gap: 10px;
}

.brand-lockup > span:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-lockup small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 800;
}

.content-header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.claim-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.claim-strip input {
  height: 44px;
  border-color: var(--line);
  background: var(--surface);
}

.claim-strip button {
  min-height: 44px;
  padding-inline: 16px;
}

.claim-strip span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.sidebar-section-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-height: 22px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

.sidebar-section-heading small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: none;
}

.search-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
}

.search-field .icon {
  width: 17px;
  height: 17px;
}

.search-field input {
  height: auto;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.search-field input:focus {
  box-shadow: none;
}

.access-summary {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(184, 135, 34, 0.22);
  border-radius: 10px;
  background: rgba(184, 135, 34, 0.08);
}

.access-summary[hidden] {
  display: none;
}

.access-summary strong {
  color: var(--ink);
  font-size: 13px;
}

.access-summary span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.area-tabs {
  display: grid;
  gap: 2px;
}

.area-tabs button {
  display: grid;
  gap: 3px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
}

.area-tabs button.is-active {
  background: var(--accent-tint);
  box-shadow: inset 3px 0 0 var(--accent);
}

.area-tabs span {
  color: var(--muted);
  font-size: 12px;
}

.product-list {
  display: grid;
  gap: 4px;
}

.product-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 7px 8px;
  text-align: left;
}

.product-row:hover,
.product-row.is-selected {
  background: rgba(15, 55, 104, 0.04);
}

.product-row-avatar,
.product-avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--accent);
  font-weight: 760;
}

.product-row-avatar {
  width: 36px;
  height: 36px;
  font-size: 14px;
}

.product-row-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.product-row-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.product-row-copy small,
.product-row em {
  color: var(--muted);
  font-size: 12px;
}

.product-row em {
  font-style: normal;
}

.product-row[data-access="owned"] em {
  color: var(--success);
}

.product-row[data-access="locked"] em,
.product-row[data-access="claim_required"] em {
  color: var(--gold);
}

.product-row[data-access="inactive"] em {
  color: var(--muted);
}

.empty-access,
.list-empty {
  padding: 18px 0;
  color: var(--muted);
}

.empty-access h2 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.12;
}

.empty-access p:not(.eyebrow) {
  margin: 8px 0 0;
  line-height: 1.45;
}

.content-surface {
  min-width: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 18px clamp(30px, 5vw, 64px);
}

.content-header {
  min-height: 50px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.mobile-only {
  display: none;
}

.inline-alert {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff5f3;
  color: var(--danger);
  font-size: 14px;
}

.inline-alert[data-tone="success"] {
  background: #eef8f2;
  color: var(--success);
}

.inline-alert[data-tone="muted"] {
  background: var(--surface-soft);
  color: var(--muted);
}

.inline-alert button {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 750;
  padding: 0 8px;
}

.detail-empty,
.product-detail,
.settings-panel,
.notification-panel,
.offline-panel {
  width: 100%;
  max-width: 860px;
  margin: 0;
  padding: 30px 0;
}

.detail-empty {
  align-self: center;
  margin: 0 auto;
}

.detail-empty h2,
.settings-panel h2,
.notification-panel h2,
.offline-panel h2 {
  font-size: 34px;
}

.product-heading {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: start;
  gap: 18px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.product-heading > div {
  flex: 1;
  min-width: 0;
}

.product-avatar {
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  font-size: 18px;
}

.product-heading h2 {
  font-size: 30px;
}

.access-help {
  margin-top: 10px !important;
  max-width: 58ch !important;
  font-size: 14px !important;
}

.access-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.access-badge[data-access="owned"] {
  background: #eef8f2;
  color: var(--success);
}

.access-badge[data-access="locked"],
.access-badge[data-access="claim_required"] {
  background: var(--gold-soft);
  color: var(--gold);
}

.access-badge[data-access="inactive"] {
  background: var(--surface-soft);
  color: var(--muted);
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
  border: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
}

.product-meta div {
  display: grid;
  gap: 5px;
  min-height: 58px;
  min-width: 150px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: #fbfcfe;
}

.product-meta span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.product-meta strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-actions {
  gap: 10px;
  padding: 18px 0 0;
}

.product-detail[data-chat-open="true"] {
  max-width: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 0 0;
}

.product-detail[data-chat-open="true"] .product-heading,
.product-detail[data-chat-open="true"] .product-meta,
.product-detail[data-chat-open="true"] .product-actions {
  display: none;
}

.product-detail[data-chat-open="true"] .webchat-host {
  flex: 1;
  height: calc(100dvh - 102px);
  min-height: 560px;
}

.content-header .text-button {
  min-height: 44px;
  font-size: 14px;
}

.chat-status {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.webchat-host {
  height: calc(100dvh - 210px);
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.settings-list {
  display: grid;
  max-width: 620px;
  border-top: 1px solid var(--line);
}

.settings-row,
.permission-row {
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.settings-row span,
.permission-row span {
  color: var(--muted);
}

.settings-row strong,
.permission-row strong {
  overflow-wrap: anywhere;
  text-align: right;
}

.notification-panel,
.offline-panel {
  max-width: 620px;
}

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

@media (max-width: 900px) {
  .auth-shell {
    grid-template-columns: 1fr;
    gap: 16px;
    align-content: start;
    align-items: start;
    padding: 58px 18px 14px;
  }

  .auth-brand {
    top: 18px;
    left: 18px;
  }

  .auth-copy h1 {
    max-width: 13ch;
    font-size: 30px;
  }

  .auth-copy p:not(.eyebrow) {
    margin-top: 10px;
    font-size: 15px;
  }

  .auth-panel {
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    box-shadow: none;
  }

  .auth-panel-copy h2 {
    font-size: 19px;
  }

  .auth-panel-copy p,
  .field small {
    font-size: 13px;
  }

  .field,
  .claim-strip label,
  .search-field {
    gap: 5px;
  }

  .field input {
    height: 44px;
  }

  .workspace-shell {
    display: block;
    min-height: 100dvh;
  }

  .workspace-shell[data-mobile-view="list"] .content-surface,
  .workspace-shell[data-mobile-view="detail"] .sidebar {
    display: none;
  }

  .sidebar {
    min-height: 100dvh;
    max-height: 100dvh;
    border-right: 0;
    border-bottom: 0;
    gap: 9px;
    padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
  }

  .content-surface {
    min-height: 100dvh;
    padding: calc(12px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  .mobile-only {
    display: inline-grid;
  }

  .content-header {
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
  }

  .detail-empty,
  .product-detail,
  .settings-panel,
  .notification-panel,
  .offline-panel {
    max-width: none;
    padding: 18px 0;
  }

  .product-heading {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px;
    padding-bottom: 16px;
  }

  .product-heading h2,
  .detail-empty h2,
    .settings-panel h2,
    .notification-panel h2,
    .offline-panel h2 {
    font-size: 22px;
  }

  .product-heading p:not(.eyebrow),
  .product-heading .access-help {
    margin-top: 10px !important;
    font-size: 14px !important;
    line-height: 1.45;
  }

  .product-avatar {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }

  .product-meta {
    display: grid;
    grid-template-columns: 1fr;
    margin-top: 14px;
  }

  .product-meta div {
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: center;
    min-height: 46px;
    min-width: 0;
    padding: 10px 12px;
  }

  .product-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 0 0;
  }

  .primary-action,
  .secondary-action,
  .danger-action,
  .claim-strip button,
  .text-button {
    font-size: 15px;
  }

  .webchat-host {
    height: calc(100dvh - 164px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-height: 360px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    margin-right: -14px;
    margin-left: -14px;
  }

  .product-detail[data-chat-open="true"] {
    padding-top: 10px;
  }

  .product-detail[data-chat-open="true"] .webchat-host {
    height: calc(100dvh - 74px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-height: 0;
  }
}

@media (max-width: 420px) {
  .sidebar-header strong {
    font-size: 16px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .claim-strip {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .claim-strip button {
    min-width: 92px;
  }

  .area-tabs button {
    min-height: 50px;
  }

  .product-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    min-height: 56px;
  }

  .product-row-avatar {
    width: 34px;
    height: 34px;
  }

  .product-row em {
    justify-self: end;
    font-size: 12px;
  }

  .content-header .text-button {
    font-size: 13px;
    padding-inline: 8px;
  }
}
