/* Keitaro Wrapper — современный минимум: без сборщиков и CDN-фреймворков. */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e3e8ee;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --danger: #b91c1c;
  --dirty-bg: #fff8e1;
  --dirty-line: #f0c36d;
  --removed: #9ca3af;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 10px clamp(12px, 3vw, 28px);
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-size: 18px; letter-spacing: .2px; }
.brand b { color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-block; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 13px; letter-spacing: .3px;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s;
}
.btn:hover { background: #f1f5fb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #1d4fd8; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #f1f5fb; }
.btn.danger { color: var(--danger); border-color: #f3d4d4; }
.btn.danger:hover { background: #fdf1f1; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.select, .input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--card); color: var(--ink);
}
.input:focus, .select:focus { outline: 2px solid #c7dbff; border-color: var(--accent); }

/* ---------- контент ---------- */
.streams { display: flex; flex-direction: column; gap: 14px; padding: 16px clamp(12px, 3vw, 28px) 60px; max-width: 1080px; margin: 0 auto; width: 100%; }
.page { display: flex; justify-content: center; padding: 28px clamp(12px, 3vw, 28px); }
.form-card { width: min(560px, 100%); }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.card.dirty { background: var(--dirty-bg); border-color: var(--dirty-line); }

.stream-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stream-title { font-weight: 700; }
.stream-title .muted { font-weight: 400; }
.muted { color: var(--muted); font-size: 13px; }

.stream-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stream-warning { background: #fee2e2; color: #7f1d1d; border: 1px solid #fecaca; border-radius: 8px; padding: 6px 10px; margin: 6px 0; font-size: 13px; }

.table-wrap { overflow-x: auto; }
table.offers { width: 100%; border-collapse: collapse; font-size: 14px; }
table.offers th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: .5px; padding: 6px 8px; border-bottom: 1px solid var(--line);
}
table.offers td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
table.offers td.name-cell { white-space: normal; min-width: 220px; }
td.share { font-weight: 700; font-variant-numeric: tabular-nums; }
tr.removed td { color: var(--removed); background: #fafafa; }
tr.removed td.share { color: var(--removed); }
.removed-tag { font-size: 12px; }

.add-row { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; flex-wrap: wrap; position: relative; }
.add-row .input { flex: 1 1 260px; }

.offer-box { position: relative; }
.suggest {
  position: absolute; z-index: 15; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); max-height: 260px; overflow-y: auto;
}
.suggest-item { padding: 8px 12px; cursor: pointer; font-size: 14px; }
.suggest-item:hover, .suggest-item.active { background: #eef4ff; }
.suggest-item .muted { margin-left: 6px; }

/* ---------- модалка ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 40;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 12px;
}
.modal-box { background: var(--card); border-radius: var(--radius); width: min(680px, 100%); padding: 16px; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-list { max-height: 50vh; overflow-y: auto; margin-top: 10px; }
.modal-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.modal-row .name { flex: 1; min-width: 0; }

/* ---------- форма создаватора ---------- */
h1 { font-size: 20px; margin: 0 0 4px; }
form, .result { margin-top: 14px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.field .input, .field .select { width: 100%; }
.field small { display: block; margin-top: 4px; }
.advanced { margin: 6px 0 14px; }
.advanced summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; }
.advanced .field { margin-top: 10px; }
.result { border: 1px solid #bbf7d0; background: #f0fdf4; border-radius: 8px; padding: 12px; }
.result a { color: var(--accent); }

/* ---------- тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111827; color: #f9fafb; padding: 10px 16px; border-radius: 8px;
  z-index: 60; max-width: min(640px, 92vw); font-size: 14px; box-shadow: var(--shadow);
}
.toast.error { background: #7f1d1d; }

.hidden { display: none !important; }

@media (max-width: 640px) {
  .topbar { gap: 8px; }
  .toolbar { width: 100%; }
  .select { max-width: 100%; }
}
