:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --text: #0f1222;
  --muted: #687089;
  --line: #e6e8f0;
  --brand: #6d5efc;
  --brand-2: #e8467c;
  --brand-soft: #efedff;
  --grad: linear-gradient(135deg, #6d5efc 0%, #a855f7 50%, #e8467c 100%);
  --ok: #15a35a;
  --ok-soft: #e6f7ee;
  --warn: #c97a06;
  --warn-soft: #fff5e1;
  --danger: #e5484d;
  --danger-soft: #feeceb;
  --instagram: #e1306c;
  --tiktok: #0f1222;
  --facebook: #1877f2;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 18, 40, 0.04), 0 8px 24px -12px rgba(16, 18, 40, 0.12);
  --shadow-lg: 0 24px 48px -16px rgba(16, 18, 40, 0.25);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d14;
    --surface: #12151f;
    --surface-2: #191d2a;
    --text: #eceef6;
    --muted: #8e95ac;
    --line: #232837;
    --brand: #8b7fff;
    --brand-soft: #221f45;
    --ok: #3dd68c;
    --ok-soft: #12291f;
    --warn: #f5b544;
    --warn-soft: #2e2512;
    --danger: #ff6b6f;
    --danger-soft: #331a1c;
    --tiktok: #eceef6;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
    --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Heebo', 'Segoe UI', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.icon { flex-shrink: 0; display: block; }
.loading { padding: 120px; text-align: center; color: var(--muted); }

/* ---------- app layout ---------- */
.layout { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px;
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 500; padding: 0 8px 18px; }
.brand b { font-weight: 800; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; background: var(--grad);
  box-shadow: 0 6px 16px -6px rgba(109, 94, 252, 0.6);
}
.nav-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 14px 10px 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 500; text-decoration: none !important;
  transition: background 0.15s;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }
.nav-item > .icon { color: var(--muted); }
.nav-item.active > .icon { color: var(--brand); }
.nav-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.nav-text small { font-size: 12px; color: var(--muted); font-weight: 400; }
.picon {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  color: var(--pcolor); background: color-mix(in srgb, var(--pcolor) 12%, transparent);
}
.picon.lg { width: 40px; height: 40px; border-radius: 12px; }

.me {
  margin-top: auto; display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 12px; background: var(--surface-2);
}
.me-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--grad);
}
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.me-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--muted); font-size: 12px; }
.icon-btn {
  border: none; background: none; color: var(--muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--surface); color: var(--danger); }

.main { min-width: 0; padding: 28px 36px 40px; max-width: 1160px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 800; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.title-with-icon { display: inline-flex; align-items: center; gap: 12px; }
.foot { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-size: 12.5px; padding-top: 24px; }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 14px; font-size: 17px; font-weight: 700; }
.card h3 { margin: 0 0 8px; font-size: 15px; font-weight: 700; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- segmented (mode switch) ---------- */
.segmented { display: inline-flex; gap: 2px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.segmented button {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: 14px; color: var(--muted);
  background: none; border: none; border-radius: 9px; padding: 8px 16px; cursor: pointer;
  transition: 0.15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(16, 18, 40, 0.12); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff;
  padding: 9px 16px; font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: transform 0.08s, filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; transform: none; }
.btn.lg { padding: 12px 18px; font-size: 15px; width: 100%; background: var(--grad); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.ok { background: var(--ok); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn.danger:hover { background: var(--danger-soft); border-color: transparent; filter: none; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }

input[type='text'], input[type='password'], input[type='number'], input[type='search'], select, textarea {
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13.5px; }
label.field .muted.small { margin-top: 5px; }

/* ---------- auth ---------- */
.auth { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.auth-inner { width: 100%; max-width: 380px; }
.auth-inner .brand { padding: 0 0 36px; }
.auth-inner h1 { margin: 0 0 4px; font-size: 28px; font-weight: 800; }
.auth-inner > .muted { margin: 0 0 28px; }
.auth-hero {
  position: relative; overflow: hidden; color: #fff;
  display: grid; place-items: center; padding: 48px;
  background: var(--grad);
}
.auth-hero::before, .auth-hero::after {
  content: ''; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.12);
}
.auth-hero::before { width: 420px; height: 420px; top: -140px; left: -120px; }
.auth-hero::after { width: 300px; height: 300px; bottom: -100px; right: -60px; background: rgba(255, 255, 255, 0.08); }
.auth-hero-inner { position: relative; max-width: 420px; }
.auth-hero h2 { font-size: 38px; line-height: 1.15; font-weight: 800; margin: 0 0 36px; }
.feature { display: flex; gap: 14px; margin-bottom: 22px; }
.feature-icon {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; background: rgba(255, 255, 255, 0.18); backdrop-filter: blur(6px);
}
.feature strong { font-size: 16px; }
.feature p { margin: 2px 0 0; opacity: 0.85; font-size: 14px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px;
}
.stat b { display: block; font-size: 28px; font-weight: 800; line-height: 1.15; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.hl { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 12px 28px -12px rgba(109, 94, 252, 0.7); }
.stat.hl span { color: rgba(255, 255, 255, 0.88); }

.settings { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 14px; align-items: end; }
.settings label.field { margin: 0; }

.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--grad); border-radius: 99px; transition: width 0.4s; }
.gate { font-weight: 600; font-size: 13.5px; color: var(--ok); }
.gate.wait { color: var(--warn); }
.gate.stop { color: var(--danger); }

.notice {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--warn-soft); color: var(--warn);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 18px; font-weight: 500; font-size: 14px;
}
.badge {
  background: var(--danger); color: #fff; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; line-height: 1.6;
}
.tag {
  display: inline-block; font-size: 12px; font-weight: 600; border-radius: 6px;
  padding: 1px 8px; background: var(--surface-2); color: var(--muted);
}
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- connect / upload ---------- */
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 4px 0 24px; }
.how > div { background: var(--surface-2); border-radius: 14px; padding: 16px; font-size: 14px; }
.how b {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; margin-bottom: 8px;
  font-size: 14px; color: #fff; background: var(--grad);
}
ol.steps { padding-inline-start: 22px; margin: 8px 0 18px; }
ol.steps li { margin-bottom: 7px; }
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 32px 16px; text-align: center; cursor: pointer;
  background: var(--surface-2); transition: 0.15s;
}
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop .drop-icon {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  color: var(--brand); background: var(--surface); box-shadow: var(--shadow);
}
.drop.compact { flex-direction: row; padding: 6px 12px; border-width: 1px; border-style: solid; gap: 6px; border-radius: 8px; background: var(--surface); font-size: 13px; }
.drop.compact .drop-icon { width: auto; height: auto; background: none; box-shadow: none; }
.drop.compact .drop-hint { display: none; }

