/* Intekey Monitor — оформление панели */

:root {
  color-scheme: light;
  --surface-0: #f4f3f0;
  --surface-1: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e0da;
  --border-strong: #cfccc4;
  --text-primary: #14140f;
  --text-secondary: #52514e;
  --text-muted: #86847d;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #4a3aa7;

  --seq-100: #cde2fb;
  --seq-200: #9ec5f4;
  --seq-300: #6da7ec;
  --seq-400: #3987e5;
  --seq-500: #256abf;
  --seq-600: #184f95;
  --seq-700: #0d366b;

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

  --grid: #e6e4de;
  --shadow: 0 1px 2px rgba(20, 20, 15, .05), 0 8px 24px rgba(20, 20, 15, .04);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --border: #333331;
    --border-strong: #454542;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8d8c83;

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

    --seq-100: #0d366b;
    --seq-200: #184f95;
    --seq-300: #256abf;
    --seq-400: #2a78d6;
    --seq-500: #5598e7;
    --seq-600: #86b6ef;
    --seq-700: #b7d3f6;

    --grid: #2e2e2b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #111110;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --border: #333331;
  --border-strong: #454542;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8d8c83;

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

  --seq-100: #0d366b;
  --seq-200: #184f95;
  --seq-300: #256abf;
  --seq-400: #2a78d6;
  --seq-500: #5598e7;
  --seq-600: #86b6ef;
  --seq-700: #b7d3f6;

  --grid: #2e2e2b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: ui-sans-serif, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }

button, select, input { font: inherit; color: inherit; }

.app { max-width: 1560px; margin: 0 auto; padding: 0 24px 64px; }

/* ------------------------------ шапка ------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface-0) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  margin: 0 -24px 20px;
  padding: 14px 24px 0;
}

.topbar__row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.brand__mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(140deg, var(--seq-400), var(--seq-600));
  display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700;
  align-self: center;
}
.brand__name { font-size: 17px; font-weight: 650; }
.brand__sub { color: var(--text-muted); font-size: 12px; }

.meta-line { color: var(--text-muted); font-size: 12px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.meta-line b { color: var(--text-secondary); font-weight: 500; }

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 0 14px;
}

.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 2px; }
.segmented button {
  border: 0; background: transparent; color: var(--text-secondary);
  padding: 6px 13px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500;
}
.segmented button[aria-pressed="true"] { background: var(--surface-1); color: var(--text-primary); box-shadow: var(--shadow); }
.segmented button:hover:not([aria-pressed="true"]) { color: var(--text-primary); }

.field { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12px; }
.field select, .field input {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 9px; color: var(--text-primary); font-size: 13px;
}

.btn {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 13px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-primary);
  display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--border-strong); }
.btn--primary { background: var(--seq-500); border-color: var(--seq-500); color: #fff; }
.btn--primary:hover { background: var(--seq-600); border-color: var(--seq-600); }
.btn[disabled] { opacity: .55; cursor: default; }

.spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------ секции ----------------------------- */

.section { margin-bottom: 26px; }
.section__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.section__head h2 { font-size: 15px; }
.section__hint { color: var(--text-muted); font-size: 12px; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.grid-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.tile { display: flex; flex-direction: column; gap: 6px; }
.tile__label { color: var(--text-muted); font-size: 12px; }
.tile__value { font-size: 27px; font-weight: 640; letter-spacing: -0.02em; line-height: 1.1; }
.tile__value small { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-left: 3px; }
.tile__foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }

.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 550; }
.delta--up { color: var(--good); }
.delta--down { color: var(--critical); }
.delta--flat { color: var(--text-muted); }

