:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --sidebar: #111827;
  --sidebar-soft: #1f2937;
  --accent: #f59e0b;
  --blue: #2563eb;
  --green: #059669;
  --red: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}

/* ---------- боковое меню ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 244px;
  background: var(--sidebar); color: #d1d5db;
  display: flex; flex-direction: column;
  overflow-y: auto; z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 20px; color: #fff; text-decoration: none;
  font-weight: 800; letter-spacing: .5px; font-size: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  background: var(--accent); color: #111827;
  border-radius: 9px; font-weight: 900; font-size: 19px;
}
.brand-text span { color: var(--accent); }
.nav-label {
  padding: 20px 22px 8px; font-size: 10px; font-weight: 700;
  letter-spacing: 1.4px; color: #6b7280;
}
.side-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 10px 16px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-soft); color: #fff; }
.nav-item.active { background: var(--accent); color: #111827; font-weight: 700; }
.nav-icon { width: 20px; text-align: center; font-size: 15px; opacity: .9; }
.sidebar-foot {
  margin-top: auto; padding: 16px 20px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px; color: #9ca3af; line-height: 1.6;
}
.sidebar-foot .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #34d399; margin-right: 5px;
}

/* ---------- основная область ---------- */
.main { margin-left: 244px; min-height: 100vh; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 20px 30px; display: flex; align-items: center;
  justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 24px; font-weight: 750; letter-spacing: -.3px; }
.subtitle { color: var(--muted); font-size: 13px; margin-top: 3px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.date-chip {
  background: #f3f4f6; color: #4b5563; border-radius: 20px;
  padding: 6px 13px; font-size: 12px; font-weight: 600;
}
.content { padding: 26px 30px 60px; max-width: 1640px; }

/* ---------- карточки и сетки ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 20px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.card-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  border-top: 3px solid var(--line);
}
.stat-card.accent { border-top-color: var(--accent); }
.stat-card.danger { border-top-color: var(--red); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-value { font-size: 25px; font-weight: 750; margin-top: 6px; letter-spacing: -.5px; }
.stat-value small { font-size: 14px; font-weight: 600; color: var(--muted); }
.stat-foot { font-size: 11px; color: var(--muted); margin-top: 6px; }
.month-card { padding-bottom: 12px; }
.month-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.month-grid div { display: flex; flex-direction: column; gap: 4px; }
.month-grid span { font-size: 12px; color: var(--muted); }
.month-grid strong { font-size: 18px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; }
.stack .card:last-child { margin-bottom: 0; }
.page-actions { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11px; letter-spacing: .4px; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 10px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
tfoot td { padding: 11px 12px; border-top: 2px solid var(--line); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 700; }
.small { font-size: 11px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 26px 12px !important; }
.positive { color: var(--green); }
.negative, .danger-text { color: var(--red); }
.actions { white-space: nowrap; }
.inline { display: inline; margin: 0; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.low-list { display: flex; flex-direction: column; gap: 8px; }
.low-item { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 8px 10px; background: #fff7ed; border-radius: 7px; }
.info-list { display: flex; flex-direction: column; gap: 0; }
.info-list > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid #f0f1f3; font-size: 13px; }
.info-list > div:last-child { border-bottom: 0; }
.info-list span { color: var(--muted); }
.info-list strong { text-align: right; font-weight: 600; }

/* ---------- формы ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span-2 { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 650; color: #4b5563; }
input, select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 13.5px;
  border: 1px solid #d1d5db; border-radius: 7px; background: #fff; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
input::placeholder { color: #9ca3af; }
select { cursor: pointer; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.filter-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.filter-form .field { width: 180px; }

/* ---------- кнопки и метки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 9px 14px; border-radius: 7px; border: 1px solid transparent;
  font-size: 13px; font-weight: 650; text-decoration: none; cursor: pointer;
  white-space: nowrap; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { background: #fff; color: var(--blue); border-color: #bfdbfe; }
.btn-outline:hover { background: #eff6ff; }
.btn-ghost { background: #f3f4f6; color: #374151; }
.btn-ghost:hover { background: #e5e7eb; }
.btn-danger-ghost { background: #fff; color: var(--red); border-color: #fecaca; }
.btn-danger-ghost:hover { background: #fef2f2; }
.link { color: var(--blue); text-decoration: none; font-size: 12px; font-weight: 600; }
.link:hover { text-decoration: underline; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  background: #eef2ff; color: #4338ca; font-size: 11px; font-weight: 700;
}
.ok-badge { background: #d1fae5; color: #065f46; }
.warn-badge { background: #fef3c7; color: #92400e; }
.danger-badge { background: #fee2e2; color: #991b1b; }
.muted-badge { background: #f3f4f6; color: #4b5563; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 13.5px; font-weight: 600; }
.alert-ok { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.danger-zone { border-left: 3px solid #fecaca; }

/* ---------- адаптив ---------- */
@media (max-width: 1180px) {
  .two-col { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .month-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { position: static; width: 100%; height: auto; }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label, .sidebar-foot { display: none; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .topbar { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .stat-grid, .stat-grid-3, .stat-grid-4 { grid-template-columns: 1fr 1fr; }
  .month-grid { grid-template-columns: 1fr 1fr; }
}
