/* Общий стиль веб-версии и админки: в духе Apple — системный шрифт, сгруппированные карточки,
   «стеклянная» шапка, сегменты и переключатели как в iOS. Светлая и тёмная тема. */
:root {
  color-scheme: light;
  --bg: #f5f5f7; --bg-2: #ffffff; --card: #ffffff; --fill: rgba(120, 120, 128, .12); --fill-2: rgba(120, 120, 128, .2);
  --sep: rgba(60, 60, 67, .14); --sep-2: rgba(60, 60, 67, .24);
  --text: #1d1d1f; --text-2: #6e6e73; --text-3: #86868b;
  --blue: #007aff; --blue-soft: rgba(0, 122, 255, .1); --green: #34c759; --green-text: #248a3d; --green-soft: rgba(52, 199, 89, .14);
  --orange: #ff9500; --orange-text: #c76a00; --orange-soft: rgba(255, 149, 0, .14);
  --red: #ff3b30; --red-text: #d70015; --red-soft: rgba(255, 59, 48, .12);
  --s1: #007aff; --s2: #ff9500; --s3: #af52de; --s4: #34c759; --s5: #5856d6;
  --glass: rgba(255, 255, 255, .72); --tip-bg: rgba(29, 29, 31, .92); --tip-text: #f5f5f7;
  --shadow: 0 1px 1px rgba(0, 0, 0, .02), 0 4px 18px rgba(0, 0, 0, .05);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .04), 0 14px 38px rgba(0, 0, 0, .1);
  --radius: 20px; --radius-s: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Inter, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000; --bg-2: #1c1c1e; --card: #1c1c1e; --fill: rgba(120, 120, 128, .24); --fill-2: rgba(120, 120, 128, .36);
    --sep: rgba(84, 84, 88, .55); --sep-2: rgba(84, 84, 88, .8);
    --text: #f5f5f7; --text-2: #a1a1a6; --text-3: #8e8e93;
    --blue: #0a84ff; --blue-soft: rgba(10, 132, 255, .18); --green: #30d158; --green-text: #30d158; --green-soft: rgba(48, 209, 88, .16);
    --orange: #ff9f0a; --orange-text: #ff9f0a; --orange-soft: rgba(255, 159, 10, .16);
    --red: #ff453a; --red-text: #ff6961; --red-soft: rgba(255, 69, 58, .16);
    --s1: #0a84ff; --s2: #d27c00; --s3: #bf5af2; --s4: #22a043; --s5: #6e6cf0;
    --glass: rgba(22, 22, 23, .72); --tip-bg: rgba(245, 245, 247, .94); --tip-text: #1d1d1f;
    --shadow: none; --shadow-lift: 0 14px 38px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000; --bg-2: #1c1c1e; --card: #1c1c1e; --fill: rgba(120, 120, 128, .24); --fill-2: rgba(120, 120, 128, .36);
  --sep: rgba(84, 84, 88, .55); --sep-2: rgba(84, 84, 88, .8);
  --text: #f5f5f7; --text-2: #a1a1a6; --text-3: #8e8e93;
  --blue: #0a84ff; --blue-soft: rgba(10, 132, 255, .18); --green: #30d158; --green-text: #30d158; --green-soft: rgba(48, 209, 88, .16);
  --orange: #ff9f0a; --orange-text: #ff9f0a; --orange-soft: rgba(255, 159, 10, .16);
  --red: #ff453a; --red-text: #ff6961; --red-soft: rgba(255, 69, 58, .16);
  --s1: #0a84ff; --s2: #d27c00; --s3: #bf5af2; --s4: #22a043; --s5: #6e6cf0;
  --glass: rgba(22, 22, 23, .72); --tip-bg: rgba(245, 245, 247, .94); --tip-text: #1d1d1f;
  --shadow: none; --shadow-lift: 0 14px 38px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.47 var(--font); letter-spacing: -0.01em; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
:focus-visible { outline: 3px solid var(--blue-soft); outline-offset: 2px; border-radius: 8px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.sub { color: var(--text-2); font-size: 13px; }
[hidden] { display: none !important; }

/* стеклянная шапка */
.nav { position: sticky; top: 0; z-index: 20; background: var(--glass); backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: .5px solid var(--sep); }
.nav-in { max-width: 1200px; margin: 0 auto; height: 52px; padding: 0 16px; display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 16px; letter-spacing: -0.02em; white-space: nowrap; color: var(--text); }
.brand:hover { text-decoration: none; }
.mark { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--bg); background: var(--text); }
.mark svg { width: 16px; height: 16px; }
.nav .spacer { flex: 1; }

