@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/onest-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/onest-cyrillic.woff2') format('woff2');
  unicode-range: U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url('/fonts/jetbrains-mono-cyrillic.woff2') format('woff2');
  unicode-range: U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}

:root {
  /* Surfaces */
  --bg: #fafaf8;
  --paper: #ffffff;
  --tint: #f3f3f0;
  --tile-hover: #f7f7f4;
  --line: #e8e8e4;
  --line-2: #d8d8d3;
  --dash: #d8d8d3;
  --track: #e8e8e4;

  /* Ink */
  --ink: #141414;
  --ink-soft: #3b3b3b;
  --mute: #6a6a67;
  --mute-2: #757571;
  --on-ink: #ffffff;

  /* Accents: blue = links/focus, green = live, amber = attention, red = danger */
  --blue: #407ff2;
  --blue-bg: #eaf1fe;
  --blue-ink: #2563d6;
  --green: #15945a;
  --green-bg: #e6f6ed;
  --green-ink: #0f7a45;
  --amber: #a67109;
  --amber-bg: #fcf3df;
  --amber-ink: #8f5f00;
  --red: #d6453d;
  --red-bg: #fff3ef;
  --red-ink: #b9322b;

  /* Shape */
  --r: 14px;
  --r-sm: 9px;
  --pill: 999px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .03);
  --frame: 1180px;
  --pad: clamp(14px, 3vw, 40px);

  --sans: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  color-scheme: light;
}

.app {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  text-align: left;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); }
[hidden] { display: none !important; }
h1, h2, h3, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: var(--r-sm); }
svg { display: block; flex: none; }

.mono { font-family: var(--mono); letter-spacing: .02em; }
.muted { color: var(--mute); }
.faint { color: var(--mute-2); }
.accent { color: var(--blue-ink); }

/* Top bar: brand left, tabs center, session right */
.top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px var(--pad);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: inline-flex; align-items: center; gap: 9px; justify-self: start; min-width: 0; }
.brand-mark { width: 20px; height: 20px; color: var(--ink); }
.brand-word { font-family: var(--mono); font-weight: 500; font-size: 15px; letter-spacing: -0.02em; }
.brand-tag { font-size: 12px; color: var(--mute); white-space: nowrap; border-left: 1px solid var(--line); padding-left: 12px; margin-left: 3px; }
.tabs { display: flex; gap: 6px; justify-self: center; }
.tab {
  display: inline-flex; align-items: center;
  height: 30px; padding-inline: 14px;
  border-radius: var(--pill);
  background: var(--paper);
  border: 1px solid var(--line);
  font-size: 12px; color: var(--ink-soft);
  white-space: nowrap;
  transition: color .15s ease, background-color .15s ease, border-color .15s ease;
}
.tab:hover { color: var(--ink); border-color: var(--line-2); }
.tab[aria-current="page"] { background: var(--ink); color: var(--on-ink); border-color: transparent; }
.top-side { display: flex; align-items: center; gap: 8px; justify-self: end; min-width: 0; }

