/* Masterok UI — светлый «воздушный» стиль в духе ggsel: Geist, крупные скругления, мягкие поверхности */
:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --surface-3: #e4e7ec;
  --text: #141414;
  --text-2: #5f6673;
  --text-3: #8b929e;
  --border: #e3e6eb;
  --ink: #141414;
  --ink-text: #ffffff;
  --brand: #3fca5a;
  --brand-soft: #e3f7e7;
  --brand-text: #17853a;
  --warn: #f2a23a;
  --warn-soft: #fff3e0;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --info: #3b82f6;
  --info-soft: #e8f0fe;
  --shadow-s: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-m: 0 8px 24px rgba(16, 24, 40, .08);
  --shadow-l: 0 24px 60px rgba(16, 24, 40, .14);
  --r-s: 10px; --r-m: 14px; --r-l: 20px; --r-xl: 28px;
  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0d0f; --surface: #17171a; --surface-2: #202024; --surface-3: #2a2a2f;
    --text: #f4f4f5; --text-2: #a1a1aa; --text-3: #71717a; --border: #2a2a2f;
    --ink: #f4f4f5; --ink-text: #111113; --brand-soft: #143a1e; --brand-text: #5ee27a;
    --warn-soft: #3a2a12; --danger-soft: #3a1618; --info-soft: #14243f;
    --shadow-s: none; --shadow-m: 0 8px 24px rgba(0,0,0,.4); --shadow-l: 0 24px 60px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0d0f; --surface: #17171a; --surface-2: #202024; --surface-3: #2a2a2f;
  --text: #f4f4f5; --text-2: #a1a1aa; --text-3: #71717a; --border: #2a2a2f;
  --ink: #f4f4f5; --ink-text: #111113; --brand-soft: #143a1e; --brand-text: #5ee27a;
  --warn-soft: #3a2a12; --danger-soft: #3a1618; --info-soft: #14243f;
  --shadow-s: none; --shadow-m: 0 8px 24px rgba(0,0,0,.4); --shadow-l: 0 24px 60px rgba(0,0,0,.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- раскладка ---------- */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.stack { display: flex; flex-direction: column; gap: var(--gap, 12px); }
.row { display: flex; align-items: center; gap: var(--gap, 12px); }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- поверхности ---------- */
.card { background: var(--surface); border-radius: var(--r-l); padding: 20px; box-shadow: var(--shadow-s); }
.card.flat { box-shadow: none; border: 1px solid var(--border); }
.card.pad-l { padding: 28px; }
.card h3 { font-size: 17px; }
.section-title { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--r-m); border: 0; cursor: pointer;
  background: var(--surface-2); color: var(--text); font-weight: 500; font-size: 15px; text-decoration: none;
  transition: background .15s, transform .05s, opacity .15s; white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--ink-text); }
.btn.primary:hover { opacity: .88; }
.btn.brand { background: var(--brand); color: #06290f; }
.btn.brand:hover { filter: brightness(.96); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: var(--r-s); }
.btn.lg { height: 52px; padding: 0 24px; font-size: 16px; border-radius: 16px; }
.btn.block { width: 100%; }
.btn.icon { width: 40px; padding: 0; }
.btn svg { width: 18px; height: 18px; }

/* ---------- поля ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; color: var(--text-2); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: var(--r-m);
  border: 1px solid transparent; background: var(--surface-2); outline: none; transition: border .15s, background .15s;
}
textarea.input { height: auto; min-height: 90px; padding: 12px 14px; resize: vertical; }
.input:focus { border-color: var(--ink); background: var(--surface); }
.input::placeholder { color: var(--text-3); }
.hint { font-size: 12px; color: var(--text-3); }

.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--surface-3); border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); }
.setting { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting .grow > b { display: block; font-weight: 500; }

/* ---------- чипы, бейджи ---------- */
.chip {
  display: inline-flex; align-items: center; justify-content: center; height: 40px; padding: 0 14px;
  border-radius: 12px; background: var(--surface-2); border: 1px solid transparent; cursor: pointer; font-weight: 500;
  transition: .15s; font-variant-numeric: tabular-nums; user-select: none;
}
.chip:hover { background: var(--surface-3); }
.chip.active { background: var(--ink); color: var(--ink-text); }
.chip:disabled { opacity: .35; cursor: default; }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.ok { background: var(--brand-soft); color: var(--brand-text); }
.badge.warn { background: var(--warn-soft); color: #b06a0b; }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- модалка и тосты ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,10,12,.45); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: var(--r-xl); width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); overflow: auto; box-shadow: var(--shadow-l); animation: pop .18s ease-out; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px 8px; }
.modal-head h3 { font-size: 20px; }
.modal-body { padding: 12px 24px 24px; }
@media (max-width: 600px) {
  .overlay { place-items: end center; padding: 0; }
  .modal { border-radius: 24px 24px 0 0; max-height: 92dvh; animation: up .22s ease-out; }
}
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--ink-text); padding: 12px 18px; border-radius: 14px; box-shadow: var(--shadow-l); font-weight: 500; animation: pop .2s; max-width: 90vw; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px) } }
@keyframes up { from { transform: translateY(40px); opacity: .5 } }

.empty { text-align: center; padding: 40px 16px; color: var(--text-2); }
.empty .ico { width: 56px; height: 56px; border-radius: 18px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 14px; font-size: 26px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 10px; }
@keyframes sk { to { background-position: -200% 0 } }

/* ---------- логотип ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; letter-spacing: -0.03em; text-decoration: none; }
.logo-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--ink); color: var(--ink-text); display: grid; place-items: center; }
.logo-mark svg { width: 18px; height: 18px; }
.logo b { color: var(--brand-text); font-weight: 700; }
