@import url('/static/fonts/golos.css');

/* UPG Закуп — дизайн-система v2 (по мотивам финансовых дашбордов: светлые карточки, тёмно-зелёная главная карточка) */
:root {
  --bg: #f3f1ec;
  --surface: #ffffff;
  --ink: #17201c;
  --ink-2: #3a433e;
  --muted: #6c736d;
  --line: #e6e2d9;
  --line-2: #f0ede6;
  --brand: #1d4a3c;          /* тёмно-зелёный: главная карточка, активное меню */
  --brand-2: #275f4d;
  --accent: #1f6f5c;
  --accent-soft: #e3efe8;
  --lime: #c9e98b;           /* акцент на тёмном */
  --owe: #b4532a;  --owe-soft: #f8e7de;   /* мы должны / рост цены */
  --adv: #2c7a4b;  --adv-soft: #e1f1e6;   /* аванс / снижение */
  --warn: #946414; --warn-soft: #f8efd9;
  --usd: #1f6f5c;  --uzs: #c58a22;
  --radius: 14px;  --radius-s: 9px;
  --shadow: 0 1px 2px rgba(23, 32, 28, .04), 0 6px 18px -8px rgba(23, 32, 28, .08);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Golos Text', -apple-system, 'Segoe UI', sans-serif; font-size: 14px; line-height: 1.45;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
[hidden] { display: none !important; }
.ic { flex: none; }

/* ── каркас ── */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { padding: 20px 14px 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: #f7f6f2; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; color: var(--ink); font-weight: 700; font-size: 15px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11.5px; }
.mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--lime); display: grid; place-items: center;
  font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.navh { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #9a9f98; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--ink-2); font-weight: 500;
  margin-bottom: 1px; }
.nav a .ic { color: #8b918a; }
.nav a:hover { background: #ebe8e1; text-decoration: none; }
.nav a.on { background: var(--brand); color: #fff; }
.nav a.on .ic { color: var(--lime); }
.nav .badge { margin-left: auto; background: var(--owe); color: #fff; font-size: 11px; font-weight: 600; border-radius: 10px; padding: 0 7px;
  line-height: 18px; }
.side .foot { margin-top: auto; padding: 14px 10px 0; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.side .foot a { display: inline-flex; align-items: center; gap: 5px; }
.dbl { margin: 6px 0 8px; word-break: break-all; }
.main { padding: 24px 30px 64px; min-width: 0; max-width: 1560px; }

/* ── шапка страницы ── */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head h1 { font-size: 26px; margin: 0; font-weight: 700; letter-spacing: -.02em; }
.head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: #e9e6df; }
.seg a { padding: 5px 11px; color: var(--ink-2); font-size: 13px; border-radius: 8px; }
.seg a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg a:hover { text-decoration: none; color: var(--ink); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: #bdb8ad; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
form.inline { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
input, select { font: inherit; font-size: 13px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); min-height: 34px; }
input:focus, select:focus, .btn:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── карточки ── */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.g2e { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mt { margin-top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0;
  box-shadow: var(--shadow); }
.panel h2 { font-size: 15px; margin: 0 0 12px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  flex-wrap: wrap; letter-spacing: -.005em; }
.panel h2 small { font-weight: 400; color: var(--muted); font-size: 12px; margin-right: auto; }
.panel h2 > span:first-child { margin-right: auto; }
.chart { position: relative; height: 250px; }
.chart.tall { height: 300px; }
.chart.short { height: 190px; }
.note { color: var(--muted); font-size: 12px; }
.note.cur { font-weight: 600; color: var(--ink-2); margin: 12px 0 4px; }
.note.cur:first-child { margin-top: 0; }
.empty { color: var(--muted); padding: 22px 0; text-align: center; }
.banner { background: var(--warn-soft); color: var(--warn); border: 1px solid #ecdcb4; padding: 10px 14px; border-radius: 11px;
  margin-bottom: 16px; font-size: 13px; }
.banner code { background: #fff8e8; padding: 1px 5px; border-radius: 4px; }

/* вкладки валют */
.tabbar { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: #efece5; }
.tabbar button { font: inherit; font-size: 12px; font-weight: 600; border: 0; background: transparent; color: var(--muted); padding: 3px 10px;
  border-radius: 7px; cursor: pointer; }
.tabbar button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

/* ── верхний ряд: главная карточка + плитки ── */
.toprow { display: grid; grid-template-columns: minmax(0, 1.35fr) repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.hero { background: radial-gradient(120% 140% at 100% 0%, #2b6a55 0%, var(--brand) 55%); color: #fff; border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; min-width: 0; position: relative; overflow: hidden; }
.hero-l { display: flex; align-items: center; gap: 8px; font-size: 13px; color: rgba(255, 255, 255, .78); }
.hero-l .ic { color: var(--lime); }
.hero-v { font-size: 32px; font-weight: 700; letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hero-v.second { font-size: 18px; font-weight: 600; margin-top: 4px; color: rgba(255, 255, 255, .9); }
.hero-d { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: rgba(255, 255, 255, .72); flex-wrap: wrap; }
.hero-adv { font-size: 12.5px; color: rgba(255, 255, 255, .78); margin-top: 10px; }
.hero-adv b { color: #fff; font-weight: 600; }
.hero-spark { margin-top: auto; padding-top: 14px; color: var(--lime); }
.hero-spark span { display: block; font-size: 11px; color: rgba(255, 255, 255, .58); margin-bottom: 4px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-width: 0; }
.tile-h { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted); }
.ico { width: 32px; height: 32px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.ico.w { background: var(--warn-soft); color: var(--warn); }
.ico.o { background: var(--owe-soft); color: var(--owe); }
.tile-v { font-size: 23px; font-weight: 700; letter-spacing: -.015em; margin-top: 12px; font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; line-height: 1.15; }
.tile-v.second { font-size: 15px; font-weight: 600; margin-top: 5px; color: var(--ink-2); }
.tile-f { margin-top: auto; padding-top: 10px; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px;
  font-size: 11.5px; color: var(--muted); }
.tile-f .spark { color: var(--accent); }

/* метки изменения */
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 20px;
  white-space: nowrap; letter-spacing: 0; font-variant-numeric: tabular-nums; }
.delta.good { background: var(--adv-soft); color: var(--adv); }
.delta.bad { background: var(--owe-soft); color: var(--owe); }
.delta.neutral, .delta.flat { background: #eeebe4; color: var(--ink-2); }
.hero .delta.good { background: rgba(201, 233, 139, .16); color: var(--lime); }
.hero .delta.bad { background: rgba(255, 176, 146, .16); color: #ffc0a6; }
.hero .delta.neutral, .hero .delta.flat { background: rgba(255, 255, 255, .12); color: #fff; }

/* мини-графики */
.spark { display: block; overflow: visible; }
.spark .a { fill: currentColor; opacity: .14; }
.spark .l { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark.up { color: var(--owe); } .spark.down { color: var(--adv); } .spark.flat { color: #a3a8a1; }
td.sparkcell { padding-top: 4px; padding-bottom: 2px; }

/* полоса «требует внимания» */
.alerts { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 16px; }
.alert { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 10px; background: var(--surface);
  border: 1px solid var(--line); color: var(--ink-2); font-size: 13px; font-weight: 500; }
.alert:hover { text-decoration: none; border-color: #bdb8ad; }
.alert .ic { color: var(--warn); }
.alert.bad { background: var(--owe-soft); border-color: #efcfbf; color: var(--owe); }
.alert.bad .ic { color: var(--owe); }

/* старый ряд показателей (внутренние страницы) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 16px; box-shadow: var(--shadow); overflow: hidden; }
.kpi { padding: 15px 18px; border-right: 1px solid var(--line-2); min-width: 0; }
.kpi:last-child { border-right: 0; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.kpi .v { font-size: 21px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.015em; }
.kpi .v + .v { font-size: 15px; margin-top: 0; font-weight: 600; }
.kpi .d { font-size: 12px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.up { color: var(--owe); } .down { color: var(--adv); }
.owe { color: var(--owe); } .adv { color: var(--adv); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin: 0 4px 0 8px; vertical-align: 0; }
.dot.owe { background: var(--owe); } .dot.adv { background: var(--adv); }

/* кольцевая диаграмма + легенда */
.donutq { container-type: inline-size; }
.donut { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 18px; align-items: center; }
.donut .chart { height: 190px; }
@container (max-width: 480px) {
  .donut { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .donut .chart { height: 176px; }
}
.legend { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 6px 0;
  border-bottom: 1px solid var(--line-2); }
.legend li:last-child { border-bottom: 0; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.legend span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend b { font-weight: 600; font-variant-numeric: tabular-nums; }
.legend em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 78px; text-align: right; }

/* лента сообщений */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.feed li:last-child { border-bottom: 0; }
.ava { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px;
  background: hsl(var(--h) 32% 88%); color: hsl(var(--h) 40% 26%); }
.feed-t { display: flex; align-items: center; gap: 7px; font-size: 13px; flex-wrap: wrap; }
.feed-t time { margin-left: auto; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.feed-m { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; overflow-wrap: anywhere; }

/* ── таблицы ── */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 9px; border-bottom: 1px solid var(--line);
  white-space: nowrap; cursor: pointer; user-select: none; background: #faf9f6; }
th:first-child { border-top-left-radius: 8px; } th:last-child { border-top-right-radius: 8px; }
th.nosort { cursor: default; }
th[data-dir="asc"]::after { content: " ↑"; } th[data-dir="desc"]::after { content: " ↓"; }
td { padding: 8px 9px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #faf9f5; }
tr.void td { color: var(--muted); text-decoration: line-through; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); background: #faf9f6; }
.tag { display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 20px; background: #efece5; color: var(--ink-2);
  white-space: nowrap; line-height: 1.4; }
.tag.a { background: var(--accent-soft); color: var(--accent); }
.tag.w { background: var(--warn-soft); color: var(--warn); }
.tag.o { background: var(--owe-soft); color: var(--owe); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }
.pager { display: flex; gap: 6px; justify-content: flex-end; margin-top: 10px; }
.pager .note { align-self: center; }
.saldo-line { display: flex; gap: 22px; flex-wrap: wrap; font-size: 15px; }
.saldo-line b { font-variant-numeric: tabular-nums; }
.totals { margin-bottom: 12px; font-size: 14px; }
.filters { margin: -6px 0 14px; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink-2); }
.chk input { min-height: auto; margin: 0; }
.panel h2 .seg { font-weight: 400; }
.panel h2 .seg a { padding: 3px 9px; font-size: 12px; }
.barcell { width: 34%; vertical-align: middle; }
.bar { height: 7px; background: var(--line-2); border-radius: 4px; min-width: 60px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.cell-bar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.cell-bar .bar { width: 70px; min-width: 70px; }
.score { display: inline-block; min-width: 46px; text-align: center; padding: 2px 7px; border-radius: 20px; font-weight: 600; font-size: 12px; }
.score.good { background: var(--adv-soft); color: var(--adv); }
.score.bad { background: var(--owe-soft); color: var(--owe); }
.score.mid { background: #eeebe4; color: var(--ink-2); }
.namecell { min-width: 170px; }
.who { display: inline-flex; align-items: center; gap: 8px; }
.who .ava { width: 26px; height: 26px; font-size: 12px; }
.insights { list-style: none; margin: 0; padding: 0; }
.insights li { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.insights li:last-child { border-bottom: 0; }
.insights .tag { justify-self: start; }
table.heat td { text-align: center; min-width: 30px; }
table.heat td:first-child { text-align: left; }
.sticky { position: sticky; top: 16px; align-self: start; }
.explain { display: flex; gap: 8px; flex-wrap: wrap; margin: -6px 0 16px; }
.explain span { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 11px; font-size: 12.5px; color: var(--ink-2); }

/* ── ежемесячный отчёт ── */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 30px 34px; }
.rep-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding-bottom: 18px;
  border-bottom: 2px solid var(--brand); margin-bottom: 20px; }
.rep-kicker { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.rep-title { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 4px; }
.rep-sub { color: var(--muted); font-size: 13px; }
.rep-meta { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.rep-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 22px; }
.rk { background: #f8f7f3; border-radius: 12px; padding: 13px 15px; }
.rk-l { font-size: 12px; color: var(--muted); }
.rk-v { font-size: 21px; font-weight: 700; letter-spacing: -.015em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.rk-d { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 5px; font-size: 11.5px; color: var(--muted); }
.rep-sec { margin-bottom: 22px; }
.rep-sec h3, .rep-card h3 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
.rep-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; margin-bottom: 22px; }
.rep-card { min-width: 0; }
.rep-ctl { display: flex; gap: 10px; flex-wrap: wrap; }
.rep-ctl span { background: #f8f7f3; border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.rep-ctl b { font-variant-numeric: tabular-nums; }

/* ── вход ── */
.login { max-width: 360px; margin: 14vh auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px;
  box-shadow: var(--shadow); }
.login h1 { font-size: 19px; margin: 0 0 4px; }
.login input { width: 100%; margin: 14px 0 10px; padding: 10px 11px; }
.login .urls { padding-left: 18px; margin: 8px 0; font-variant-numeric: tabular-nums; }
.err { color: var(--owe); font-size: 13px; }

@media (max-width: 1280px) { .toprow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (max-width: 1100px) {
  .g2, .g2e, .g3, .rep-grid { grid-template-columns: minmax(0, 1fr); }
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .donut { grid-template-columns: 150px minmax(0, 1fr); }
}
@media (max-width: 640px) { .toprow { grid-template-columns: 1fr; } .main { padding: 16px; } .report { padding: 18px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

@media print {
  @page { size: A4; margin: 11mm; }
  body { background: #fff; font-size: 11.5px; }
  .side, .head .tools, .banner, .no-print { display: none !important; }
  .app { display: block; }
  .main { padding: 0; max-width: none; }
  .head { margin-bottom: 8px; }
  .report { border: 0; box-shadow: none; padding: 0; }
  .rep-sec, .rep-card, .rk, .panel, tr { break-inside: avoid; }
  .rep-grid { display: block; }                 /* на бумаге — блоки друг под другом: сетка плохо делится на страницы */
  .rep-card { margin-bottom: 16px; break-inside: avoid; }
  .rep-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .rk { padding: 9px 11px; } .rk-v { font-size: 16px; }
  .page-break { break-before: page; }
  .donutq { container-type: normal; }
  .chart canvas { display: none !important; }
  .print-img { display: block !important; }
  a { color: inherit; }
}
.print-img { display: none; }
