:root {
  color-scheme: dark;
  --ink: #08111f;
  --page-bg: #9ca3ad;
  --header-bg: rgba(229, 231, 235, 0.96);
  --header-line: #c2c8d0;
  --panel: #101a2b;
  --panel-2: #17253a;
  --panel-3: #20314a;
  --line: #31445e;
  --line-soft: #22334b;
  --text: #eef4fb;
  --muted: #9fb0c4;
  --gold: #f7b733;
  --gold-2: #ffd47b;
  --coral: #f26d4a;
  --blue: #4ea3f1;
  --green: #4fd18b;
  --danger: #ff5c76;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  min-height: 86px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--header-line);
  background: var(--header-bg);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 72px;
  height: 48px;
  flex: 0 0 auto;
  object-fit: contain;
  padding: 4px;
  border-radius: 4px;
  background: #ffffff;
}

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

.brand-title strong {
  color: var(--ink);
  font-size: 18px;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand-title span {
  color: #586675;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.mode-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  min-height: 42px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.mode-tabs button {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.mode-tabs button.active {
  color: var(--ink);
  background: var(--gold);
  font-weight: 800;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel-2);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--gold);
}

.btn.primary {
  color: var(--ink);
  border-color: var(--gold);
  background: var(--gold);
  font-weight: 800;
}

.btn.ghost {
  background: transparent;
}

.btn.navy {
  color: #ffffff;
  border-color: #1f4561;
  background: #1f4561;
}

.btn.navy:hover {
  border-color: #163650;
  background: #163650;
}

.btn.danger {
  color: #ffd7de;
  border-color: rgba(255, 92, 118, 0.6);
}

.btn.icon-only {
  width: 36px;
  min-width: 36px;
  padding: 0;
  font-weight: 900;
}

.page {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  align-items: start;
  gap: 22px;
  padding: 24px;
}

.sidebar {
  position: sticky;
  top: 110px;
  display: grid;
  gap: 18px;
}

.profile-panel,
.main-panel,
.section,
.recommendation,
.metric-card,
.dialog {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.profile-panel {
  overflow: hidden;
}

.profile-panel header,
.section header,
.main-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.profile-panel h2,
.section h2,
.main-panel h1,
.main-panel h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.profile-list {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.profile-item {
  width: 100%;
  min-height: 48px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--text);
  text-align: left;
  background: transparent;
  cursor: pointer;
}

.profile-item strong,
.profile-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.profile-item.active {
  border-color: rgba(247, 183, 51, 0.65);
  background: rgba(247, 183, 51, 0.1);
}

.client-box {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-2);
  outline: none;
}

.input,
.select {
  padding: 0 12px;
}

.textarea {
  min-height: 88px;
  padding: 12px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(247, 183, 51, 0.12);
}

.main-panel {
  min-width: 0;
  overflow: hidden;
}

.main-panel > header {
  align-items: end;
}

.title-stack {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.title-stack h1 {
  font-size: 26px;
}

.title-stack p {
  margin: 0;
  color: var(--muted);
}

.content {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.metric-card {
  display: grid;
  gap: 12px;
  min-height: 178px;
  padding: 14px;
  background: var(--panel-2);
}

.metric-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.metric-card h3 {
  margin: 0;
  font-size: 15px;
}

.metric-meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.metric-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-values .field label {
  font-size: 10px;
}

.progress {
  height: 9px;
  border-radius: 999px;
  background: #273950;
  overflow: hidden;
}

.progress span {
  display: block;
  width: var(--w, 0%);
  max-width: 100%;
  height: 100%;
  background: var(--c, var(--green));
}

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

.opportunity {
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-2);
}

.opportunity small {
  display: block;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.opportunity strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
}

.opportunity span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.recommendations {
  display: grid;
  gap: 12px;
}

.recommendation {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  overflow: hidden;
  background: var(--panel-2);
}

.score-rank {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 14px;
  color: var(--ink);
  background: var(--gold);
  font-weight: 900;
}

.recommendation-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.recommendation h3 {
  margin: 0;
  font-size: 18px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
}

.chip.hot {
  color: var(--ink);
  border-color: var(--gold);
  background: var(--gold);
  font-weight: 800;
}

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

.detail {
  min-height: 110px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(8, 17, 31, 0.36);
}

.detail strong {
  display: block;
  margin-bottom: 6px;
  color: var(--gold-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail p {
  margin: 0;
  color: #dce7f5;
  line-height: 1.45;
}

.editor-grid {
  display: grid;
  gap: 18px;
}

.section {
  overflow: hidden;
}

.section-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

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

td.actions {
  width: 52px;
  text-align: right;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--muted);
  white-space: nowrap;
}

.switch input {
  width: 17px;
  height: 17px;
  accent-color: var(--gold);
}

.behavior-editor {
  display: grid;
  gap: 12px;
}

.behavior-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-2);
}

.behavior-top {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 12px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  color: #dbe7f4;
}

.check-item input {
  width: 17px;
  height: 17px;
  accent-color: var(--gold);
}

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

.empty {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 7, 14, 0.72);
}

.dialog {
  width: min(620px, 100%);
  overflow: hidden;
}

.dialog header,
.dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.dialog footer {
  border-top: 1px solid var(--line-soft);
  border-bottom: 0;
}

.dialog-body {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.file-input {
  max-width: 280px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 16px;
  border: 1px solid rgba(79, 209, 139, 0.4);
  border-radius: 8px;
  color: #dcffe8;
  background: #113120;
  box-shadow: var(--shadow);
}

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

  .toolbar {
    justify-content: start;
  }

  .page {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 760px) {
  .topbar,
  .page {
    padding: 14px;
  }

  .brand-title strong,
  .brand-title span {
    white-space: normal;
  }

  .mode-tabs {
    width: 100%;
  }

  .opportunity-row,
  .detail-grid,
  .example-grid {
    grid-template-columns: 1fr;
  }

  .recommendation {
    grid-template-columns: 1fr;
  }

  .score-rank {
    min-height: 48px;
  }

  .main-panel > header,
  .profile-panel header,
  .section header {
    align-items: start;
    flex-direction: column;
  }

  .title-stack h1 {
    font-size: 22px;
  }
}
