:root {
  color-scheme: light;
  --bg: #eef8f1;
  --surface: #ffffff;
  --text: #0b2416;
  --text-2: #3f5a4a;
  --muted: #6b7f73;
  --line: #e2eee6;
  --grid: #e8efe9;
  --axis: #cddbd2;
  --green: #16a34a;
  --green-d: #0f7a37;
  --green-l: #d7f5e1;
  --green-xl: #f0fbf4;
  --mint: #34d399;
  /* Статусы: фиксированные цвета, всегда вместе со значком и подписью */
  --st-good: #16a34a;
  --st-critical: #d03b3b;
  --st-warning: #d98e04;
  --st-good-bg: #e3f7ea;
  --st-critical-bg: #fdecec;
  --st-warning-bg: #fff4de;
  --shadow: 0 18px 40px -28px rgba(11, 92, 42, .35), 0 1px 3px rgba(11, 36, 22, .04);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(900px 400px at 10% -10%, #dff6e8 0%, transparent 70%), var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; padding: 32px 28px; border-radius: 22px; background: var(--surface);
  box-shadow: var(--shadow); border: 1px solid var(--line); text-align: center;
  animation: rise .6s var(--ease-out) both;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
.login-card .muted { margin: 0 0 22px; }
.login-card .label { text-align: left; }
.logo {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 15px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--mint), var(--green-d));
  box-shadow: 0 10px 24px -10px rgba(15, 122, 55, .6), inset 0 1px 0 rgba(255,255,255,.35);
}
.logo svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.logo.sm { width: 32px; height: 32px; margin: 0; border-radius: 10px; box-shadow: none; }
.logo.sm svg { width: 17px; height: 17px; }

.label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.input, .select {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  font: inherit; font-size: 14px; color: var(--text); outline: none; transition: border-color .25s, box-shadow .25s;
}
.input:focus, .select:focus { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-l); }
.btn {
  width: 100%; margin-top: 14px; padding: 13px 18px; border: 0; border-radius: 12px; cursor: pointer;
  font-weight: 700; font-size: 15px; color: #fff; background: linear-gradient(135deg, var(--green), var(--green-d));
  box-shadow: 0 10px 22px -12px rgba(15, 122, 55, .7); transition: transform .25s var(--ease-out), opacity .2s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.error {
  margin-top: 14px; padding: 11px 13px; border-radius: 10px; font-size: 13px; font-weight: 600; text-align: left;
  color: var(--st-critical); background: var(--st-critical-bg);
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, calc((100vw - 1200px) / 2 + 16px));
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.tag { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--green-d); background: var(--green-l); padding: 3px 8px; border-radius: 999px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.updated { font-size: 12px; color: var(--muted); margin-right: 4px; }
.btn-light {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--text-2); font-size: 13px; font-weight: 700;
  transition: background .2s, border-color .2s;
}
.btn-light svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .6s var(--ease-out); }
.btn-light:disabled { opacity: .45; cursor: default; }
@media (hover: hover) {
  .btn-light:hover:not(:disabled) { background: var(--green-xl); border-color: var(--green-l); }
  #refresh:hover svg { transform: rotate(-200deg); }
}
#refresh.spinning svg { animation: spin .8s linear infinite; }

