:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e7e9f0;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --green: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

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

/* ── Шапка ─────────────────────────────────────────────── */

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }

.nav-link {
  padding: 7px 14px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: #f2f3f8; color: var(--text); text-decoration: none; }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent); }

/* ── Контейнер ─────────────────────────────────────────── */

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 20px 40px;
  flex: 1;
}

.container--center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

/* ── Заголовки ─────────────────────────────────────────── */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

h1 { font-size: 26px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ── Карточки ──────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card--pad0 { padding: 0; overflow: hidden; }
.card-title { display: flex; align-items: center; justify-content: space-between; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat { padding: 16px 18px; margin: 0; }
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.stat-note { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 18px;
}

.chart-wrap { position: relative; height: 260px; }
.chart-wrap--donut { height: 280px; }

/* ── Лимиты ────────────────────────────────────────────── */

.limits { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }

.limit-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  margin-bottom: 6px;
}

.limit-name { font-weight: 600; }

.bar {
  height: 8px;
  background: #eef0f6;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width .3s;
}

.limit--warn .bar-fill { background: var(--warn); }
.limit--over .bar-fill { background: var(--danger); }
.limit--over .limit-pct { color: var(--danger); }

/* ── Списки и таблицы ──────────────────────────────────── */

.tx-list { list-style: none; margin: 0; padding: 0; }

.tx-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.tx-list li:last-child { border-bottom: none; }
.tx-desc { font-weight: 500; }
.tx-amount { font-weight: 600; white-space: nowrap; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fafbfe;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table--hover tbody tr:hover { background: #fafbfe; }

.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: #f1f2f8;
  color: #3f4658;
  font-size: 12.5px;
  white-space: nowrap;
}

/* ── Формы ─────────────────────────────────────────────── */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field--grow { flex: 1; min-width: 200px; }
.field > span { font-size: 12.5px; color: var(--muted); }

.select, input[type="search"], input[type="password"], input[type="text"] {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  min-width: 0;
}
.select:focus, input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.filters-actions { display: flex; gap: 8px; }

.btn {
  font: inherit;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4338ca; }

.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: #f7f8fc; }

.btn-block { width: 100%; }

.inline-form { display: flex; gap: 10px; align-items: center; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 24px;
  flex-wrap: wrap;
}

/* ── Алерты и пустые состояния ─────────────────────────── */

.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.empty { text-align: center; padding: 36px 20px; }
.empty p { margin: 6px 0; }

/* ── Логин ─────────────────────────────────────────────── */

.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
}

.login-brand { font-size: 24px; font-weight: 700; text-align: center; }
.login-sub { text-align: center; color: var(--muted); margin: 4px 0 22px; font-size: 13.5px; }
.login-form { display: grid; gap: 14px; }
.login-hint { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 0; }

@media (max-width: 640px) {
  .topbar-inner { gap: 12px; padding: 10px 14px; }
  .container { padding: 18px 14px 32px; }
  h1 { font-size: 22px; }
  .card { padding: 14px; }
  .table th, .table td { padding: 9px 10px; }
  .ellipsis { max-width: 140px; }
}
