/* Базовые стили калькуляторов: токены темы, карточки, кнопки, таблицы, графики */

:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --success-text:   #006300;

  --series-1: #2a78d6; /* blue    */
  --series-2: #eb6834; /* orange  */
  --series-3: #1baf7a; /* aqua    */
  --series-4: #eda100; /* yellow  */
  --series-5: #e87ba4; /* magenta */
  --series-6: #008300; /* green   */
  --series-7: #4a3aa7; /* violet  */
  --series-8: #e34948; /* red     */

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --card-bg: #ffffff;
  --input-bg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);
    --success-text:   #0ca30c;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;

    --card-bg: #232322;
    --input-bg: #232322;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page-plane:     #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);
  --success-text:   #0ca30c;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;

  --card-bg: #232322;
  --input-bg: #232322;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
body { padding: 24px; }
.wrap { max-width: 1240px; margin: 0 auto; }

.topbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
h1 { font-size: 22px; margin: 0 0 4px 0; font-weight: 650; }
.subtitle { color: var(--text-secondary); font-size: 14px; margin: 0; max-width: 640px; }
.theme-toggle {
  border: 1px solid var(--border); background: var(--card-bg); color: var(--text-secondary);
  border-radius: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer;
}

.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin: 0 0 12px 0; font-weight: 650; }
.card h2 .hint { font-weight: 400; color: var(--text-muted); font-size: 12px; }

.dropzone {
  border: 1.5px dashed var(--baseline); border-radius: 10px; padding: 22px;
  text-align: center; color: var(--text-secondary); font-size: 13.5px;
  background: var(--surface-1); cursor: pointer; transition: border-color .15s;
}
.dropzone.drag { border-color: var(--series-1); color: var(--text-primary); }
.dropzone strong { color: var(--series-1); }
input[type=file] { display: none; }

.filelist { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.filerow {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; padding: 8px 10px; border-radius: 8px; background: var(--surface-1);
}
.filerow .meta { color: var(--text-secondary); }
.filerow button {
  border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 16px;
  line-height: 1; padding: 2px 6px;
}
.filerow button:hover { color: var(--status-critical); }

.btn {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer; font-weight: 550;
}
.btn:hover { border-color: var(--series-1); }
.btn.primary { background: var(--series-1); color: #fff; border-color: var(--series-1); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.filters {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px;
}
.filters .group { display: flex; gap: 4px; background: var(--surface-1); border-radius: 9px; padding: 3px; }
.filters .group button {
  border: none; background: none; color: var(--text-secondary); font-size: 12.5px;
  padding: 6px 11px; border-radius: 7px; cursor: pointer;
}
.filters .group button.active { background: var(--card-bg); color: var(--text-primary); box-shadow: 0 1px 2px var(--border); font-weight: 600; }
.filters select, .filters input[type=text], .filters input[type=date] {
  border: 1px solid var(--border); background: var(--input-bg); color: var(--text-primary);
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px;
}

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 980px) { .kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 620px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px;
}
.kpi .label { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.kpi .value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.kpi .value.good { color: var(--success-text); }
.kpi .value.bad { color: var(--status-critical); }
.kpi .delta { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }


svg text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.axis-label { fill: var(--text-muted); font-size: 11px; }
.cat-label { fill: var(--text-primary); font-size: 12px; }
.val-label { fill: var(--text-secondary); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.grid-line { stroke: var(--gridline); stroke-width: 1; }
.base-line { stroke: var(--baseline); stroke-width: 1; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2; background: var(--card-bg);
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--gridline);
  cursor: pointer; white-space: nowrap;
}
thead th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
thead th:hover { color: var(--text-primary); }
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--gridline); vertical-align: middle; }
tbody tr:hover { background: var(--surface-1); }
tfoot td {
  position: sticky; bottom: 0; z-index: 2; background: var(--surface-1);
  padding: 10px; font-weight: 700; border-top: 1px solid var(--gridline); border-bottom: none;
}
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
}
.badge.good { color: var(--status-good); background: color-mix(in srgb, var(--status-good) 14%, transparent); }
.badge.critical { color: var(--status-critical); background: color-mix(in srgb, var(--status-critical) 14%, transparent); }
.table-scroll { max-height: 480px; overflow-y: auto; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13.5px; }
.note { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-top: 10px; }
.search-input { flex: 1; min-width: 160px; }

.tooltip {
  position: fixed; pointer-events: none; background: var(--text-primary); color: var(--surface-1);
  font-size: 12px; padding: 8px 10px; border-radius: 8px; z-index: 50; opacity: 0; transition: opacity .08s;
  max-width: 260px; line-height: 1.5;
}
.tooltip .row { display: flex; justify-content: space-between; gap: 10px; }
.tooltip .row strong { font-variant-numeric: tabular-nums; }
.tooltip .title { font-weight: 650; margin-bottom: 4px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }
.legend .item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend .swatch.line { width: 14px; height: 2px; border-radius: 1px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--baseline); border-radius: 4px; }

/* ---------------------- Шапка сайта и список калькуляторов ---------------------- */

.site-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-bottom: 14px; margin-bottom: 22px; border-bottom: 1px solid var(--border);
}
.site-head .brand {
  font-size: 14px; font-weight: 650; color: var(--text-primary);
  text-decoration: none; letter-spacing: -0.01em;
}
.site-head nav { display: flex; gap: 14px; align-items: center; }
.site-head nav a { font-size: 13px; color: var(--text-secondary); text-decoration: none; }
.site-head nav a:hover { color: var(--text-primary); }

.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.calc-tile {
  display: block; text-decoration: none; color: inherit;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; transition: border-color .15s, transform .15s;
}
.calc-tile:hover { border-color: var(--series-1); transform: translateY(-1px); }
.calc-tile h3 { margin: 0 0 6px 0; font-size: 15px; font-weight: 650; }
.calc-tile p { margin: 0; font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.calc-tile .tag {
  display: inline-block; margin-top: 10px; font-size: 11.5px; font-weight: 600;
  color: var(--series-1); background: color-mix(in srgb, var(--series-1) 12%, transparent);
  border-radius: 999px; padding: 2px 9px;
}
.calc-tile.soon { opacity: .55; pointer-events: none; }
.calc-tile.soon .tag { color: var(--text-muted); background: var(--surface-1); }

.site-foot {
  margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted); display: flex; gap: 14px; flex-wrap: wrap;
}
.site-foot a { color: var(--text-muted); }
