:root {
  --bg: #0c1410;
  --nav: #101a15;
  --panel: #15211b;
  --text: #e7f0ea;
  --muted: #8aa396;
  --line: #24362d;
  --border: #24362d;
  --accent: #3dce7a;
  --chip: #1b2b23;
  --nav-hover: #1a2a22;
  --nav-on: #1c3a2a;
  --ok: #3dce7a;
  --bad: #ff6b6b;
  --warn: #f0a03c;
  --ident: #e06030;
  --ident-ok: #5aa8ff;
  --ident-ok-glow: rgba(90, 168, 255, 0.45);
  --shadow: 0 18px 40px #0006;
  --glow:
    0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent),
    0 12px 32px color-mix(in srgb, var(--accent) 28%, transparent);
  --glow-in: .34s;
  --glow-out: .5s;
  --ease: cubic-bezier(.22, .8, .28, 1);
  --font: "IBM Plex Sans", Manrope, system-ui, sans-serif;
}

html[data-theme="meadow"] {
  --bg: #eef4f0;
  --nav: #f7fbf8;
  --panel: #ffffff;
  --text: #14241c;
  --muted: #5d7268;
  --line: #d5e4db;
  --border: #d5e4db;
  --accent: #1f8a4c;
  --chip: #e7f3ec;
  --nav-hover: #e8f6ee;
  --nav-on: #d8f3e3;
  --ok: #1f8a4c;
  --bad: #d64545;
  --warn: #e08a1a;
  --ident: #c05621;
  --ident-ok: #2b7de9;
  --ident-ok-glow: rgba(43, 125, 233, 0.35);
  --shadow: 0 14px 34px #14241c12;
  --glow:
    0 0 0 3px color-mix(in srgb, var(--accent) 13%, transparent),
    0 10px 26px color-mix(in srgb, var(--accent) 22%, transparent);
  --font: Manrope, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(800px 380px at 100% -20%, #163226 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
html[data-theme="meadow"] body {
  background:
    radial-gradient(900px 420px at 0% -10%, #d9f4e4 0%, transparent 60%),
    var(--bg);
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--nav);
  border-right: 1px solid var(--line);
  padding: 14px 12px 12px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  height: 100vh;
}
html[data-theme="grove"] .sidebar,
:root:not([data-theme="meadow"]) .sidebar { background: #0e1713; }
html[data-theme="meadow"] .sidebar { background: #f4faf6; }
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 14px;
  text-decoration: none;
  color: inherit;
}
.brand img { width: 40px; height: 40px; border-radius: 12px; }
.brand strong { display: block; font-size: 1.02rem; letter-spacing: -.02em; }
.brand em { display: block; font-style: normal; color: var(--muted); font-size: 12px; font-weight: 600; }
.search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 9px;
  margin: 0 4px 10px;
  transition: border-color var(--glow-out) var(--ease), box-shadow var(--glow-out) var(--ease);
}
.search:hover, .search:focus-within {
  border-color: var(--accent);
  box-shadow: var(--glow);
  transition-duration: var(--glow-in);
}
.search svg { width: 15px; height: 15px; flex: 0 0 auto; color: var(--muted); }
.search input {
  border: 0;
  outline: none;
  background: transparent;
  width: 100%;
  min-width: 0;
  padding: 0;
  font-size: 13px;
  font-weight: 650;
  color: inherit;
}
.search input::-webkit-search-cancel-button { display: none; }
.search kbd {
  font-size: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 4px;
  color: var(--muted);
}
.search button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 15px; line-height: 1; padding: 2px 3px; border-radius: 6px;
}
.search button:hover { color: var(--bad); background: var(--chip); }
.menu { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow: auto; }
.menu-label {
  margin: 10px 10px 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 12px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.nav-btn svg { width: 20px; height: 20px; flex: 0 0 auto; }
.nav-btn:hover { background: var(--nav-hover); color: var(--text); }
.nav-btn.is-on, .nav-btn.active { background: var(--nav-on); color: var(--accent); }
.nav-btn .badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--warn);
  color: #fff;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.side-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.side-foot .nav-btn { position: relative; }
.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 4px;
}
.ava {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  color: var(--accent); font-weight: 800;
}
.user-row b { display: block; }
.user-row small { display: block; color: var(--muted); font-size: 11px; }
.jobs-card {
  margin: 2px 4px 6px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: inherit;
  text-align: left;
  width: calc(100% - 8px);
  cursor: pointer;
  transition:
    border-color var(--glow-out) var(--ease),
    box-shadow var(--glow-out) var(--ease);
}
.jobs-card:hover {
  border-color: var(--accent);
  box-shadow: var(--glow);
  transition-duration: var(--glow-in);
}
.jobs-card-h { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 13px; }
.jobs-card-h .beacon {
  width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: 0 0 auto;
}
.jobs-card.is-run .beacon, .jobs-card.state-running .beacon { background: var(--ident-ok); animation: jobs-pulse 1.2s infinite; }
.jobs-card.is-ok .beacon, .jobs-card.state-done .beacon { background: var(--ok); }
.jobs-card.is-warn .beacon, .jobs-card.state-partial .beacon { background: var(--warn); }
.jobs-card.is-bad .beacon, .jobs-card.state-error .beacon { background: var(--bad); }
.jobs-card.state-ident .beacon { background: var(--ident); }
.jobs-card-h b { margin-left: auto; font-size: 11px; color: var(--muted); font-weight: 700; }
.jobs-last { margin-top: 7px; font-size: 11px; color: var(--muted); line-height: 1.35; text-align: left; }
.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px 0;
}
.crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  color: var(--muted); font-size: 1.18rem; font-weight: 700; min-width: 0;
}
.crumbs a { color: var(--accent); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .path-sep { color: var(--line); font-weight: 500; }
.crumbs b, .crumbs .path-here { color: var(--text); font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; }
.crumbs .id-mark { margin-left: 8px; }
@media (max-width: 640px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .crumbs b, .crumbs .path-here { font-size: 1.4rem; }
}
.app-main { min-width: 0; }
#app { padding: 16px 28px 48px; min-width: 0; }
.meter-path, .path-with-marks { display: none; }

header h1 { margin: 0 0 4px; font-size: 1.6rem; }
.brand { color: inherit; text-decoration: none; }
.subtitle { color: var(--muted); margin: 0; }
.user-chip {
  color: var(--muted);
  font-size: 0.9rem;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-block { margin: 18px 0; }
.search-block h2 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.search-block h2 span { color: var(--muted); font-weight: 700; font-size: 13px; }
mark {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: inherit; border-radius: 4px; padding: 0 2px; font-weight: 800;
}

.login-wrap {
  max-width: 420px;
  margin: 10vh auto 0;
  padding: 20px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-hint { margin: 16px 0 0; }
.jobs-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}
.jobs-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
}
.jobs-btn.state-running .jobs-dot {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(61,139,253,0.7);
  animation: jobs-pulse 1.2s infinite;
}
.jobs-btn.state-done .jobs-dot { background: var(--ok); }
.jobs-btn.state-partial .jobs-dot { background: var(--warn); }
.jobs-btn.state-error .jobs-dot { background: var(--bad); }
.jobs-btn.state-ident .jobs-dot { background: var(--ident); }
@keyframes jobs-pulse {
  0% { box-shadow: 0 0 0 0 rgba(61,139,253,0.55); }
  70% { box-shadow: 0 0 0 10px rgba(61,139,253,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,139,253,0); }
}
.jobs-btn.state-cancelled .jobs-dot { background: var(--muted); }
.jobs-btn.has-inbox .jobs-dot { background: var(--ident); }
.inbox-wrap { position: relative; }
.inbox-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  width: min(420px, calc(100vw - 32px));
  max-height: min(60vh, 440px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  z-index: 40;
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
}
.inbox-head { font-weight: 650; margin-bottom: 10px; }
.inbox-item {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}
.inbox-item:first-of-type { border-top: none; padding-top: 0; }
.inbox-item a { color: inherit; font-weight: 650; }
.inbox-actions { margin-top: 6px; display: flex; gap: 8px; }
.inbox-actions .inbox-dismiss { padding: 4px 10px; font-size: 13px; }
.cov-name .id-mark, .cov-group .id-mark { margin-left: 6px; }
.id-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  border-radius: 50%;
  border: 2px solid currentColor;
  line-height: 0;
  vertical-align: middle;
  flex: 0 0 auto;
  cursor: help;
}
.id-mark-icon {
  display: grid;
  place-items: center;
  line-height: 0;
  transform: none;
}
.id-mark svg { width: 13px; height: 13px; display: block; }
.id-ok, .id-stale {
  color: var(--ident-ok);
  box-shadow: 0 0 8px var(--ident-ok-glow);
}
.id-old, .id-never { color: var(--bad); }
.id-pause { color: var(--ident); }
.id-tip {
  display: none;
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  z-index: 40;
  width: max-content;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  white-space: normal;
  text-align: left;
  pointer-events: none;
}
.id-mark:hover .id-tip,
.id-mark:focus .id-tip { display: block; }
.path-crumb {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.path-with-marks {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.link-verify-btn {
  margin-left: 2px;
  padding: 5px 12px;
  font-size: 0.82rem;
}
.link-row dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.link-row dd .muted { margin-top: 0; }
.card-title .id-mark, .card-title-row .id-mark { margin-left: 8px; }
.jobs-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(58vh, 520px);
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--chip);
}
.jobs-list::-webkit-scrollbar {
  width: 8px;
}
.jobs-list::-webkit-scrollbar-track {
  background: var(--chip);
  border-radius: 99px;
}
.jobs-list::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 99px;
  border: 2px solid var(--chip);
}
.jobs-list::-webkit-scrollbar-thumb:hover {
  background: var(--ok);
}
.job-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--chip);
  min-width: 0;
  overflow: hidden;
}
.job-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.job-card .job-title {
  font-weight: 650;
  margin-bottom: 4px;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.job-card .job-meta {
  color: var(--muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.job-cancel {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(227, 93, 93, 0.55);
  color: #f0a0a0;
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 8px;
}
.job-cancel:hover { background: rgba(227, 93, 93, 0.12); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.toolbar-title .inline-title { min-width: 0; }
.crumb { margin-bottom: 10px; }
.crumb a { color: var(--accent); text-decoration: none; }

.card-list { display: grid; gap: 10px; }
.card-link {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: inherit;
  text-decoration: none;
  transition: border-color .15s;
}
.card-link:hover { border-color: var(--accent); }
.card-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.card-row .card-link { flex: 1; min-width: 0; }
.card-edit {
  flex: 0 0 42px;
  width: 42px;
  height: auto;
  min-height: 42px;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}
.card-edit:hover { border-color: var(--accent); color: #fff; }
.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.btn-add .plus {
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 700;
}
.add-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 76px;
  margin: 0 0 12px;
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 2.6rem;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
}
.add-tile:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.meter-group-block { margin-bottom: 22px; }
.meter-group-block h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}
.card-title { font-weight: 650; margin-bottom: 4px; }
.card-meta { color: var(--muted); font-size: 0.9rem; }

/* списки Рощи: таблица групп и строки счётчиков */
.list-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.list-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.list-tools input {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 13px;
  outline: none;
  min-width: 210px;
}
.list-tools input:focus { border-color: var(--accent); }
@media (max-width: 780px) {
  .list-tools { margin-left: 0; width: 100%; }
  .list-tools input { flex: 1; min-width: 0; }
}
button.add-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
}
button.add-btn svg { width: 20px; height: 20px; }

.row-list { display: flex; flex-direction: column; gap: 10px; }
.row-item {
  position: relative;
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 52px 14px 16px;
  color: inherit;
  text-decoration: none;
  transition:
    border-color var(--glow-out) var(--ease),
    box-shadow var(--glow-out) var(--ease);
}
.row-item:hover {
  border-color: var(--accent);
  box-shadow: var(--glow);
  transition-duration: var(--glow-in);
}
.row-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 12px; }
.row-name { font-size: 1.03rem; font-weight: 800; }
.row-sub { color: var(--muted); font-size: 13px; }
.row-marks { display: inline-flex; align-items: center; gap: 4px; }
.row-params {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 6px 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.row-params div { min-width: 0; }
.row-params dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.row-params dd { margin: 2px 0 0; font-weight: 700; font-size: 13px; overflow-wrap: anywhere; }

.grid-scroll { overflow-x: auto; padding-bottom: 4px; }
.grid-list { display: flex; flex-direction: column; gap: 8px; min-width: max-content; }
.grid-head, .grid-row {
  display: grid;
  grid-template-columns: var(--grid-cols);
  gap: 10px 14px;
  align-items: center;
}
.grid-head { padding: 0 16px 2px; }
.grid-head .cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 4px 0;
  border-radius: 6px;
}
.grid-head button.cell {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 4px 0;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  cursor: pointer;
}
.grid-head button.cell:hover { color: var(--accent); background: transparent; }
.grid-head .cell.is-sorted { color: var(--accent); }
.grid-head .cell i { font-style: normal; font-size: 12px; }
.grid-row {
  position: relative;
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  transition:
    border-color var(--glow-out) var(--ease),
    box-shadow var(--glow-out) var(--ease);
}
.grid-row:hover {
  border-color: var(--accent);
  box-shadow: var(--glow);
  transition-duration: var(--glow-in);
}
.grid-row > .row-link { position: absolute; inset: 0; border-radius: inherit; }
.grid-row > .row-link::after { content: none; }
.grid-row .cell { min-width: 0; font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.grid-row .cell a { position: relative; z-index: 2; }
.cell-meters { display: flex; flex-direction: column; gap: 3px; }
.cell-meters a {
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  border-radius: 6px;
  padding: 1px 4px;
  margin-left: -4px;
}
.cell-meters a:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.muted-note { color: var(--muted); font-weight: 650; }
.grid-row .cell-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.grid-row .cell-act {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  z-index: 2;
  opacity: 0;
  transition: opacity .18s var(--ease);
}
.grid-row:hover .cell-act, .grid-row:focus-within .cell-act { opacity: 1; }
@media (hover: none) { .grid-row .cell-act { opacity: 1; } }
.dot-warn { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: 0 0 auto; }
.row-link { position: static; color: inherit; text-decoration: none; }
button.row-ico {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  display: inline-grid;
  place-items: center;
}
button.row-ico:hover { border-color: var(--accent); color: var(--accent); background: var(--panel); }
button.row-ico svg { width: 13px; height: 13px; }

.col-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; margin: 4px 0 12px; }
.col-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  background: var(--panel);
  cursor: grab;
}
.col-row:hover, .col-row.is-over { border-color: var(--accent); box-shadow: var(--glow); }
.col-row.is-drag { opacity: .45; }
.col-row .grip { color: var(--muted); letter-spacing: 2px; font-size: 13px; line-height: 1; }
.col-row label { display: flex; align-items: center; gap: 9px; font-weight: 700; flex: 1; cursor: pointer; }
.col-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.col-row:has(input:disabled) { opacity: .5; }
.col-row:has(input:disabled) label { cursor: not-allowed; }