/* Page column */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px var(--pad) 64px;
  display: grid;
  gap: 26px;
  align-content: start;
}
.boot { display: grid; gap: 8px; padding: 48px 0; justify-items: center; }
.kicker {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase; color: var(--mute);
}
.kicker b { font-weight: 500; color: var(--blue-ink); }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-title { font-size: 25px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.section { display: grid; gap: 10px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.sec-title { font-size: 14.5px; font-weight: 600; letter-spacing: -0.01em; }
.meta { font-family: var(--mono); font-size: 11px; letter-spacing: .02em; color: var(--mute); }

/* Cards */
.card {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.card-tint { background: var(--tint); box-shadow: none; }
.card-flat { box-shadow: none; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

/* Label → value pairs */
.pairs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.pairs-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pair { display: grid; gap: 2px; min-width: 0; }
.pair-label { font-size: 11.5px; color: var(--mute); }
.pair-value { font-family: var(--mono); font-size: 16px; letter-spacing: -0.01em; }
.pair-value small { font-size: 11px; color: var(--mute); }

/* Progress bar */
.bar { height: 6px; border-radius: var(--pill); background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ink); border-radius: inherit; }
.row-bar { width: 90px; flex: none; }
.bar > span.ok { background: var(--green); }
.bar > span.warn { background: var(--amber); }
.bar > span.crit { background: var(--red); }
.bar > span.blue { background: var(--blue); }

/* Rows */
.rows { display: grid; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 10px;
  border-bottom: 1px solid var(--tint);
  font-size: 13px;
  min-width: 0;
}
.row:last-child { border-bottom: 0; }
.row-main { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.row-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--mute); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.row-value { font-family: var(--mono); font-size: 11px; letter-spacing: .02em; color: var(--mute); white-space: nowrap; }
.row-value b { font-weight: 500; color: var(--ink); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding-inline: 16px;
  border-radius: var(--pill);
  border: 1px solid transparent;
  background: var(--ink); color: var(--on-ink);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: #333333; }
.btn-ghost { background: var(--paper); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--tile-hover); border-color: var(--mute-2); }
.btn-danger { background: var(--red-bg); color: var(--red-ink); border-color: rgba(224, 96, 85, .35); }
.btn-danger:hover { background: #fde7e2; }
.btn-text { background: none; border-color: transparent; color: var(--mute); padding-inline: 8px; }
.btn-text:hover { color: var(--ink); background: none; }
.btn-sm { height: 28px; padding-inline: 12px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: default; pointer-events: none; }

/* States */
.dot { width: 7px; height: 7px; border-radius: var(--pill); background: var(--mute-2); flex: none; display: inline-block; }
.dot.ok { background: var(--green); }
.dot.warn { background: var(--amber); }
.dot.crit { background: var(--red); }
.dot.blue { background: var(--blue); }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding-inline: 9px; border-radius: var(--pill);
  background: var(--tint); color: var(--mute);
  font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: .02em;
  white-space: nowrap;
}
.chip.ok { background: var(--green-bg); color: var(--green-ink); }
.chip.warn { background: var(--amber-bg); color: var(--amber-ink); }
.chip.blue { background: var(--blue-bg); color: var(--blue-ink); }
.chip.crit { background: var(--red-bg); color: var(--red-ink); }
.chip.is-strong { background: var(--ink); color: var(--on-ink); }
.chip .dot { background: currentColor; }

/* Tables */
.table-wrap { overflow-x: auto; max-width: 100%; min-width: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; font-weight: 400;
  font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--mute);
  padding: 0 12px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--tint); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { font-family: var(--mono); font-size: 11.5px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.label { font-size: 12.5px; color: var(--mute); }
.label-hint { color: var(--mute-2); font-size: 11px; }
.input, .select, .textarea {
  min-height: 38px; width: 100%; padding: 8px 12px;
  border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--paper);
  font: inherit; color: var(--ink);
  transition: border-color .15s ease;
}
.textarea { min-height: 84px; resize: vertical; font-family: var(--mono); font-size: 12px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--mute-2); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); outline: 2px solid var(--blue-bg); outline-offset: 0; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--mute) 50%), linear-gradient(135deg, var(--mute) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 4px; }
.switch { width: 34px; height: 20px; border-radius: var(--pill); background: var(--line-2); position: relative; flex: none; transition: background-color .15s ease; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: var(--pill); background: var(--paper); transition: left .15s ease; }
.switch[aria-checked="true"] { background: var(--blue); }
.switch[aria-checked="true"]::after { left: 16px; }
.form-error { color: var(--red-ink); font-size: 12.5px; min-height: 18px; }
.form-summary { display: grid; gap: 6px; font-family: var(--mono); font-size: 11.5px; color: var(--mute); }
.form-summary b { color: var(--ink-soft); font-weight: 500; }

/* Batch detail job list */
.job-msg { color: var(--mute); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }

/* Toast */
.toast-zone { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 40; }
.toast {
  background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  padding: 10px 14px; font-size: 13px; max-width: 340px;
}
.toast.ok { border-color: rgba(63, 185, 122, .4); }
.toast.crit { border-color: rgba(224, 96, 85, .4); }

/* Confirm overlay */
.confirm {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(10, 10, 12, .6);
  display: grid; place-items: center;
  padding: 20px;
}
.confirm-card {
  background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 18px; width: min(380px, 100%);
  display: grid; gap: 10px;
}
.confirm-title { font-size: 15px; font-weight: 600; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.empty {
  border: 1px dashed var(--dash); border-radius: var(--r);
  padding: 22px; text-align: center; color: var(--mute); font-size: 13px;
}

@media (max-width: 1100px) {
  .top { grid-template-columns: 1fr auto; row-gap: 10px; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-self: start; }
  .top-side { grid-column: 2; grid-row: 1; }
}

@media (max-width: 860px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pairs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .top { grid-template-columns: 1fr auto; padding: 10px 14px; row-gap: 10px; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; overflow-x: auto; }
  .top-side { grid-column: 2; grid-row: 1; }
  .brand-tag { display: none; }
  .top-side { flex-wrap: wrap; max-width: 180px; justify-content: flex-end; gap: 4px; }
  #service-chip { max-width: 100%; height: auto; min-height: 22px; padding-block: 3px; white-space: normal; font-size: 9px; }
  #user-chip { max-width: 150px; overflow: hidden; text-overflow: ellipsis; display: block; line-height: 22px; }
  .tabs { gap: 5px; }
  .tab { flex: 1; justify-content: center; padding-inline: 10px; }
  .grid-2 { grid-template-columns: 1fr; }
  .main { padding: 16px 14px 48px; gap: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .tab, .btn, .input, .select, .textarea, .switch, .switch::after { transition: none; }
}
