:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --line: #e2e5ea;
  --text: #1d2126;
  --muted: #7b8391;
  --brand: #c0392b;
  --brand-dark: #96291e;
  --ok-bg: #e8f6ec;
  --ok-text: #1c7c3c;
  --err-bg: #fdecec;
  --err-text: #b3231b;
  --warn: #c98a00;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- шапка ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background: #22262b;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar a { color: #dfe3e8; }
.topbar .brand a { font-weight: 600; color: #fff; }
.topbar nav { display: flex; gap: 14px; flex: 1; }
.topbar nav a.active { color: #fff; border-bottom: 2px solid var(--brand); padding-bottom: 2px; }
.userbox { display: flex; align-items: center; gap: 10px; color: #cfd4da; font-size: 13px; }
.userbox .role { color: #8b939d; font-style: normal; }

/* ---------- контейнер ---------- */

.container { padding: 18px; max-width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h3 { font-size: 14px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.bad { color: var(--err-text); font-weight: 600; }
.good { color: var(--ok-text); }
.warn { color: var(--warn); }

/* ---------- карточки ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
}
.cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.card.kpi { flex: 1 1 180px; display: flex; flex-direction: column; gap: 4px; }
.card.kpi b { font-size: 19px; }
.card.kpi em { color: var(--muted); font-style: normal; font-size: 12px; }
.kpi-label { color: var(--muted); font-size: 12px; }
.forms { display: flex; gap: 12px; flex-wrap: wrap; }
.card.mini { flex: 1 1 260px; margin-bottom: 0; }

/* ---------- формы ---------- */

label { display: block; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
input, select, button { font: inherit; }
input[type=text], input[type=date], input[type=password], select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}
input.tiny { width: 90px; }
input.wide { width: 100%; }

button.btn, button.btn-primary {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}
button.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.btn-primary:hover { background: var(--brand-dark); }
button.link { background: none; border: none; color: #cfd4da; cursor: pointer; padding: 0; }
button.link.danger { color: var(--err-text); }
button.link:hover { text-decoration: underline; }

.period { display: flex; gap: 8px; align-items: center; }
.period select { width: auto; }
.inline-fields { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.inline-fields label { margin-bottom: 0; }
.inline-form { display: inline-block; margin-bottom: 14px; }
.row-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-actions { margin: 12px 0; }

/* ---------- таблицы ---------- */

.table-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
table.grid { border-collapse: collapse; width: 100%; font-size: 12px; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 3px 5px; text-align: right; white-space: nowrap; }
table.grid th { background: #f0f2f5; position: sticky; top: 0; z-index: 10; font-weight: 600; }
table.grid td.sticky-cat, table.grid th.sticky-cat {
  position: sticky; left: 0; background: #fff; text-align: left; min-width: 170px; z-index: 11;
}
table.grid th.sticky-cat { background: #f0f2f5; z-index: 12; }
table.grid td.day { min-width: 58px; }
table.grid td.day.has { background: #fff8e1; }
table.grid td.sum { font-weight: 600; background: #f7f8fa; }
table.grid tr.totals td { font-weight: 600; background: #eef1f4; }
table.grid tr.revenue td { background: #f8fbf9; }
table.grid tr.revenue.strong td { font-weight: 600; }
table.grid.compact { border-radius: 8px; }
table.grid.compact th, table.grid.compact td { text-align: left; }
table.grid.compact td.sum { text-align: right; }
input.num-input { width: 62px; padding: 2px 4px; text-align: right; border: 1px solid var(--line); border-radius: 4px; }
input.num-input.pct { width: 52px; }

/* ---------- сообщения ---------- */

.flash { padding: 9px 12px; border-radius: 6px; margin-bottom: 12px; }
.flash.ok { background: var(--ok-bg); color: var(--ok-text); }
.flash.err { background: var(--err-bg); color: var(--err-text); }

/* ---------- вход ---------- */

.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card { width: 320px; }
.login-card h1 { margin-bottom: 4px; }
.login-card button { width: 100%; margin-top: 6px; }

.footer { padding: 14px 18px; color: var(--muted); font-size: 12px; }