.pack {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 14px;
}
.pack-h {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 18px 0;
}
.pack-h h2, .pack-h h3 { margin: 0; font-size: 1.05rem; }
.pack-h p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.pack-h-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.pack-h-title .seg { flex: 0 0 auto; }
.corr-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  flex: 0 0 auto;
  width: max-content;
  max-width: 100%;
}
.clock-tz {
  width: 0;
  min-width: 100%;
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  text-align: right;
  overflow-wrap: anywhere;
}
.corr-seg button[data-corr="1"].active {
  background: #c9a227;
  color: #1a1408;
  border-color: transparent;
}
.pack-b { padding: 14px 18px 18px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.toolbar .filters { margin-left: auto; }
@media (max-width: 780px) { .toolbar .filters { margin-left: 0; } }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.grp-pick { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.pill-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pill-group + .pill-group {
  margin-left: 10px; padding-left: 12px;
  border-left: 1px solid var(--line);
}
button.pill-toggle {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 15px;
  font-weight: 750;
  font-size: 13px;
}
button.pill-toggle:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); color: var(--text); background: var(--panel); }
button.pill-toggle.is-on {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 38%, transparent);
}
html[data-theme="grove"] button.pill-toggle.is-on { color: #06210f; }
.cons-seg {
  display: inline-flex;
  gap: 4px;
  background: var(--chip);
  padding: 4px;
  border-radius: 999px;
  border: 0;
  overflow: visible;
}
.cons-seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 750;
}
.cons-seg button.is-on { background: var(--panel); color: var(--text); box-shadow: 0 2px 8px color-mix(in srgb, var(--text) 10%, transparent); }
.total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.total-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.total-sum { display: flex; align-items: center; gap: 12px; min-width: 0; }
.status-ico {
  width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--chip); color: var(--muted);
}
.status-ico > svg { width: 22px; height: 22px; display: block; }
.status-body { min-width: 0; }
.status-body strong { display: block; font-size: 14px; font-weight: 750; line-height: 1.25; }
.status-body .hint { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; overflow-wrap: anywhere; }
.total-sum .status-ico {
  width: 46px; height: 46px;
  background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok);
}
.total-sum .status-ico svg { width: 26px; height: 26px; }
.total-sum .status-body strong { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; }
.total-sum .status-body .hint { font-size: 13px; }
@media (max-width: 640px) { .total-sum .status-body strong { font-size: 22px; } }
@media (max-width: 720px) { .total-bar { flex-direction: column; align-items: stretch; } }
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
table.data {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}
table.data th, table.data td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
}
table.data th { color: var(--muted); font-size: 12px; font-weight: 750; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.when, table.data th.when { min-width: 11rem; white-space: nowrap; }
table.data td.status { white-space: nowrap; min-width: 12rem; }
table.data tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data.cons tbody tr { cursor: pointer; }
table.data.cons tbody tr:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
table.data.cons tbody tr.is-off td:not(.pick) { opacity: .42; }
table.data.cons td.pick, table.data.cons th.pick { width: 34px; padding: 4px 0 4px 8px; }
button.pick-btn {
  display: block; width: 22px; min-height: 38px; height: 100%;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--chip); cursor: pointer;
  padding: 0;
}
button.pick-btn:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--chip); }
button.pick-btn.is-on {
  background: var(--accent); border-color: transparent;
  box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 40%, transparent);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 800;
  background: var(--chip); color: var(--text);
}
.chip.idle { color: var(--muted); }

