:root {
  --bg: #f4f6f7;
  --card: #ffffff;
  --text: #16202a;
  --muted: #65717d;
  --faint: #8d97a1;
  --line: #e3e8ec;
  --accent: #0e7c66;
  --accent-ink: #0a5f4e;
  --accent-soft: #e6f4ef;
  --amber: #b45309;
  --amber-soft: #fdf3e2;
  --red: #c2362b;
  --red-soft: #fcebea;
  --blue-soft: #eaf1fb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app { max-width: 1180px; margin: 0 auto; padding: 22px 24px 48px; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.brand { display: flex; gap: 14px; align-items: center; }
.brand h1 { font-size: 22px; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.sub { margin: 3px 0 0; color: var(--muted); }
.logo-mark {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  background: linear-gradient(140deg, #13a383, #0b6553) center / cover;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
  position: relative;
}
.logo-mark::after {
  content: ""; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 44 44' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 33V15l9-4v22M21 33V19l10 3v11M9 33h26M15 18v.01M15 22v.01M15 26v.01M25 25v.01M25 29v.01'/%3E%3Ccircle cx='32' cy='13' r='5' fill='white' stroke='none'/%3E%3Cpath d='M32 10.5v5M29.5 13h5' stroke='%230b6553' stroke-width='1.8'/%3E%3C/svg%3E") center / 100% no-repeat;
}
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; color: var(--muted); white-space: nowrap; box-shadow: var(--shadow); }
.pill b { color: var(--text); }

.tabs { display: inline-flex; gap: 4px; padding: 4px; background: #e9edf0; border-radius: 12px; margin-bottom: 16px; }
.tab { border: 0; background: transparent; padding: 7px 16px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tab.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 14px; background: var(--blue-soft); border: 1px solid #cddcf3; display: flex; gap: 10px; align-items: center; }
.banner.warn { background: var(--amber-soft); border-color: #f3d9ae; }
.banner.err { background: var(--red-soft); border-color: #f1c5c1; }
.banner .bar { flex: 1; height: 6px; background: rgba(0,0,0,.07); border-radius: 99px; overflow: hidden; max-width: 260px; }
.banner .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar select, .search { height: 40px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; }
.toolbar select { padding: 0 34px 0 12px; appearance: none; cursor: pointer;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%2365717d' stroke-width='1.5'/%3E%3C/svg%3E") right 12px center / 12px no-repeat; }
.search { flex: 1 1 280px; display: flex; align-items: center; gap: 8px; padding: 0 12px; }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--faint); stroke-width: 2; flex: none; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; height: 100%; }
.toolbar select:focus-visible, .search:focus-within, .btn:focus-visible, .tab:focus-visible { outline: 2px solid rgba(14,124,102,.35); outline-offset: 1px; }
.grow { flex: 1; }
.range { display: inline-flex; gap: 8px; align-items: center; }
.range label { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.range input { height: 40px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 0 10px; }
.toolbar select { max-width: 280px; }
.count { color: var(--muted); margin: 4px 2px 10px; min-height: 20px; }

.list { display: grid; gap: 10px; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s, opacity .25s;
}
.row:hover { border-color: #cdd6dc; }
.row.leaving { opacity: 0; transform: translateX(12px); }
.row h3 { margin: 0 0 6px; font-size: 15.5px; font-weight: 600; letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 13px; }
.meta span { display: inline-flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; }
.meta b { color: var(--text); font-weight: 500; }
.tag { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #eef1f3; color: var(--muted); }
.tag.won { background: var(--accent-soft); color: var(--accent-ink); }
.tag.lost { background: var(--red-soft); color: var(--red); }
.tag.fired { background: var(--amber-soft); color: var(--amber); }
.tag.none { background: #eef1f3; }

.btn { height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { background: var(--card); border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: #c9d2d8; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 16px; }
.skeleton { height: 74px; border-radius: var(--radius); background: linear-gradient(90deg, #eceff2 0%, #f6f8f9 50%, #eceff2 100%); background-size: 200% 100%; animation: sk 1.2s infinite linear; }
@keyframes sk { to { background-position: -200% 0; } }

.pager { display: flex; justify-content: center; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pager button { min-width: 36px; height: 34px; border: 1px solid var(--line); background: var(--card); border-radius: 9px; cursor: pointer; }
.pager button.cur { background: var(--text); color: #fff; border-color: var(--text); }
.pager button:disabled { opacity: .45; cursor: default; }

.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 600; background: #fafbfc; }
.table tr:last-child td { border-bottom: 0; }
.table td.num { text-align: right; }
.link { color: var(--accent-ink); cursor: pointer; text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* Настройки */
.set-grid { display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card h2 { font-size: 15.5px; margin: 0 0 4px; }
.card .hint { color: var(--muted); margin: 0 0 14px; font-size: 13px; }
.field { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid #eef1f3; }
.field:first-of-type { border-top: 0; }
.field .lbl { display: grid; gap: 2px; }
.field .lbl small { color: var(--muted); font-size: 12.5px; }
.num-input { width: 84px; height: 36px; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; text-align: right; }
.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: #cfd6dc; border-radius: 99px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid rgba(14,124,102,.35); outline-offset: 2px; }
.seg { display: inline-flex; padding: 3px; background: #eef1f3; border-radius: 10px; gap: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.check { display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 6px 11px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #eef1f3; border-radius: 99px; padding: 4px 6px 4px 11px; font-size: 13px; }
.chip button { border: 0; background: rgba(0,0,0,.06); width: 20px; height: 20px; border-radius: 50%; cursor: pointer; line-height: 1; padding: 0; color: var(--muted); }
.chip.fired { background: var(--amber-soft); }
.muted { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: #f7f9fa; border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 22px; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 12.5px; }
.savebar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; align-items: center; padding: 14px 0 4px; background: linear-gradient(transparent, var(--bg) 35%); }
.savebar .muted { margin-right: auto; }

/* Окно подтверждения и уведомления */
.modal { position: fixed; inset: 0; background: rgba(16, 24, 32, .38); display: grid; place-items: center; padding: 16px; z-index: 10; animation: fade .15s; }
.modal-card { background: var(--card); border-radius: 18px; padding: 22px 22px 18px; width: min(460px, 100%); box-shadow: 0 20px 50px rgba(0,0,0,.18); }
.modal-card h2 { font-size: 18px; margin: 0 0 10px; letter-spacing: -.01em; }
.modal-card ul { margin: 0; padding-left: 18px; color: var(--muted); display: grid; gap: 5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #16202a; color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.2); z-index: 20; max-width: calc(100% - 32px); animation: fade .15s; }
.toast.err { background: var(--red); }

.install { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.install-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 32px; max-width: 440px; text-align: center; box-shadow: var(--shadow); }
.install-card .logo-mark { margin: 0 auto 14px; width: 56px; height: 56px; }
.install-card h1 { font-size: 20px; margin: 0 0 8px; }
.install-card p { color: var(--muted); margin: 0; }
.install-card p.error { color: var(--red); }

@media (max-width: 720px) {
  .app { padding: 16px 16px 40px; }
  .top { flex-direction: column; }
  .row { grid-template-columns: 1fr; }
  .row .btn { width: 100%; }
  .toolbar select { flex: 1 1 100%; max-width: none; }
  .range { flex: 1 1 100%; }
  .range label, .range input { flex: 1; }
  .field { flex-wrap: wrap; }
}