/* заголовки */
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px 64px; }
.large-title { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -0.03em; margin: 28px 0 4px; }
.lead { color: var(--text-2); font-size: 17px; margin: 0 0 22px; }
.section-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 34px 0 12px; }
.group-label { font-size: 13px; color: var(--text-2); text-transform: uppercase; letter-spacing: .02em; margin: 26px 16px 7px; }
.group-foot { font-size: 13px; color: var(--text-2); margin: 7px 16px 0; }

/* карточки */
.card { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.card .head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card .head .tools { margin-left: auto; }

/* список как в «Настройках» iOS */
.list { background: var(--card); border-radius: var(--radius-s); overflow: hidden; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 16px; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.row .label { flex: 1; min-width: 0; }
.row .label small { display: block; color: var(--text-2); font-size: 13px; }
.row .value { color: var(--text-2); }
.row.stack { display: block; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; cursor: pointer;
  background: var(--fill); color: var(--blue); border-radius: 980px; padding: 7px 15px; font-size: 14px; font-weight: 500;
  transition: background .15s, transform .1s, opacity .15s; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--fill-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.large { padding: 12px 24px; font-size: 17px; }
.btn.danger { color: var(--red-text); }
.btn.plain { background: none; padding: 6px 8px; }
.btn.plain:hover { background: var(--fill); }

/* сегменты */
.seg { display: inline-flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 0; position: relative; }
.seg button { border: 0; background: none; color: var(--text); font-size: 13px; font-weight: 500; padding: 4px 12px;
  border-radius: 7px; cursor: pointer; min-width: 36px; transition: background .2s, box-shadow .2s; white-space: nowrap; }
.seg button.on { background: var(--bg-2); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); font-weight: 600; }
:root[data-theme="dark"] .seg button.on { background: #636366; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button.on { background: #636366; } }

/* переключатель iOS */
.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--fill-2); transition: background .25s; }
.switch span::after { content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px; border-radius: 50%; background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 3px 1px rgba(0, 0, 0, .06); transition: transform .25s cubic-bezier(.3, .7, .4, 1); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--blue-soft); outline-offset: 2px; }
.switch input:disabled + span { opacity: .5; }
.switch.small { width: 42px; height: 26px; }
.switch.small span::after { width: 22px; height: 22px; }
.switch.small input:checked + span::after { transform: translateX(16px); }

/* метки и чипы */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 980px; white-space: nowrap; }
.pill.good, .pill.sent { color: var(--green-text); background: var(--green-soft); }
.pill.bad, .pill.rejected { color: var(--red-text); background: var(--red-soft); }
.pill.warn, .pill.error { color: var(--orange-text); background: var(--orange-soft); }
.pill.neutral, .pill.screened_out { color: var(--text-2); background: var(--fill); }
.pill.blue { color: var(--blue); background: var(--blue-soft); }
.pill.dotted::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 0; background: var(--fill); color: var(--text); border-radius: 980px; padding: 7px 14px; font-size: 14px;
  cursor: pointer; transition: background .15s, color .15s; }
.chip:hover { background: var(--fill-2); }
.chip.on { background: var(--blue); color: #fff; }
.chip.small { padding: 4px 11px; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.good { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.warn { background: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.dot.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

/* поля ввода */
.field { width: 100%; border: 0; background: var(--fill); border-radius: 10px; padding: 10px 12px; font-size: 15px; outline: none;
  transition: box-shadow .15s; }
.field:focus { box-shadow: 0 0 0 3px var(--blue-soft); }
textarea.field { resize: vertical; min-height: 84px; line-height: 1.45; }
select.field { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select.inline { width: auto; padding: 5px 28px 5px 10px; font-size: 14px; background-color: var(--fill); }

/* всплывающая подсказка и уведомление */
#tip { position: fixed; pointer-events: none; background: var(--tip-bg); color: var(--tip-text); font-size: 12px; line-height: 1.5;
  padding: 7px 10px; border-radius: 10px; opacity: 0; transition: opacity .1s; z-index: 50; white-space: nowrap;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; z-index: 60; pointer-events: none;
  background: var(--tip-bg); color: var(--tip-text); padding: 10px 18px; border-radius: 980px; font-size: 14px; font-weight: 500;
  transition: opacity .25s, transform .25s cubic-bezier(.3, .7, .4, 1); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.empty { display: grid; place-items: center; text-align: center; min-height: 140px; color: var(--text-3); font-size: 14px;
  border-radius: var(--radius-s); background: var(--fill); padding: 18px; }
.fade-in { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 640px) {
  .large-title { font-size: 28px; margin-top: 20px; }
  .card { padding: 16px; border-radius: 16px; }
}