.form-sec { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.form-sec:first-of-type { border-top: 0; margin-top: 4px; padding-top: 0; }
.form-sec > h3 { margin: 0 0 4px; font-size: 15px; }
.form-sec .req { margin-left: 8px; color: var(--warn); font-size: 11px; font-weight: 800; }
.row3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 700px) { .row3 { grid-template-columns: 1fr; } }
.seg-pick { display: inline-flex; gap: 4px; background: var(--chip); border-radius: 999px; padding: 4px; flex-wrap: wrap; }
.seg-pick button {
  border: 0; background: transparent; color: var(--muted); border-radius: 999px;
  padding: 7px 14px; font-weight: 750; font-size: 13px;
}
.seg-pick button.is-on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
dialog.dlg-wide {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
}

.empty-state {
  text-align: center;
  padding: 34px 20px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 4%, var(--panel));
}
.empty-state .ico {
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}
.empty-state .ico svg { width: 24px; height: 24px; }
.empty-state h3 { margin: 0 0 6px; font-size: 1.1rem; }
.empty-state p { margin: 0 auto 14px; max-width: 34rem; color: var(--muted); line-height: 1.5; }
.empty-state .form-actions { justify-content: center; }
.empty-state a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 600;
}

.search-block h2 svg { width: 17px; height: 17px; color: var(--muted); }
.row-item mark { background: color-mix(in srgb, var(--accent) 32%, transparent); }