/* ---------- lists ---------- */
.ltabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -6px 0 14px; overflow-x: auto; }
.ltabs button {
  font: inherit; font-size: 14px; background: none; border: none; color: var(--muted); font-weight: 600;
  padding: 10px 12px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px;
}
.ltabs button:hover { color: var(--text); }
.ltabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.ltabs button .count { font-weight: 400; opacity: 0.8; }

.person {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: 12px; transition: background 0.12s;
}
.person + .person { border-top: 1px solid var(--line); }
.person:hover { background: var(--surface-2); }
.person.opened { background: var(--brand-soft); }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; color: #fff; text-transform: uppercase; font-size: 15px;
}
.person .info { flex: 1; min-width: 0; }
.person .info strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; font-weight: 600; }
.person .actions { display: flex; gap: 6px; flex-shrink: 0; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 40px 16px; color: var(--muted); max-width: 440px; margin: 0 auto; }
.empty .big {
  width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  color: var(--brand); background: var(--brand-soft);
}

/* ---------- target audiences ---------- */
.aud-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.aud {
  border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--surface);
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
.aud-head { display: flex; align-items: flex-start; gap: 6px; }
.aud-head h3 { flex: 1; margin: 4px 0 0; }
.aud.editing { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 12%, transparent); margin-bottom: 14px; }
.aud-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.aud-stats b { color: var(--text); font-size: 15px; font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.chip {
  font: inherit; font-size: 13px; font-weight: 500; color: var(--brand); background: var(--brand-soft);
  border: none; border-radius: 999px; padding: 4px 12px; cursor: pointer; text-decoration: none !important;
  transition: filter 0.15s;
}
.chip:hover { filter: brightness(0.95); }
.check-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px 3px 9px; transition: 0.15s;
}
.check-chip:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.check-chip input { margin: 0; accent-color: var(--brand); }
details summary { cursor: pointer; font-weight: 600; color: var(--brand); padding: 4px 0; font-size: 14px; }
details[open] summary { margin-bottom: 8px; }

/* ---------- browser extension page ---------- */
.ext-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.ext-step { display: flex; gap: 14px; padding: 12px 0; }
.ext-step + .ext-step { border-top: 1px solid var(--line); }
.ext-step strong { display: block; margin-bottom: 2px; }
.ext-step p { margin: 0 0 8px; }
.ext-num {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; display: grid; place-items: center;
  font-size: 14px; font-weight: 700; color: #fff; background: var(--grad);
}
.ext-list { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
code { font-family: Consolas, monospace; font-size: 13px; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; direction: ltr; unicode-bidi: embed; }
.code-box { display: flex; gap: 8px; margin: 14px 0 6px; }
.code-input { font-family: Consolas, monospace !important; font-size: 13px !important; }
.new-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-2); }

/* ---------- tables & forms ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 12px 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
th { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr) auto; gap: 12px; align-items: end; }
.form-grid label.field { margin: 0; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 380px; }
.toast {
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: 12px;
  box-shadow: var(--shadow-lg); font-weight: 500; font-size: 14px; animation: pop 0.2s ease;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .settings { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 20; height: auto;
    flex-direction: row; align-items: center; gap: 6px;
    padding: 10px 12px; border-inline-end: none; border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .brand { padding: 0 4px 0 8px; }
  .brand > span:last-child, .nav-label, .nav-text small, .me-text { display: none; }
  .nav { flex-direction: row; }
  .nav-item { padding: 7px 9px; white-space: nowrap; }
  .nav-item:not(.platform) .nav-text { display: none; }
  .me { margin: 0 auto 0 0; padding: 4px; background: none; }
  .me-avatar { display: none; }
  .main { padding: 20px 16px 32px; }
  .page-head h1 { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats .stat.hl { grid-column: span 2; }
  .settings, .form-grid, .how, .aud-grid, .ext-grid { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .person { flex-wrap: wrap; }
  .person .actions { width: 100%; justify-content: flex-end; }
}
