:root {
  color-scheme: light;
  --ink: #0a2540;
  --muted: #697386;
  --line: #e3e8ee;
  --panel: #ffffff;
  --page: #f7fafc;
  --soft: #eff6ff;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --green: #0e6245;
  --amber: #946200;
  --red: #b42318;
  --blue: #2563eb;
  --shadow: 0 2px 8px rgba(37, 99, 235, 0.055), 0 1px 3px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: grid;
  gap: 7px;
  min-height: 58px;
  padding: 0 6px;
}

.brand-logo {
  display: block;
  width: 178px;
  height: auto;
  max-width: 100%;
}

.brand strong,
.identity-panel strong,
.plan-panel strong {
  display: block;
}

.brand span,
.identity-panel span,
.plan-panel span {
  color: var(--muted);
  font-size: 13px;
}

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

.nav-tab {
  height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #3c4257;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 8px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
}

.nav-tab.active,
.nav-tab:hover {
  background: #f0f3ff;
  border-color: #e3e7ff;
  color: var(--brand-dark);
}

.icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: transparent;
  border: 0;
  color: #697386;
  position: relative;
}

.nav-tab.active .icon,
.nav-tab:hover .icon {
  background: #ffffff;
  color: var(--brand-dark);
}

.icon svg {
  width: 17px;
  height: 17px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.plan-panel {
  margin-top: auto;
  padding: 12px;
  border-radius: 8px;
  background: #f6f9fc;
  border: 1px solid var(--line);
}

.plan-panel strong {
  color: var(--ink);
  font-size: 18px;
  margin: 3px 0;
}

.identity-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.pfp {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  color: #ffffff;
  font-weight: 800;
  background-size: cover;
  background-position: center;
}

.main-panel {
  min-width: 0;
  padding: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
  margin-bottom: 0;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.25;
  font-weight: 700;
}

h2 {
  font-size: 15px;
  line-height: 1.35;
  font-weight: 700;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.search-input {
  width: 220px;
}

.search-wrap {
  position: relative;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  width: min(420px, 80vw);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 32px rgba(10, 37, 64, 0.16);
}

.search-results button {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
}

.search-results button:hover {
  background: var(--soft);
}

.search-results span,
.search-empty {
  color: var(--muted);
  font-size: 12px;
}

.search-empty {
  padding: 10px;
}

select,
input {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 10px;
  max-width: 100%;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.02);
}

a {
  color: var(--brand-dark);
  text-decoration: none;
}

.view {
  display: none;
}

.view.active {
  display: block;
  padding: 24px 28px;
}

.metrics-grid,
.stats-grid,
.dashboard-grid,
.admin-grid {
  display: grid;
  gap: 16px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-width: 1180px;
  margin-bottom: 16px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 16px;
  display: grid;
  gap: 6px;
}

.stat-card strong {
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.stat-card span:last-child {
  color: var(--muted);
  font-size: 13px;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.dashboard-grid {
  grid-template-columns: 1.45fr 1fr;
  max-width: 1180px;
}

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

.panel,
.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

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

.wide {
  grid-column: span 2;
}

.metric-card {
  padding: 14px;
  display: grid;
  gap: 8px;
  min-height: 112px;
}

.metric-card strong {
  font-size: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.status,
.pill,
.severity {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill {
  background: #f0f3ff;
  color: var(--brand-dark);
}

.good {
  background: #e6f4ee;
  color: var(--green);
}

.warn,
.medium {
  background: #fff8e6;
  color: var(--amber);
}

.high,
.critical {
  background: #fee4e2;
  color: var(--red);
}

.progress {
  height: 8px;
  overflow: hidden;
  background: var(--soft);
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--brand);
}

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

.method-card,
.price-card {
  min-height: 106px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  padding: 14px;
  text-align: left;
  display: grid;
  gap: 8px;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.method-card span,
.price-card span,
.price-card small {
  color: var(--muted);
  font-size: 13px;
}

.method-card.selected,
.price-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 8px 20px rgba(37, 99, 235, 0.12);
}

.method-card:not(.disabled):hover,
.price-card:hover {
  border-color: #b7b7ff;
  transform: translateY(-1px);
}

.method-card.disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

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

.price-card strong {
  color: var(--brand-dark);
  font-size: 26px;
}

.choice-stack {
  display: grid;
  gap: 10px;
}

.wizard-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 18px;
  display: grid;
  gap: 16px;
  min-height: 260px;
}

.wizard-content h3 {
  margin: 8px 0 6px;
  font-size: 20px;
  letter-spacing: 0;
}

.wizard-content p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.step-number {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--brand);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.wizard-progress {
  height: 6px;
  background: #e8eef7;
  border-radius: 999px;
  overflow: hidden;
}

.wizard-progress span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: inherit;
  transition: width 180ms ease;
}

.wizard-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.wizard-options button {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.wizard-options button.active,
.wizard-options button:hover {
  background: #ffffff;
  color: var(--brand-dark);
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 8px 20px rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

.wizard-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.wizard-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wizard-fade {
  animation: fadeQuestion 180ms ease;
}

.recommendation-card {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  background: #ffffff;
  padding: 14px;
}

.recommendation-card span {
  color: var(--muted);
  font-size: 13px;
}

@keyframes fadeQuestion {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.setup-strip,
.notice {
  margin-top: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f7fafc;
}

.setup-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
}

.notice {
  padding: 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.lock-notice {
  border-color: #f6c56f;
  background: #fffaf0;
  color: var(--amber);
  margin-bottom: 12px;
}

code {
  background: #eef2ff;
  border-radius: 5px;
  color: var(--brand-dark);
  padding: 2px 6px;
  font-size: 13px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 12px;
  font-weight: 700;
  font-size: 13px;
}

.primary-button {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.ghost-button,
.icon-button {
  background: #ffffff;
  color: var(--ink);
}

.ghost-link {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.ghost-button:hover,
.icon-button:hover {
  background: #f7fafc;
}

.danger-button {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 20px;
}

.full {
  width: 100%;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

#webhookUrl {
  width: 100%;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.upload-drop {
  min-height: 150px;
  border: 1px dashed #b7c5d8;
  border-radius: 16px;
  background: #f7fafc;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  cursor: pointer;
  text-align: center;
  padding: 20px;
}

.upload-drop span {
  color: var(--muted);
  font-size: 13px;
}

.upload-drop input {
  display: none;
}

.checkbox-list,
.check-grid {
  display: grid;
  gap: 9px;
  margin: 14px 0;
}

.with-margin {
  margin: 14px 0;
}

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

.compact-list,
.case-list {
  display: grid;
  gap: 8px;
}

.list-item,
.case-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 12px 13px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.list-item span,
.case-card span,
.meta-text {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  border: 1px dashed #b7c5d8;
  border-radius: 16px;
  background: #f7fafc;
  min-height: 128px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 20px;
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.empty-state span {
  color: var(--muted);
  font-size: 13px;
  max-width: 360px;
}

.chart-empty {
  min-height: 284px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  padding: 18px;
  display: grid;
  align-content: end;
  gap: 8px;
  overflow: hidden;
}

.chart-empty strong {
  margin-top: 12px;
}

.chart-empty > span {
  color: var(--muted);
  font-size: 13px;
}

.chart-grid {
  height: 156px;
  display: grid;
  grid-template-columns: repeat(30, minmax(2px, 1fr));
  align-items: end;
  gap: 8px;
  padding: 18px 0 8px;
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(to top, rgba(226, 232, 240, 0.75) 1px, transparent 1px);
  background-size: 100% 39px;
}

.auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 28px;
  padding: 24px;
  background: #f7fafc;
}

.auth-gate > img {
  width: min(240px, 70vw);
}

.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.auth-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.button-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fafc;
}

#restrictionForm {
  grid-template-columns: 1fr 1fr 1.4fr 1fr auto;
}

.inline-form label,
.invite-result label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.invite-result {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #f8fbff;
}

.invite-result input {
  width: 100%;
}

.invite-result > span {
  color: var(--muted);
  font-size: 12px;
}

.member-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.member-identity > div {
  display: grid;
  gap: 2px;
}

.member-identity img,
.mini-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.mini-avatar {
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--brand-dark);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: min(440px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 12px 32px rgba(10, 37, 64, 0.18);
  font-weight: 700;
}

.toast.error {
  border-color: #fecaca;
  color: var(--red);
}

.app-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(10, 37, 64, 0.24);
}

.app-dialog::backdrop {
  background: rgba(10, 37, 64, 0.34);
}

.app-dialog form {
  padding: 20px;
}

.app-dialog input {
  width: 100%;
}

.danger-panel {
  border-color: #fecaca;
}

.public-resources {
  min-height: 100vh;
  padding: 48px 24px;
  background: var(--page);
}

.public-resources main {
  width: min(760px, 100%);
  margin: 0 auto;
}

.public-resources img {
  width: 210px;
  margin-bottom: 28px;
}

.public-resources h1 {
  margin: 4px 0 22px;
  font-size: 28px;
}

.resource-public-list {
  display: grid;
  gap: 10px;
}

.resource-public-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.resource-public-item span {
  color: var(--muted);
  font-size: 13px;
}

.chart-grid span {
  display: block;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.55), rgba(37, 99, 235, 0.13));
}

.warn-row {
  border-color: #f6c56f;
  background: #fffaf0;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.review-layout {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 14px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-chip {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  padding: 0 11px;
  font-weight: 800;
  color: var(--muted);
}

.filter-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.case-card {
  width: 100%;
  text-align: left;
}

.case-card.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}

.case-card.priority {
  border-color: #f6a66f;
  background: #fff7ed;
}

.case-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.evidence-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px;
  background: #ffffff;
}

.evidence-box strong {
  display: block;
  margin-bottom: 4px;
}

.chat-context {
  display: grid;
  gap: 8px;
}

.message-row {
  border-left: 3px solid var(--line);
  padding-left: 10px;
}

.message-row.reported {
  border-color: var(--red);
  background: #fff7f6;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.escalation-box {
  margin-top: 14px;
  border: 1px solid #fecaca;
  border-radius: 16px;
  background: #fff7f7;
  padding: 14px;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  color: var(--ink);
  font: inherit;
}

@media (max-width: 1100px) {
  .metrics-grid,
  .stats-grid,
  .dashboard-grid,
  .admin-grid,
  .review-layout {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  .check-grid,
  .stats-grid,
  .form-grid,
  .inline-form,
  #restrictionForm,
  .integration-grid,
  .stats-grid,
  .pricing-grid,
  .wizard-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .topbar,
  .setup-strip,
  .list-item {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .integration-grid,
  .form-grid,
  .inline-form,
  #restrictionForm,
  .pricing-grid,
  .wizard-options,
  .check-grid,
  .detail-grid,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .main-panel {
    padding: 14px;
  }
}