/* ---------- раскладка ---------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 18px; }
.filters .select { width: auto; min-width: 180px; padding: 9px 12px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(15, 122, 55, .07); }
.seg button {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--muted); transition: background .25s, color .25s, box-shadow .25s;
}
.seg button.active { background: #fff; color: var(--green-d); box-shadow: 0 3px 10px -4px rgba(11, 92, 42, .3); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 18px; transition: opacity .25s;
  animation: rise .5s var(--ease-out) both;
}
.loading .card, .loading .tiles { opacity: .6; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { font-size: 16px; margin: 0; letter-spacing: -.01em; }
.card-head p { margin: 3px 0 0; }
.link { border: 0; background: none; color: var(--green-d); font-weight: 700; font-size: 13px; cursor: pointer; padding: 4px 0; white-space: nowrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid2 .card { margin-bottom: 18px; }

/* ---------- плитки ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; transition: opacity .25s; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--shadow); animation: rise .5s var(--ease-out) both;
}
.tile-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.tile-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.tile-note { font-size: 12px; color: var(--muted); margin-top: 4px; }
.st-ico {
  width: 18px; height: 18px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; line-height: 1;
}
.st-ico.good { background: var(--st-good-bg); color: var(--st-good); }
.st-ico.critical { background: var(--st-critical-bg); color: var(--st-critical); }
.st-ico.warning { background: var(--st-warning-bg); color: var(--st-warning); }
.st-ico.neutral { background: var(--green-xl); color: var(--green-d); }

/* ---------- графики ---------- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.chart { margin: 0; min-width: 0; }
.chart figcaption { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }
.key { width: 12px; height: 12px; border-radius: 3px; }
.key.ok { background: var(--st-good); }
.key.fail { background: var(--st-critical); }
.plot { position: relative; height: 190px; }
.plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.plot .gridline { stroke: var(--grid); stroke-width: 1; }
.plot .baseline { stroke: var(--axis); stroke-width: 1; }
.plot .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.plot .bar.ok { fill: var(--st-good); }
.plot .bar.fail { fill: var(--st-critical); }
.plot .band { fill: transparent; cursor: default; outline: none; }
.plot .band-bg { fill: var(--green-xl); opacity: 0; transition: opacity .15s; }
.plot .band-bg.on { opacity: 1; }
.plot .empty { fill: var(--muted); font-size: 13px; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; min-width: 160px; padding: 10px 12px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line); box-shadow: 0 14px 30px -16px rgba(11, 36, 22, .35);
  font-size: 12.5px;
}
.tooltip .tt-date { font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
.tooltip .tt-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tooltip .tt-val { font-weight: 800; color: var(--text); min-width: 22px; font-variant-numeric: tabular-nums; }
.tooltip .tt-lbl { color: var(--muted); }

/* ---------- горизонтальные полосы ---------- */
.hbars { display: grid; gap: 12px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.hbar-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-num { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hbar-num b { color: var(--text); }
.hbar-track { height: 8px; border-radius: 4px; background: var(--green-xl); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--green); width: 0; transition: width .7s var(--ease-out); }
.empty-note { font-size: 13px; color: var(--muted); padding: 8px 0; }

/* ---------- журнал ---------- */
.list-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search svg { position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search .input { padding: 9px 12px 9px 36px; font-size: 13px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; }
#daily-table { margin-top: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; background: #f7fbf8; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { animation: fadeIn .35s ease both; }
@media (hover: hover) { .table tbody tr:hover td { background: #fafdfb; } }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 12px; }
.sub { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
td .sub.mono { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reason { max-width: 260px; color: var(--text-2); }
.order { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prov { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--green-xl); color: var(--green-d); border: 1px solid var(--green-l); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 4px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.good { background: var(--st-good-bg); color: var(--st-good); }
.badge.critical { background: var(--st-critical-bg); color: var(--st-critical); }
.badge.warning { background: var(--st-warning-bg); color: #9a6200; }
.badge .st-ico { width: 16px; height: 16px; background: #fff; font-size: 10px; }
.empty-row td { text-align: center; color: var(--muted); padding: 28px 12px; }

/* Маска ключа, по нажатию копируется полный ключ */
.code-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; margin: -4px -8px;
  border: 1px dashed transparent; border-radius: 8px; background: transparent; cursor: pointer;
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 12px; color: var(--text);
  white-space: nowrap; transition: background .2s, border-color .2s, color .2s;
}
.code-btn svg { width: 13px; height: 13px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: stroke .2s; }
.code-btn:focus-visible { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-l); }
@media (hover: hover) {
  .code-btn:hover { background: var(--green-xl); border-color: var(--green-l); }
  .code-btn:hover svg { stroke: var(--green-d); }
}
.code-btn.copied { background: var(--st-good-bg); border-color: transparent; color: var(--st-good); }
.code-btn.copied svg { stroke: var(--st-good); }
.code-none { color: var(--muted); cursor: help; }
.code-manual { width: auto; padding: 5px 8px; font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 12px; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-l); }

.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 60; transform: translateX(-50%);
  padding: 11px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 700; color: #fff;
  background: var(--text); box-shadow: 0 14px 30px -12px rgba(11, 36, 22, .5);
  animation: toastIn .35s var(--ease-out) both;
}
.toast.err { background: var(--st-critical); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .charts, .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topbar { padding: 10px 12px; }
  .updated, .brand .tag { display: none; }
  .btn-light { padding: 7px 10px; }
  .wrap { padding: 14px 12px 40px; }
  .card { padding: 16px 14px; border-radius: 16px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile-value { font-size: 22px; }
  .filters .select { flex: 1; min-width: 0; }
  .search { max-width: none; }
  .input, .select { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .tile, .login-card, .table tbody tr { animation: none; }
}