.meter-head { margin-bottom: 12px; }
.meter-tabs { margin-bottom: 12px; }
nav.meter-tabs {
  display: inline-flex;
  gap: 2px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  max-width: 100%;
}
nav.meter-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: .18s var(--ease);
}
nav.meter-tabs button svg { width: 16px; height: 16px; flex: 0 0 auto; }
nav.meter-tabs button:hover { color: var(--text); background: transparent; }
nav.meter-tabs button.is-on {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
html[data-theme="grove"] nav.meter-tabs {
  background: #15211b;
}
html[data-theme="grove"] nav.meter-tabs button.is-on {
  background: #1c3a2a;
  color: var(--accent);
}
#group-panel.panel,
#meter-panel.panel {
  background: transparent;
  border: 0;
  padding: 0;
}
.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
@media (max-width: 900px) { .status-strip { grid-template-columns: 1fr; } }
.status-strip article {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  min-width: 0;
}
.status-strip .status-ico {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--chip); color: var(--muted);
}
.status-strip .status-ico > svg { width: 22px; height: 22px; }
.status-strip article.tone-ok .status-ico { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.status-strip article.tone-warn .status-ico { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.status-strip article.tone-bad .status-ico { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.status-strip article.tone-ident .status-ico { background: color-mix(in srgb, var(--ident) 16%, transparent); color: var(--ident); }
.status-strip article.tone-idle .status-ico { color: var(--muted); }
.status-ico .ident-badge { background: transparent; border-color: currentColor; }
.ident-badge {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid currentColor;
  flex: 0 0 auto;
}
.ident-badge svg { width: 15px; height: 15px; display: block; }
.ident-badge.inline { width: 22px; height: 22px; }
.ident-badge.inline svg { width: 13px; height: 13px; }
.ident-badge.is-ok { color: var(--ident); }
.ident-badge.is-old, .ident-badge.is-never { color: var(--warn); }
.ident-badge.is-bad { color: var(--bad); }

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 16px;
  margin: 0 0 18px;
}
.kv dt {
  color: var(--muted);
  margin: 0;
}
.kv dd {
  margin: 0;
  word-break: break-word;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tab {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

main { max-width: none; width: 100%; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: none;
  width: 100%;
  overflow: visible;
}
.panel.active { display: block; }

.form-grid fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 0 0 14px;
  padding: 12px 14px 16px;
}
.form-grid legend { color: var(--muted); padding: 0 6px; }
.form-grid label {
  display: block;
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--muted);
}
.form-grid input,
.form-grid select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f131b;
  color: var(--text);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 12px; padding: 9px 14px; font-weight: 750;
  transition: transform .12s var(--ease), box-shadow .18s, background .18s, border-color .18s, filter .18s;
}
.btn:hover { border-color: var(--accent); box-shadow: var(--glow); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary {
  background: var(--accent); color: #fff; border-color: transparent;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn.primary:hover { filter: brightness(1.05); }
html[data-theme="grove"] .btn.primary {
  background: linear-gradient(180deg, #49d986, #2db368);
  color: #06210f;
}
.btn.ghost { background: transparent; }
.btn.danger { background: color-mix(in srgb, var(--bad) 12%, var(--panel)); color: var(--bad); border-color: transparent; }
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: 12px; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 8px; }
.icon-btn.sm svg { width: 13px; height: 13px; }
button {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  cursor: pointer;
  font-weight: 600;
}
button.nav-btn {
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  padding: 9px 12px;
  font-weight: 700;
}
button.nav-btn:hover { background: var(--nav-hover); color: var(--text); }
button.jobs-card {
  background: var(--panel);
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  font-weight: inherit;
}
button.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }

.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.muted { color: var(--muted); font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }
.help { color: var(--muted); font-size: 13px; line-height: 1.45; }
input.field-warn, select.field-warn {
  border-color: var(--warn);
  background: rgba(224, 168, 0, 0.08);
}
.field-warn-hint {
  display: block;
  color: var(--warn);
  font-size: 0.85rem;
  line-height: 1.35;
  margin: 6px 0 0;
}
.protocol-hint { margin: 0 0 12px; }
.protocol-banner {
  background: rgba(232, 176, 67, 0.12);
  border: 1px solid rgba(232, 176, 67, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  line-height: 1.45;
}
.protocol-banner strong { display: block; margin-bottom: 4px; }

.status-box, .readings-box {
  background: #0f131b;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-right: 6px;
}
.badge.ok { background: rgba(47,191,113,0.15); color: var(--ok); }
.badge.ident-ok {
  background: rgba(77, 184, 255, 0.16);
  color: var(--ident-ok);
  box-shadow: 0 0 10px var(--ident-ok-glow);
}
.badge.bad { background: rgba(227,93,93,0.15); color: var(--bad); }
.badge.warn { background: rgba(232,176,67,0.18); color: #e8b043; }
.badge.idle { background: rgba(154,163,181,0.15); color: var(--muted); }
.badge.ident { background: rgba(224,96,48,0.2); color: var(--ident); }

.link-status h3 { margin: 0 0 8px; font-size: 1.05rem; }
.link-row {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 6px 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  align-items: start;
}
.link-row:first-of-type { border-top: none; padding-top: 4px; }
.link-row dt { color: var(--muted); margin: 0; }
.link-row dd { margin: 0; }
.link-row .muted { display: block; margin-top: 4px; }
#dlg-identity,
#dlg-identity-replace { width: min(640px, 96vw); }
.identity-choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}
.identity-choice {
  display: grid;
  grid-template-columns: minmax(13.5rem, max-content) 1fr;
  gap: 8px 14px;
  align-items: center;
}
.identity-choice button {
  justify-self: start;
  white-space: nowrap;
}
.identity-choice .hint { margin: 0; }
.identity-choice button:disabled { opacity: 0.65; }
@media (max-width: 560px) {
  .identity-choice { grid-template-columns: 1fr; }
  .identity-choice button { white-space: normal; }
}
#dlg-poll {
  max-width: min(640px, calc(100vw - 24px));
  width: min(640px, calc(100vw - 24px));
}
#dlg-poll .dialog-form {
  max-height: min(82vh, 860px);
  overflow: auto;
}
#dlg-poll fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 0 8px;
  padding: 10px 12px 12px;
}
#dlg-poll legend { color: var(--muted); padding: 0 6px; }

