/* yg dashboard — сдержанный дизайн-язык.
   Светлая нейтральная палитра, один приглушённый акцент. Без кричащих цветов. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e3e6ea;
  --border-strong: #d2d7dd;
  --text: #1f2733;
  --text-2: #4a5563;
  --muted: #7a8493;
  --accent: #3a6b73;          /* приглушённый сине-зелёный */
  --accent-ink: #2c5158;
  --accent-soft: #e8f0f1;
  --ok: #4b7f6b;
  --warn: #9a7b3f;
  --danger: #9c5a52;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20, 28, 40, .05), 0 2px 8px rgba(20, 28, 40, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.4rem; font-weight: 650; margin: 0 0 .25rem; letter-spacing: -.01em; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* --- Topbar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .02em;
}
.brand-mark--lg { width: 44px; height: 44px; font-size: 1.1rem; border-radius: 12px; }
.brand-title { font-weight: 600; color: var(--text); }
.topbar__nav { display: flex; align-items: center; gap: 16px; }
.navlink { color: var(--text-2); font-weight: 500; }
.navlink--muted { color: var(--muted); }
.userpill {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .82rem;
  font-weight: 600;
}

/* --- Content --- */
.content { max-width: 1180px; margin: 0 auto; padding: 28px 24px 60px; }
.page-head { margin-bottom: 22px; }

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card__label { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card__value { font-size: 1.5rem; font-weight: 650; margin-top: 6px; }
.placeholder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

/* --- Auth --- */
.auth-bg { background: linear-gradient(180deg, #eef1f3, #f4f5f7); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(20, 28, 40, .08);
  padding: 32px 30px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-card__head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 6px; }
.auth-card__head h1 { font-size: 1.25rem; margin: 6px 0 0; }

/* --- Forms --- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--text-2); }
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: .95rem;
  font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .92rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .04s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-ink); }
.btn--block { width: 100%; }
.link-muted { display: block; text-align: center; color: var(--muted); font-size: .85rem; }

/* --- Alerts --- */
.alert { border-radius: var(--radius-sm); padding: 10px 12px; font-size: .88rem; }
.alert--error { background: #f6ebe9; color: var(--danger); border: 1px solid #ecd6d2; }
.alert--ok { background: #e9f1ed; color: var(--ok); border: 1px solid #d3e5dd; }

/* ===================== App shell ===================== */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: #11161b;
  color: #c7cdd6;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar__brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 18px; }
.sidebar .brand-mark { background: #2f5e66; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar .brand-title { color: #eef1f4; font-weight: 650; font-size: .98rem; }
.brand-sub { color: #7d8794; font-size: .72rem; }

.sidenav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.sidenav__link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 8px;
  color: #aeb6c1; font-weight: 500; font-size: .92rem;
}
.sidenav__link:hover { background: #1a2127; color: #eef1f4; text-decoration: none; }
.sidenav__link.is-active { background: #20323a; color: #eaf3f4; }
.sidenav__link .ic { width: 18px; text-align: center; opacity: .85; }

.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-top: 14px; }
.envbadge { font-size: .76rem; color: #9aa3ae; background: #1a2127; padding: 7px 10px; border-radius: 8px; }
.envbadge strong { color: #d8dee6; }
.envbadge--production strong { color: #e0b487; }
.envbadge--sandbox strong { color: #8fc6c3; }
.userrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.userrow .userpill { background: #20323a; color: #cfe6e6; }
.logout { color: #8b94a0; font-size: 1.1rem; padding: 4px 8px; border-radius: 6px; }
.logout:hover { background: #1a2127; color: #eef1f4; text-decoration: none; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 28px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar__title { font-size: 1.15rem; font-weight: 650; margin: 0; }
.envswitch { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 3px; gap: 2px; }
.seg {
  border: none; background: transparent; cursor: pointer;
  padding: 6px 14px; border-radius: 6px; font-size: .85rem; font-weight: 600;
  color: var(--text-2); font-family: inherit;
}
.seg.is-on { background: var(--accent); color: #fff; }

.content { max-width: 1180px; width: 100%; margin: 0; padding: 26px 28px 60px; }
.section-intro { margin: 0 0 18px; }

/* --- KPI --- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  border-left: 3px solid var(--border-strong);
}
.kpi--accent-warn { border-left-color: var(--warn); }
.kpi--accent-ok { border-left-color: var(--ok); }
.kpi__label { color: var(--muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi__value { font-size: 1.7rem; font-weight: 680; margin-top: 4px; letter-spacing: -.02em; }
.kpi__pct { font-size: 1rem; color: var(--muted); font-weight: 600; }
.kpi__hint { color: var(--muted); font-size: .76rem; margin-top: 2px; }

/* --- Panels --- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel__head h2 { font-size: 1.02rem; font-weight: 650; margin: 0; }

/* --- Stage chips (dashboard) --- */
.stage-track { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.stage-chip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); }
.stage-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); flex: none; }
.stage-chip.is-on .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(75,127,107,.15); }
.stage-chip.is-off { opacity: .8; }
.stage-chip__title { font-size: .9rem; font-weight: 600; }
.stage-chip__status { font-size: .77rem; color: var(--muted); }

/* --- Table --- */
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.mono, .tbl .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; color: var(--text-2); }
.bar { display: inline-block; width: 90px; height: 7px; border-radius: 4px; background: var(--border); overflow: hidden; vertical-align: middle; }
.bar > span { display: block; height: 100%; background: var(--warn); }
.bar__val { font-size: .8rem; color: var(--text-2); margin-left: 8px; }
.empty { color: var(--muted); padding: 24px 4px; text-align: center; }

/* --- Stage control --- */
.stage__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.stage__head h2 { margin: 0 0 4px; font-size: 1.05rem; }
.stage__form { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.stage__actions { display: flex; align-items: center; gap: 12px; }
.stage__stub { margin-top: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field--check { flex-direction: row; align-items: center; gap: 10px; }
.field--check input { width: auto; }
textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; font-size: .9rem; resize: vertical; }
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: .82em; }

/* --- Switch --- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch__track { width: 42px; height: 24px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch__thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track .switch__thumb { left: 21px; }
.switch__label { font-size: .85rem; color: var(--text-2); font-weight: 600; }

/* --- Buttons extra --- */
.btn:not(.btn--primary) { background: var(--surface); border-color: var(--border-strong); color: var(--text-2); }
.btn:not(.btn--primary):hover { background: var(--surface-2); }
.btn--sm { padding: 6px 12px; font-size: .82rem; }

/* --- Inline forms --- */
.inline-form { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.inline-form input[type=text] { width: auto; min-width: 180px; }

/* --- Run log --- */
.runlog { margin-top: 14px; background: #11161b; color: #cfe0df; padding: 14px 16px; border-radius: 9px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; white-space: pre-wrap; line-height: 1.5; max-height: 360px; overflow: auto; }

/* --- Toasts --- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast { background: #1b232b; color: #eef1f4; padding: 11px 16px; border-radius: 9px; font-size: .88rem; box-shadow: 0 6px 20px rgba(0,0,0,.18); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast--error { background: #5c2f2c; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
  .sidenav { flex-direction: row; flex-wrap: wrap; }
  .sidebar__foot { margin: 0 0 0 auto; flex-direction: row; }
  .grid-3 { grid-template-columns: 1fr; }
}
