:root {
  --bg-page: #f3f3f5;
  --bg-surface: #ffffff;
  --bg-subtle: #f7f7f8;
  --bg-muted: #efeff1;
  --bg-pressed: #e7e7ea;
  --text-main: #15151a;
  --text-muted: #5f5f68;
  --text-soft: #7b7b84;
  --border: #dedee3;
  --border-strong: #c9c9d0;
  --accent: #9147ff;
  --accent-dark: #772ce8;
  --success: #2d9d5d;
  --danger: #d64545;
  --warning: #be7a00;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --rail-width: 320px;
  --rail-width-compact: 88px;
  --topbar-height: 60px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  color: var(--text-main);
  background: var(--bg-page);
  font-family: "Segoe UI", "Helvetica Neue", "Noto Sans", "Liberation Sans", sans-serif;
}

body.modal-open {
  overflow: hidden;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

.hidden {
  display: none !important;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.top-bar {
  height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr minmax(300px, 520px) 1fr;
  gap: var(--space-4);
  align-items: center;
  padding: 0 var(--space-5);
}

.top-left,
.top-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.top-right {
  justify-content: flex-end;
  position: relative;
}

.search-wrap {
  min-width: 280px;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
  align-items: center;
}

.search-input {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 38px;
  padding: 0 var(--space-4);
}

.brand-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
}

.brand-glyph {
  font-weight: 800;
}

.ghost-btn,
.text-link {
  border: none;
  background: transparent;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-weight: 600;
}

.ghost-btn:hover,
.text-link:hover {
  background: var(--bg-muted);
}

.text-link {
  color: var(--accent-dark);
  padding: 4px 6px;
  font-size: 12px;
}

.pill-btn {
  border: none;
  border-radius: 999px;
  background: linear-gradient(120deg, #5f2ea1, #9147ff);
  color: #fff;
  height: 34px;
  padding: 0 14px;
  font-weight: 700;
}

.icon-btn,
.avatar-btn {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: 10px;
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  position: relative;
}

.icon-btn:hover,
.avatar-btn:hover {
  background: var(--bg-subtle);
}

.badge {
  position: absolute;
  right: -4px;
  top: -5px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid var(--bg-surface);
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.avatar-btn {
  width: 34px;
  padding: 0;
  overflow: hidden;
}

.avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-menu {
  position: absolute;
  top: 48px;
  right: 0;
  width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  display: grid;
  gap: var(--space-1);
}

.account-menu button {
  border: none;
  background: transparent;
  text-align: left;
  border-radius: var(--radius-sm);
  padding: 8px;
}

.account-menu button:hover {
  background: var(--bg-subtle);
}

.workspace {
  min-height: 0;
  flex: 1;
  display: flex;
}

.left-rail {
  width: var(--rail-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  transition: width 180ms ease;
}

body.rail-compact .left-rail {
  width: var(--rail-width-compact);
}

.left-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.left-rail-head h2 {
  font-size: 14px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.left-rail-scroll {
  overflow: auto;
  min-height: 0;
  padding: var(--space-3) var(--space-2) var(--space-5);
}

.rail-group {
  margin-bottom: var(--space-5);
}

.rail-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0 var(--space-2);
  margin-bottom: var(--space-2);
}

.rail-group-header h3 {
  font-size: 12px;
  color: var(--text-soft);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.rail-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--space-1);
}

.rail-item {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: var(--space-2);
  align-items: center;
  border-radius: var(--radius-sm);
  padding: 7px;
  border: 1px solid transparent;
}

.rail-item:hover {
  background: var(--bg-subtle);
}

.rail-item.active {
  background: #f0ebfb;
  border-color: #dbc9ff;
}

.rail-avatar,
.service-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(120deg, #7a53c4, #50258a);
}

.rail-title-wrap {
  min-width: 0;
}

.rail-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rail-meta {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

.dot-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e92929;
  display: inline-block;
  margin-right: 5px;
}

body.rail-compact .rail-group-header h3,
body.rail-compact .rail-group-header .text-link,
body.rail-compact .left-rail-head h2,
body.rail-compact .rail-title-wrap,
body.rail-compact .rail-meta,
body.rail-compact .recommendation-cards {
  display: none;
}

body.rail-compact .rail-item {
  grid-template-columns: 1fr;
  justify-items: center;
}

.recommendation-cards {
  display: grid;
  gap: var(--space-2);
  padding: 0 var(--space-2);
}

.recommendation-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  overflow: hidden;
}

.reco-thumb {
  height: 76px;
  background: linear-gradient(150deg, #f0e8ff, #ddd6f7);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.reco-thumb.blurred::after {
  content: "Blurred by preference";
  position: absolute;
  inset: 0;
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #222;
  background: rgba(255, 255, 255, 0.42);
}

.reco-body {
  padding: var(--space-2);
  display: grid;
  gap: var(--space-2);
}

.reco-title {
  font-size: 12px;
  font-weight: 700;
}

.reco-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.reco-actions {
  display: flex;
  gap: var(--space-1);
}

.reco-actions button {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-subtle);
  padding: 6px;
  font-size: 11px;
}

.main-region {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
}

.main-scroll {
  flex: 1;
  overflow: auto;
  padding: var(--space-7) clamp(18px, 5vw, 52px) var(--space-8);
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 2px;
}

.main-header h1 {
  font-size: clamp(28px, 4vw, 36px);
  letter-spacing: -0.02em;
}

.inline-switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 12px;
  color: var(--text-muted);
}

.settings-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(var(--bg-page) 85%, transparent);
  padding: 6px 0 12px;
  margin-bottom: var(--space-4);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.settings-tab {
  border: none;
  border-radius: 999px;
  background: #ececf0;
  color: var(--text-main);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 13px;
}

.settings-tab:hover {
  background: #e4e4ea;
}

.settings-tab.active {
  background: var(--accent);
  color: #fff;
}

.page-content {
  display: grid;
  gap: var(--space-6);
}

.page-intro {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 860px;
}

.section {
  display: grid;
  gap: var(--space-3);
}

.section-title {
  font-size: 19px;
  letter-spacing: -0.01em;
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 900px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card.pad {
  padding: var(--space-4);
}

.row {
  display: grid;
  grid-template-columns: minmax(230px, 320px) 1fr;
  gap: var(--space-4);
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}

.row:first-child {
  border-top: none;
}

.row.stack {
  grid-template-columns: 1fr;
}

.row-label {
  display: grid;
  gap: var(--space-1);
}

.row-label h4,
.row-label label {
  font-size: 14px;
  font-weight: 700;
}

.row-helper {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.35;
}

.row-control {
  display: grid;
  gap: var(--space-2);
  align-content: start;
}

.control-inline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
  padding: 10px 12px;
  min-height: 38px;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input[disabled],
textarea[disabled],
select[disabled] {
  background: var(--bg-muted);
  color: var(--text-soft);
}

.toggle {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid #b8b8c2;
  background: #cdced6;
  position: relative;
  transition: background 160ms ease, border-color 160ms ease;
}

.toggle::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.toggle[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent-dark);
}

.toggle[aria-checked="true"]::after {
  transform: translateX(18px);
}

.toggle:disabled,
.toggle[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn,
.link-btn,
.icon-only {
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  border-radius: 10px;
  padding: 8px 12px;
  min-height: 36px;
  font-weight: 600;
}

.btn:hover,
.link-btn:hover,
.icon-only:hover {
  background: var(--bg-subtle);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
}

.btn.primary:hover {
  background: var(--accent-dark);
}

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

.link-btn {
  border: none;
  background: transparent;
  color: var(--accent-dark);
  padding-left: 0;
  padding-right: 0;
}

.icon-only {
  padding: 0;
  width: 36px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 3px 8px;
  font-size: 12px;
}

.status.success {
  color: var(--success);
  border-color: #bde3cd;
  background: #effaf3;
}

.status.warning {
  color: var(--warning);
  border-color: #f0d7ae;
  background: #fff7ea;
}

.avatar-preview {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 1px solid var(--border);
  object-fit: cover;
}

.banner-preview {
  width: min(420px, 100%);
  height: 120px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: cover;
  background: #ece8ff;
}

.input-with-icon {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
}

.input-with-icon button {
  width: 38px;
}

.field-error {
  color: var(--danger);
  font-size: 12px;
}

.accordion {
  border-top: 1px solid var(--border);
}

.accordion:first-child {
  border-top: none;
}

.acc-trigger {
  width: 100%;
  border: none;
  background: transparent;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  text-align: left;
  gap: var(--space-3);
  padding: var(--space-4);
}

.acc-trigger:hover {
  background: var(--bg-subtle);
}

.acc-head {
  display: grid;
  gap: var(--space-1);
}

.acc-title {
  font-weight: 700;
  font-size: 14px;
}

.acc-summary,
.acc-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.acc-chevron {
  font-size: 18px;
  color: var(--text-soft);
  transition: transform 160ms ease;
}

.acc-trigger[aria-expanded="true"] .acc-chevron {
  transform: rotate(90deg);
}

.acc-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 200ms ease;
  border-top: 1px solid var(--border);
}

.acc-panel-content {
  padding: var(--space-4);
  display: grid;
  gap: var(--space-3);
}

.delivery-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.delivery-row[data-disabled="true"] {
  background: var(--bg-muted);
  color: var(--text-soft);
}

.service-row {
  display: grid;
  grid-template-columns: auto minmax(200px, 320px) 1fr auto;
  gap: var(--space-4);
  align-items: center;
  border-top: 1px solid var(--border);
  padding: var(--space-4);
}

.service-row:first-child {
  border-top: none;
}

.service-name {
  font-weight: 700;
}

.service-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: #fafafc;
  color: var(--text-muted);
  padding: var(--space-5);
  text-align: center;
  font-size: 13px;
}

