:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1b232b;
  --muted: #66727e;
  --line: #dfe4e9;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --warn-bg: #fff6e5;
  --warn-line: #f0c674;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 32, .06), 0 6px 24px rgba(16, 24, 32, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1217;
    --card: #161c24;
    --text: #e6ebf1;
    --muted: #94a2b1;
    --line: #263140;
    --accent: #4d9bff;
    --accent-soft: #16273f;
    --warn-bg: #2a2413;
    --warn-line: #6b5726;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }

.wrap { max-width: 1060px; margin: 0 auto; padding: 24px 20px 64px; }

header.site {
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
header.site .wrap { padding: 18px 20px; display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
header.site .brand { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
header.site .brand a { color: inherit; text-decoration: none; }
header.site nav { margin-left: auto; display: flex; gap: 16px; font-size: 14px; }
header.site nav a { color: var(--muted); text-decoration: none; }
header.site nav a:hover { color: var(--text); }

h1 { font-size: 26px; margin: 8px 0 4px; }
.lead { color: var(--muted); margin: 0 0 20px; }

.notice {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  margin: 0 0 22px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

/* ---- portal grid ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tile {
  display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.tile h3 { margin: 0 0 6px; font-size: 17px; }
.tile p { margin: 0; color: var(--muted); font-size: 14px; }
.tile.soon { opacity: .55; pointer-events: none; }
.tag { display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 999px; margin-bottom: 10px; }
.tag.grey { background: var(--line); color: var(--muted); }

/* ---- controls ---- */
.controls { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 720px) { .controls { grid-template-columns: 1.2fr 1fr 1fr; } }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; font-size: 15px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px; appearance: none;
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

.autocomplete { position: relative; }
.suggestions {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--card); border: 1px solid var(--line); border-radius: 9px;
  box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; display: none;
}
.suggestions.open { display: block; }
.suggestions div { padding: 9px 12px; cursor: pointer; font-size: 14px; }
.suggestions div small { color: var(--muted); }
.suggestions div.active, .suggestions div:hover { background: var(--accent-soft); }

/* ---- result ---- */
.result h2 { margin: 0 0 2px; font-size: 22px; }
.result .where { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

.section-title { font-size: 15px; font-weight: 700; margin: 22px 0 6px; }

/* ---- параметры списком: текст и значение в одной строке (удобно копировать) ---- */
.kv { font-size: 14px; }
.kv .row { padding: 5px 0; border-bottom: 1px solid var(--line); }
.kv .row:last-child { border-bottom: 0; }
.kv .k { color: var(--text); }
.kv .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.kv .v.mono { font-weight: 500; }
.kv.frame {
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent-soft);
  padding: 4px 14px;
  margin-bottom: 12px;
}
.kv.frame .row { border-bottom-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.kv.frame .row:last-child { border-bottom: 0; }

/* ---- сводная помесячная таблица ---- */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 2px; }
table.data { border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { border: 1px solid var(--line); padding: 6px 9px; white-space: nowrap; }
table.data thead th { background: var(--accent-soft); font-weight: 600; text-align: center; }
table.data tbody th { font-weight: 400; text-align: left; white-space: normal; min-width: 210px; position: sticky; left: 0; background: var(--card); }
table.data td.v { text-align: right; font-variant-numeric: tabular-nums; }
table.months td.v { text-align: center; }

.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.toolbar { display: flex; gap: 10px; margin: 16px 0 0; flex-wrap: wrap; }
button.btn {
  font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
}
button.btn:hover { border-color: var(--accent); color: var(--accent); }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.btn.primary:hover { filter: brightness(1.08); color: #fff; }

/* ---- калькулятор ---- */
.block-title { font-size: 16px; font-weight: 700; margin: 0 0 12px; }
h3.block-title { font-size: 14px; margin: 22px 0 8px; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.field-note { font-size: 13px; color: var(--muted); line-height: 1.4; }
table.data tfoot th, table.data tfoot td { background: var(--accent-soft); font-weight: 700; }
table.data tfoot th { text-align: right; white-space: normal; position: static; min-width: 0; }
table.inputs td { padding: 4px 6px; }
table.inputs input {
  width: 100%; min-width: 90px; padding: 7px 8px; font: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--text);
}
table.inputs input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
#out p { margin: 6px 0; }
#out .kv { margin-top: 12px; }

footer.site { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 20px; }

@media print {
  header.site nav, .controls, .toolbar, .notice { display: none; }
  .card { box-shadow: none; border: none; padding: 0; }
  .scroll-x { overflow: visible; }
  table.data { font-size: 9px; }
  table.data tbody th { min-width: 0; position: static; }
  body { background: #fff; }
}