.error {
  background: rgba(227,93,93,0.12);
  color: var(--bad);
  border: 1px solid rgba(227,93,93,0.35);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.form-actions.wrap { flex-wrap: wrap; }
.readings-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px 20px;
  flex-wrap: wrap;
}
.readings-head .form-actions { margin-top: 8px; }
.readings-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  justify-content: flex-end;
  margin-left: auto;
  padding-top: 10px;
}
.rd-filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.readings-filters label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.table-wrap {
  margin-top: 12px;
  width: 100%;
  overflow-x: auto;
}
.readings-table {
  width: 100%;
  border-collapse: collapse;
}
.readings-table th, .readings-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
.readings-table thead th.energy-group { text-align: center; border-bottom: 0; }
.readings-table th.col-energy {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.readings-table .col-t {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.readings-table .energy-sep,
.readings-table thead th.energy-group + th.energy-group,
.readings-table thead th.col-energy + th.col-energy {
  border-left: 1px solid var(--border);
}
.readings-table tr.bad td { background: rgba(227,93,93,0.06); }
.readings-table tr.missing td { opacity: 0.75; }
.readings-table tr.anomaly td {
  background: rgba(227,93,93,0.16);
  color: var(--bad);
}
.readings-table tr.anomaly td.col-status { font-weight: 600; }
.readings-table tr.spike td {
  background: rgba(224, 168, 0, 0.14);
  color: var(--warn);
}
.readings-table tr.spike td.col-status { font-weight: 600; }
.readings-table .col-when { width: 16%; }
.readings-table .col-kind { width: 12%; }
.readings-table .col-energy { width: 9%; }
.readings-table .col-status { width: 12%; }
.readings-table .col-actions { width: 8%; text-align: right; }
.readings-table .col-actions button {
  padding: 6px 10px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.pager-info { color: var(--muted); font-size: 0.9rem; }

.profile-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}
.profile-toolbar label { margin: 0; color: var(--muted); font-size: 0.85rem; }
.profile-toolbar input,
.profile-toolbar select {
  display: block;
  margin-top: 4px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f131b;
  color: var(--text);
}
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--chip);
  padding: 4px;
  border: 0;
  border-radius: 999px;
  overflow: visible;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: .18s var(--ease);
}
.seg button:last-child { border-right: 0; }
.seg button.is-on,
.seg button.active { background: var(--panel); color: var(--text); box-shadow: 0 2px 8px color-mix(in srgb, var(--text) 10%, transparent); }
button.correction-on {
  background: #c9a227;
  color: #1a1408;
  border-color: #e0a800;
}
.chart-wrap {
  width: 100%;
  height: 420px;
  margin-top: 8px;
  position: relative;
}
.chart-wrap canvas { width: 100% !important; height: 100% !important; }
#in-chart-wrap, #pf-chart-wrap { cursor: crosshair; user-select: none; touch-action: none; }
.chart-brush {
  position: absolute;
  background: rgba(61, 139, 253, 0.2);
  border-left: 1px solid rgba(61, 139, 253, 0.9);
  border-right: 1px solid rgba(61, 139, 253, 0.9);
  pointer-events: none;
  z-index: 2;
}
.in-nav { margin: 10px 0 2px; }
.in-nav-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.in-nav-head .secondary {
  padding: 4px 10px;
  font-size: 0.85rem;
  margin-left: auto;
}
.in-nav-body {
  position: relative;
  height: 56px;
  background: #0f131b;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.in-nav-body canvas {
  width: 100% !important;
  height: 100% !important;
}
.in-nav-win {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(61, 139, 253, 0.22);
  border: 1px solid rgba(61, 139, 253, 0.85);
  box-sizing: border-box;
  cursor: grab;
}
.in-nav-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 10px;
  background: rgba(61, 139, 253, 0.85);
  cursor: ew-resize;
}
.in-nav-handle-min { left: -1px; }
.in-nav-handle-max { right: -1px; }
.profile-events-title {
  margin: 16px 0 0;
  font-size: 1rem;
}
.profile-events td:first-child { width: 28px; }
.ev-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  vertical-align: middle;
}
.ev-dot.ev-gap { background: rgba(220, 53, 69, 0.85); }
.ev-dot.ev-clock { background: rgba(224, 168, 0, 0.95); }
.ev-dot.ev-off { background: rgba(139, 147, 167, 0.95); }
.series-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.series-toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.pf-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; }
.pf-bar-l, .pf-bar-r { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pf-legend {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 0 0 10px;
}
.pf-legend > .pill-group { justify-self: center; }
.pf-legend > .btn, .pf-legend > button { justify-self: end; }
.pf-legend .pill-toggle { display: inline-flex; align-items: center; gap: 7px; }
.pf-legend .pill-toggle i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.pf-hint { color: var(--muted); font-size: 12px; }
@media (max-width: 820px) {
  .pf-legend { grid-template-columns: 1fr; justify-items: start; }
  .pf-legend > .pill-group, .pf-legend > .btn, .pf-legend > button { justify-self: start; }
}
.pf-axis { color: var(--muted); font-size: 11px; font-weight: 750; margin: 0 0 4px; }
.pf-wrap {
  position: relative; overflow: hidden; touch-action: none; cursor: crosshair;
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
}
.pf-svg { display: block; width: 100%; }
.pf-grid { stroke: var(--line); stroke-width: 1; }
.pf-ax { fill: var(--muted); font-size: 11px; font-weight: 700; }
.pf-line { fill: none; stroke-width: 2; stroke-linecap: butt; stroke-linejoin: miter; }
.pf-line.hot { stroke-width: 4; }
.pf-line.thin { stroke-width: 1.4; }
.pf-layer { position: absolute; inset: 0; pointer-events: none; }
.pf-mark { fill: var(--text); opacity: .07; }
.pf-mark.is-sel { fill: var(--accent); opacity: .14; }
.pf-brush {
  position: absolute; top: 0; bottom: 0; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-left: 1px solid var(--accent); border-right: 1px solid var(--accent);
}
.pf-tip {
  position: absolute; top: 10px; transform: translateX(-50%); pointer-events: none; z-index: 2;
  display: grid; gap: 2px; min-width: 150px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 10px; box-shadow: 0 14px 34px #00000026; font-size: 12px;
}
.pf-tip .pf-tip-d { color: var(--muted); }
.pf-tip .pf-tip-r { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.pf-tip .pf-tip-r i { width: 8px; height: 8px; border-radius: 2px; }
.pf-tip .pf-tip-r b { margin-left: auto; font-variant-numeric: tabular-nums; }
.pf-tip .pf-tip-n { color: var(--muted); margin-top: 2px; white-space: pre-line; }
.pf-nav {
  position: relative; margin-top: 8px; overflow: hidden; touch-action: none; cursor: ew-resize;
  border: 1px solid var(--line); border-radius: 12px; background: var(--chip); height: 56px;
}
.pf-nav-win {
  position: absolute; top: 0; bottom: 0; cursor: grab;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-left: 2px solid var(--accent); border-right: 2px solid var(--accent);
}
.pf-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pf-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--chip); border-radius: 999px; padding: 6px 12px;
  font-size: 12px; color: var(--muted); font-weight: 700;
}
.pf-chip i { width: 8px; height: 8px; border-radius: 2px; }
.pf-chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.month-grid {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  background: transparent;
  object-fit: contain;
}
.brand-name {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.brand .subtitle {
  display: block;
  margin-top: 2px;
  font-size: 0.85rem;
  font-weight: 400;
}
header h1 { display: none; }

.picker-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 122px;
  width: auto;
  max-width: 100%;
  margin-top: 0;
  padding: 8px 36px 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: left;
  overflow: hidden;
  box-sizing: border-box;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
label > .picker-btn { width: 100%; margin-top: 4px; }
.picker-btn:hover, .picker-btn:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  outline: none;
}
.picker-btn::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 0;
  bottom: 0;
  margin: auto 0;
  width: 18px;
  height: 18px;
  pointer-events: none;
  background-color: currentColor;
  opacity: .55;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Crect x='4' y='6' width='16' height='14' rx='2' stroke='black' stroke-width='1.8'/%3E%3Cpath d='M8 4v4M16 4v4M4 10h16' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: 18px 18px;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Crect x='4' y='6' width='16' height='14' rx='2' stroke='black' stroke-width='1.8'/%3E%3Cpath d='M8 4v4M16 4v4M4 10h16' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: 18px 18px;
}
.month-pick { display: inline-flex; align-items: center; gap: 8px; font-weight: 750; font-size: 13px; color: var(--muted); }
.picker-pop {
  position: fixed;
  inset: unset;
  margin: 0;
  z-index: 80;
  width: 268px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 60px #00000026;
  padding: 12px;
}
.picker-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.picker-nav-title {
  font-weight: 700;
  color: var(--text);
}
.picker-pop .icon-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
}
.picker-pop .icon-btn:hover {
  background: var(--chip);
  color: var(--text);
}
.month-pop-grid, .cal-grid {
  display: grid;
  gap: 4px;
}
.month-pop-grid { grid-template-columns: repeat(3, 1fr); }
.cal-grid { grid-template-columns: repeat(7, 1fr); }
.month-pop-grid button, .cal-grid button {
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  padding: 10px 0;
  border-radius: 12px;
  cursor: pointer;
  transition: .16s var(--ease);
}
.cal-grid button {
  aspect-ratio: 1;
  padding: 0;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}