/* ------------------------------ таблица ---------------------------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 9px 10px; text-align: right; white-space: nowrap; }
table.data th {
  color: var(--text-muted); font-weight: 500; font-size: 12px;
  border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; position: sticky; top: 0;
  background: var(--surface-1);
}
table.data th:hover { color: var(--text-primary); }
table.data th.is-sorted { color: var(--text-primary); }
table.data td { border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data td:first-child, table.data th:first-child { text-align: left; position: sticky; left: 0; background: var(--surface-1); }
table.data tbody tr:hover td:first-child { background: var(--surface-2); }
table.data tbody tr { cursor: pointer; }
table.data tr.is-selected td, table.data tr.is-selected td:first-child { background: color-mix(in srgb, var(--seq-400) 10%, var(--surface-1)); }

.who { display: flex; align-items: center; gap: 9px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.who__name { font-weight: 550; }

.bar-cell { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.bar-cell__track { display: block; width: 54px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar-cell__fill { display: block; height: 100%; border-radius: 3px; background: var(--seq-400); }

.score { display: inline-flex; align-items: center; gap: 7px; justify-content: flex-end; }
.score__pill {
  min-width: 34px; text-align: center; padding: 2px 7px; border-radius: 6px;
  font-weight: 600; font-size: 12px; font-variant-numeric: tabular-nums;
}
.score--high { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.score--mid { background: color-mix(in srgb, var(--warning) 22%, transparent); color: color-mix(in srgb, var(--warning) 80%, var(--text-primary)); }
.score--low { background: color-mix(in srgb, var(--critical) 16%, transparent); color: var(--critical); }
.score--none { color: var(--text-muted); }

/* ------------------------------ графики ---------------------------- */

.chart-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .chart-grid { grid-template-columns: minmax(0, 1fr); } }
.chart { position: relative; }
.chart__title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.chart__sub { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.chart svg { display: block; width: 100%; overflow: visible; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.legend__item[aria-pressed="false"] { opacity: .38; }
.legend__key { width: 14px; height: 3px; border-radius: 2px; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 20;
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow);
  min-width: 130px; opacity: 0; transition: opacity .1s;
}
.tooltip__title { color: var(--text-muted); margin-bottom: 5px; }
.tooltip__row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tooltip__row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.tooltip__key { display: inline-flex; align-items: center; gap: 6px; }

/* ------------------------------ карточки --------------------------- */

.dev-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.dev-card { display: flex; flex-direction: column; gap: 12px; cursor: pointer; border-left: 3px solid transparent; }
.dev-card:hover { border-color: var(--border-strong); }
.dev-card__head { display: flex; align-items: center; gap: 10px; }
.dev-card__name { font-weight: 600; }
.dev-card__role { font-size: 12px; color: var(--text-muted); }
.dev-card__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini { display: flex; flex-direction: column; }
.mini__value { font-size: 18px; font-weight: 620; font-variant-numeric: tabular-nums; }
.mini__label { font-size: 11px; color: var(--text-muted); }

/* ------------------------------ деталь ----------------------------- */

.detail { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1080px) { .detail { grid-template-columns: minmax(0, 1fr); } }

.quality-row { display: grid; grid-template-columns: 132px 1fr 44px; align-items: center; gap: 10px; padding: 5px 0; }
.quality-row__label { font-size: 12px; color: var(--text-secondary); }
.quality-row__track { display: block; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.quality-row__fill { display: block; height: 100%; border-radius: 4px; }
.quality-row__value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12px; }
.quality-row__detail { grid-column: 2 / -1; font-size: 11px; color: var(--text-muted); margin-top: -3px; }

.tasklist { max-height: 420px; overflow-y: auto; }
.tasklist table.data th { top: 0; }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; font-weight: 500;
  background: var(--surface-2); color: var(--text-secondary);
}
.tag--done { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.tag--wip { background: color-mix(in srgb, var(--seq-400) 16%, transparent); color: var(--seq-500); }

a { color: var(--seq-500); text-decoration: none; }
a:hover { text-decoration: underline; }

.empty { color: var(--text-muted); padding: 26px; text-align: center; font-size: 13px; }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  background: color-mix(in srgb, var(--warning) 10%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--warning) 30%, var(--border));
  border-radius: var(--radius); padding: 12px 14px; font-size: 12.5px; color: var(--text-secondary);
}
.notice b { color: var(--text-primary); font-weight: 600; }

.sync-log { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11.5px; color: var(--text-muted); }

.toggle-link { background: none; border: 0; color: var(--seq-500); cursor: pointer; padding: 0; font-size: 12px; }
.toggle-link:hover { text-decoration: underline; }

.progress { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress__fill { height: 100%; background: var(--seq-400); transition: width .3s; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
