:root {
  --navy: #0F1E3A;
  --navy-2: #1B2E52;
  --green: #137A42;
  --lime: #3DDC84;
  --bg: #F5F4F0;
  --card: #FFFFFF;
  --line: #E4E2DA;
  --text: #0F1E3A;
  --muted: #6A7386;
  --red: #C8372D;
  --red-bg: #FCEBE9;
  --amber: #B7791F;
  --amber-bg: #FDF3E1;
  --green-bg: #E6F5EC;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 "Manrope", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .logo, .kpi-value { font-family: "Unbounded", "Manrope", sans-serif; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 17px; font-weight: 600; margin: 0 0 14px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 10px; }
a { color: var(--green); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- шапка ---- */
.topbar { background: var(--navy); color: #fff; }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.logo { font-size: 22px; font-weight: 700; color: #fff; text-decoration: none; white-space: nowrap; }
.logo b { color: var(--lime); font-weight: 700; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: #C9D2E3; text-decoration: none; padding: 7px 12px; border-radius: 9px; font-weight: 600; font-size: 14px; }
.nav a:hover { color: #fff; background: var(--navy-2); }
.nav a.on { color: var(--navy); background: var(--lime); }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #C9D2E3; }
.who form { margin: 0; }
.link-btn { background: none; border: 1px solid #3A4C70; color: #fff; border-radius: 8px; padding: 5px 10px; cursor: pointer; font: inherit; }
.link-btn:hover { border-color: var(--lime); }
.admin-strip { background: var(--lime); color: var(--navy); font-size: 13px; font-weight: 600; }
.admin-strip .topbar-in { padding: 6px 24px; }
.admin-strip a { color: var(--navy); }

.page { max-width: 1240px; margin: 0 auto; padding: 28px 24px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }

/* ---- карточки и сетки ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }
@media (max-width: 960px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main, .g2 { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; }
  .nav a { white-space: nowrap; }
  .who { margin-left: auto; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr; } .page { padding: 20px 16px 48px; } .topbar-in { padding: 12px 16px; gap: 12px; } h1 { font-size: 21px; } }

.kpi .kpi-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .kpi-value { font-size: 26px; font-weight: 600; margin: 6px 0 4px; white-space: nowrap; }
.delta { font-size: 13px; font-weight: 700; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }
.kpi.accent { background: var(--navy); color: #fff; border-color: var(--navy); }
.kpi.accent .kpi-label, .kpi.accent .muted { color: #AEB9CF; }
.kpi.accent .kpi-value { color: var(--lime); }

/* ---- переключатель периода ---- */
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg a { padding: 6px 14px; border-radius: 8px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px; }
.seg a.on { background: var(--navy); color: #fff; }
.period-bar { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.seg-wrap { flex-wrap: wrap; }
.seg-wrap a { padding: 6px 11px; font-size: 13px; }
.period-custom { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
.period-custom input[type=date] { width: auto; margin: 0; padding: 5px 8px; font-size: 13px; }
.period-custom.on input[type=date] { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); }
@media (max-width: 720px) { .period-bar { align-items: stretch; } }
.crumbs { font-size: 13px; margin-bottom: 4px; }
.crumbs a { text-decoration: none; }
.crumbs span { color: var(--muted); margin: 0 6px; }
tr.sub-row td:first-child { padding-left: 30px; }
tr.sub-row td:first-child::before { content: "└ "; color: var(--muted); }
tr.main-row td:first-child { font-weight: 700; }
.share { display: inline-block; width: 46px; height: 6px; background: #ECEAE3; border-radius: 99px; margin-right: 8px; vertical-align: middle; overflow: hidden; }
.share i { display: block; height: 100%; background: var(--green); }
select.inline-select { display: inline-block; width: auto; min-width: 200px; margin: 0; padding: 6px 8px; font-size: 13px; }
.kw { font-size: 12px; color: var(--muted); }
.dir-card + .dir-card { margin-top: 16px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---- кнопки и формы ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--green); color: #fff; border: 0; border-radius: 10px;
  padding: 9px 16px; font: 600 14px "Manrope", sans-serif; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #0F6536; }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--navy); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #F0C8C4; }
.btn.small { padding: 5px 10px; font-size: 13px; }
form.inline { display: inline; margin: 0; }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
label .hint { font-weight: 500; color: var(--muted); display: block; margin-top: 3px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=month], textarea, select {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px; border: 1px solid #D5D2C8; border-radius: 9px;
  font: 500 14px "Manrope", sans-serif; background: #fff; color: var(--text); }
input:focus, textarea:focus { outline: 2px solid var(--lime); border-color: var(--green); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.check input { width: 17px; height: 17px; accent-color: var(--green); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > label { flex: 1; min-width: 160px; }

/* ---- таблицы ---- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid #F0EEE7; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #FAFAF7; }
th.num { text-align: right; }
td .sub { color: var(--muted); font-size: 12px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--navy); }

/* ---- статусы ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--green-bg); color: var(--green); }
.pill.error { background: var(--red-bg); color: var(--red); }
.pill.running { background: var(--amber-bg); color: var(--amber); }
.pill.never, .pill.off { background: #EEEDE8; color: var(--muted); }

/* ---- прогресс плана ---- */
.bar { position: relative; height: 10px; background: #ECEAE3; border-radius: 99px; overflow: visible; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--green); max-width: 100%; }
.bar > i.done { background: var(--lime); }
.bar > i.risk { background: #E0A43A; }
.bar > i.behind { background: var(--red); }
.bar > em { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--navy); border-radius: 2px; }
.plan-line { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.plan-item + .plan-item { margin-top: 16px; }
.big-plan .kpi-value { font-size: 34px; }

/* ---- уведомления ---- */
.flash { padding: 12px 16px; border-radius: 11px; margin-bottom: 18px; font-weight: 600; }
.flash.ok { background: var(--green-bg); color: var(--green); }
.flash.error { background: var(--red-bg); color: var(--red); }
.flash.warn { background: var(--amber-bg); color: var(--amber); }
.note { background: #fff; border: 1px dashed #CFCBBF; border-radius: 11px; padding: 12px 14px; font-size: 13px; color: var(--muted); }
.err-text { color: var(--red); font-size: 12px; max-width: 360px; }
.chart-box { position: relative; height: 280px; }
details summary { cursor: pointer; font-weight: 600; color: var(--green); }

/* ---- вход ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--navy); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 34px 30px; }
.login-card .logo { color: var(--navy); font-size: 30px; display: block; margin-bottom: 4px; }
.login-card .logo b { color: var(--green); }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 6px; }