.month-pop-grid button:hover, .cal-grid button:hover {
  background: var(--chip);
  color: var(--text);
}
.month-pop-grid button.active, .cal-grid button.active {
  background: var(--accent);
  color: #fff;
}
.cal-grid button.muted-day { color: var(--muted); opacity: 0.45; }
.cal-dow {
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  padding: 4px 0;
}

.jobs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}
.jobs-head h3 { margin: 0; }
.jobs-hint { margin: 0; flex-shrink: 0; }
.job-card .job-progress {
  height: 4px;
  background: #0f131b;
  border-radius: 99px;
  margin-top: 8px;
  overflow: hidden;
}
.job-card .job-progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
}

.notice {
  background: rgba(61,139,253,0.12);
  color: var(--text);
  border: 1px solid rgba(61,139,253,0.35);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
}

.chart-legend-hint { margin-top: 8px; }

.journal-group { margin: 18px 0 28px; }
.journal-group h3 { margin: 0 0 10px; font-size: 1.05rem; }
.journal-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.journal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.vector-wrap { margin: 16px 0 8px; }
.vector-wrap svg {
  background: #0f131b;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: block;
}
.switch-row { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.identity-opts { margin: 10px 0 0; }
.identity-opts summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.identity-opts-list {
  margin: 8px 0 0;
  padding-left: 1.2em;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}
.identity-opts-list li { margin: 6px 0; }
.sch-row { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
.sch-row .muted { grid-column: 1; }
.sch-row-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}
.sch-tz-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
}
.sch-tz-label select {
  max-width: 220px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f131b;
  color: var(--text);
}
.schedule-clock { color: var(--muted); margin-bottom: 10px; }
.day-picks { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 10px; }
.day-picks label { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); }
.month-days label { min-width: 42px; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    gap: 10px;
  }
  .side-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
  }
  .side-nav a { white-space: nowrap; }
}
@media (max-width: 640px) {
  .kv { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .brand-name { font-size: 1.05rem; }
  .sch-row { grid-template-columns: 1fr; }
  .sch-row-actions { grid-column: 1; grid-row: auto; justify-self: start; flex-wrap: wrap; }
  .readings-filters { justify-content: flex-start; margin-left: 0; }
}

.manual-grid {
  display: grid;
  grid-template-columns: 36px repeat(5, minmax(72px, 1fr));
  gap: 6px 8px;
  align-items: center;
  margin: 8px 0 12px;
}
.manual-grid span { color: var(--muted); font-size: 0.85rem; text-align: center; }
.manual-grid > span:nth-child(6n+1) { text-align: left; }
.manual-grid input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f131b;
  color: var(--text);
}
#dlg-manual { width: min(760px, 96vw); }

dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  padding: 0;
  max-width: 480px;
  width: calc(100% - 24px);
  overflow: visible;
}
#dlg-rd-poll {
  max-width: 560px;
  width: min(560px, calc(100% - 24px));
}
#dlg-rd-poll .dialog-form { max-height: min(86vh, 760px); overflow: auto; }
#dlg-rd-poll .poll-block {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--chip);
  box-shadow: none;
}
#dlg-rd-poll .poll-block b { color: var(--text); font-size: 14px; }
#dlg-rd-poll .poll-block .btn.primary { justify-self: start; }
#dlg-rd-poll .row2 > .picker-btn { width: 100%; }
#dlg-jobs {
  max-width: min(780px, calc(100vw - 24px));
  width: min(780px, calc(100vw - 24px));
  overflow: hidden;
}
#dlg-jobs .jobs-dialog {
  min-width: 0;
  width: 100%;
  max-height: min(82vh, 740px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overflow-x: hidden;
}
#dlg-jobs .form-actions { flex-shrink: 0; margin-top: 4px; }
dialog::backdrop { background: rgba(0,0,0,0.55); }
.dialog-form { padding: 18px 20px 20px; display: grid; gap: 10px; }
.dialog-form h3 { margin: 0 0 4px; }
.dialog-form label { display: block; color: var(--muted); font-size: 0.9rem; }
.dialog-form input, .dialog-form select {
  display: block; width: 100%; margin-top: 4px;
  padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: #0f131b; color: var(--text);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
button.danger { background: var(--bad); }

.dialog-form label.check-row {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px; color: var(--text);
}
.dialog-form label.check-row input {
  display: inline-block; width: auto; margin: 0;
}

.clock-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 10px 14px;
  margin: 0 0 14px;
  padding: 10px 12px;
  background: #151a24;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.clock-bar-meta { color: var(--muted); font-size: 0.9rem; flex: 1 1 240px; }
.clock-bar #clock-correct { flex: 0 0 auto; }
.clock-card {
  margin: 12px 0 20px;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.clock-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.clock-card label { color: var(--muted); font-size: 0.9rem; }
.clock-card select {
  display: block;
  margin-top: 4px;
  min-width: 220px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f131b;
  color: var(--text);
}

.group-meters-head {
  margin: 28px 0 12px;
  font-size: 1.05rem;
}
.consumption-hero {
  background: #0f131b;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 4px 0 14px;
}
.consumption-hero-value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 6px;
}
.consumption-table .col-check {
  width: 2.4rem;
  text-align: center;
  vertical-align: middle;
}
.consumption-table .col-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.consumption-table tr.off { opacity: 0.45; }
.consumption-hero-note {
  margin-top: 8px;
  font-size: 0.82rem;
  line-height: 1.35;
  color: #ff5a5a;
}
.consumption-table .when-off {
  color: #ff3b3b;
  font-weight: 700;
}
.cov-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 12px;
}
.cov-period {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cov-period strong { min-width: 3.2em; text-align: center; }
.cov-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 12px;
}
.cov-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
  margin-right: 5px;
}
.cov-dot.full, .cov-cell.full { background: var(--ok); }
.cov-dot.part, .cov-cell.part { background: var(--warn); }
.cov-dot.none, .cov-cell.none { background: #2a3142; border: 1px solid var(--border); }
.cov-dot.anom, .cov-cell.anom { background: var(--bad); }
.cov-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.cov-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 720px;
}
.cov-table th, .cov-table td {
  padding: 7px 6px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.cov-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
.cov-table .cov-name { text-align: left; padding-left: 12px; white-space: nowrap; min-width: 220px; }
.cov-table .cov-name a { color: var(--accent); text-decoration: none; }
.cov-search {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  font-weight: 600;
  color: var(--muted);
}
.cov-search input {
  width: min(280px, 40vw);
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f131b;
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
.cov-group td {
  text-align: left;
  padding: 10px 12px 6px;
  color: var(--text);
  font-weight: 650;
  background: #151a24;
}
.cov-group a { color: inherit; text-decoration: none; }
.cov-cell {
  width: 28px;
  height: 18px;
  border-radius: 4px;
  padding: 0;
  border: 0;
  cursor: pointer;
  display: block;
  margin: 0 auto;
}
.cov-cell.cov-future { opacity: 0.35; }
.cov-cell:hover { outline: 2px solid var(--accent); }

.sms-template {
  margin: 10px 0 0;
  padding: 10px 12px;
  background: #0f131b;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
}
.sms-box { background: var(--chip); border-radius: 14px; padding: 14px; }
.sms-out {
  margin-top: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  white-space: pre-wrap; overflow-wrap: anywhere; min-height: 44px;
}
.steps-flow { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; }
.steps-flow li { display: flex; gap: 10px; align-items: flex-start; list-style: none; color: var(--muted); font-size: 13px; }
.steps-flow b {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px;
  background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent);
}
.ports-host { margin: 12px 0 20px; max-width: 520px; }
.ports-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.port-input { width: 7rem; }
.protocol-banner pre { color: var(--text); }

.coach-back {
  position: fixed; inset: 0; z-index: 70;
  background: color-mix(in srgb, #000 62%, transparent);
  animation: fade .2s var(--ease);
}
.coach-hole {
  position: fixed; z-index: 71; border-radius: 14px; pointer-events: none;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px color-mix(in srgb, #000 62%, transparent), 0 0 0 6px color-mix(in srgb, var(--accent) 35%, transparent);
  animation: hole .5s var(--ease) infinite alternate;
}
.coach-box {
  position: fixed; z-index: 72; width: min(340px, calc(100vw - 32px));
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 18px; box-shadow: 0 24px 60px #0006;
  animation: pop .24s var(--ease);
}
.coach-box .step { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.coach-box h3 { margin: 4px 0 6px; font-size: 1.05rem; }
.coach-box p { margin: 0 0 12px; color: var(--muted); line-height: 1.45; font-size: 13px; }
.coach-box .form-actions { margin: 0; }
.coach-arrow {
  position: fixed; z-index: 72; color: var(--accent); pointer-events: none;
  animation: nudge .9s var(--ease) infinite alternate;
}
.coach-arrow svg { width: 34px; height: 34px; }
@keyframes hole {
  from { box-shadow: 0 0 0 9999px color-mix(in srgb, #000 62%, transparent), 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent); }
  to { box-shadow: 0 0 0 9999px color-mix(in srgb, #000 62%, transparent), 0 0 0 10px color-mix(in srgb, var(--accent) 12%, transparent); }
}
@keyframes nudge { from { transform: translateY(-3px); } to { transform: translateY(3px); } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 640px) {
  .kv { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
}
