:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #f1f3f5);
  --text: var(--tg-theme-text-color, #111827);
  --hint: var(--tg-theme-hint-color, #8b95a1);
  --link: var(--tg-theme-link-color, #2481cc);
  --button: var(--tg-theme-button-color, #2481cc);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: #e0483d;
  --ok: #2ead5b;
  --warn: #e6a23c;
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  padding-bottom: 40px;
  zoom: 0.83;            /* весь интерфейс на ~17% компактнее */
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--secondary-bg);
}

.tabs { display: flex; }
.tab {
  flex: 1;
  padding: 14px 8px;
  border: none;
  background: none;
  color: var(--hint);
  font-size: 15px;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab.active { color: var(--text); border-bottom-color: var(--button); }

main { padding: 14px; }

.loader, .empty { text-align: center; color: var(--hint); padding: 40px 12px; }

.card {
  background: var(--secondary-bg);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title { font-weight: 700; font-size: 16px; margin: 0; }
.card-sub { color: var(--hint); font-size: 13px; margin-top: 2px; }

.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

label { display: block; font-size: 13px; color: var(--hint); margin: 12px 0 4px; }

input[type="text"], textarea, input[type="number"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--secondary-bg);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
textarea { min-height: 64px; resize: vertical; }

input:focus, textarea:focus { outline: none; border-color: var(--button); }

button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  background: var(--button);
  color: var(--button-text);
}
.btn.block { width: 100%; }
.btn.ghost { background: var(--secondary-bg); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.small { padding: 7px 12px; font-size: 13px; }

.icon-btn {
  border: none;
  background: none;
  color: var(--hint);
  padding: 4px 8px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Строгие линейные иконки — наследуют цвет текста кнопки/строки */
.ic {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: -3px;
}
.btn .ic { margin-right: 6px; }
.icon-btn .ic { width: 18px; height: 18px; vertical-align: middle; }
.kw .ic, .verdict .ic, .qa .ic, .card-sub .ic {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
  margin-right: 3px;
}
.verdict.pass .ic { stroke: var(--ok); }
.verdict.fail .ic { stroke: var(--warn); }
.qa .m .ic { stroke: var(--ok); }
.qa .nm .ic { stroke: var(--warn); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge.on { background: rgba(46,173,91,.15); color: var(--ok); }
.badge.off { background: rgba(139,149,161,.2); color: var(--hint); }

/* toggle */
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; border-radius: 26px;
  background: var(--hint); transition: .2s; cursor: pointer;
}
.slider::before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.question {
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
}
.question .qtext { font-weight: 600; }
.kw { color: var(--link); font-size: 13px; margin-top: 4px; word-break: break-word; }
.kw.empty { color: var(--warn); }

.range-wrap { display: flex; align-items: center; gap: 12px; }
input[type="range"] { flex: 1; accent-color: var(--button); }
.range-val { font-weight: 700; min-width: 44px; text-align: right; }

.divider { height: 1px; background: var(--bg); margin: 12px 0; }

.appcard .verdict { font-weight: 700; margin: 4px 0 8px; }
.verdict.pass { color: var(--ok); }
.verdict.fail { color: var(--warn); }
.verdict.none { color: var(--hint); }
.qa { margin-top: 8px; }
.qa .q { font-weight: 600; }
.qa .a { color: var(--text); }
.qa .m { color: var(--ok); font-size: 12px; }
.qa .nm { color: var(--warn); font-size: 12px; }

.tglink {
  color: var(--link);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.tglink:active { opacity: .6; }

.hidden { display: none !important; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 24px;
  font-size: 14px; z-index: 100; max-width: 90%;
}

.fab-wrap { position: sticky; bottom: 12px; margin-top: 8px; }

.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; z-index: 50;
}
.modal {
  background: var(--bg); width: 100%; border-radius: 16px 16px 0 0;
  padding: 18px; max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 10px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
small.hint { color: var(--hint); display: block; margin-top: 4px; }