.feedback-list {
  display: grid;
  gap: var(--space-2);
}

.feedback-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-subtle);
  padding: 10px;
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
}

.kicker {
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.promo-card {
  border-radius: var(--radius-lg);
  border: 1px solid #d2c0fa;
  padding: var(--space-5);
  background: linear-gradient(130deg, #efe6ff, #f9f4ff);
  display: grid;
  gap: var(--space-3);
}

.meta-table {
  display: grid;
  gap: 1px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-surface);
}

.meta-row div {
  padding: 10px;
  font-size: 13px;
}

#modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 30, 0.48);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal {
  width: min(640px, 100%);
  max-height: min(80vh, 860px);
  overflow: auto;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.modal header,
.modal footer {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.modal footer {
  border-bottom: none;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

.modal-body {
  padding: var(--space-4);
  display: grid;
  gap: var(--space-3);
}

.modal-close {
  float: right;
  border: none;
  background: transparent;
}

.wizard-steps {
  display: flex;
  gap: var(--space-2);
}

.wizard-step {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: #dddde6;
}

.wizard-step.active {
  background: var(--accent);
}

.toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 120;
  display: grid;
  gap: var(--space-2);
  width: min(320px, calc(100% - 32px));
}

.toast {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  background: var(--bg-surface);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
}

.toast button {
  border: none;
  background: transparent;
  color: var(--text-soft);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  .top-bar {
    grid-template-columns: auto 1fr auto;
  }

  .left-rail {
    width: 290px;
  }

  .row,
  .service-row {
    grid-template-columns: 1fr;
  }

  .main-scroll {
    padding-inline: 18px;
  }
}

@media (max-width: 860px) {
  .top-bar {
    height: auto;
    position: static;
    grid-template-columns: 1fr;
    gap: var(--space-2);
    padding: var(--space-2);
  }

  .workspace {
    flex-direction: column;
  }

  .left-rail {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  body.rail-compact .left-rail {
    width: 100%;
  }

  body.rail-compact .rail-group-header h3,
  body.rail-compact .left-rail-head h2,
  body.rail-compact .rail-title-wrap,
  body.rail-compact .rail-meta,
  body.rail-compact .recommendation-cards,
  body.rail-compact .rail-group-header .text-link {
    display: initial;
  }
}
