.page-head, .split, .kpi-grid, .chart-grid, .stat-grid, .form-grid, .detail-grid {
  display: grid;
  gap: 16px;
}
.page-head { grid-template-columns: 1fr auto; align-items: end; margin-bottom: 16px; }
.page-head p, .hint { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 16px 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }

.btn, .btn-ghost, .btn-danger {
  border: 0;
  border-radius: 12px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn { background: var(--accent); color: var(--accent-ink); }
.btn:hover { background: #12b5a6; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-danger { background: rgba(212, 83, 74, .12); color: var(--danger); }
.btn[disabled] { opacity: .6; cursor: wait; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; border-radius: 10px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.grow { flex: 1; }
.field span, .field label { font-size: 12px; font-weight: 700; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  min-height: 42px;
  padding: 8px 12px;
  outline: none;
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 199, 183, .18);
}
.field-error { color: var(--danger); font-size: 12px; min-height: 16px; }
.form-grid { grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }

.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 720px; }
table.data th, table.data td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
  white-space: nowrap;
}
table.data th { font-size: 12px; color: var(--muted); font-weight: 700; background: color-mix(in srgb, var(--bg) 70%, var(--card)); }
table.data tr:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px !important; white-space: normal; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 750;
  background: var(--bg);
  color: var(--muted);
}
.badge-ok { background: rgba(14, 159, 122, .12); color: var(--ok); }
.badge-warn { background: rgba(183, 121, 31, .14); color: var(--warn); }
.badge-info { background: rgba(60, 125, 219, .12); color: var(--info); }
.badge-danger { background: rgba(212, 83, 74, .12); color: var(--danger); }
.badge-neutral { background: var(--bg); color: var(--muted); }

.pager { display: flex; gap: 6px; padding: 12px 14px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; border: 1px solid var(--line); font-size: 13px; font-weight: 700;
}
.pager span { background: #101827; color: #fff; border-color: #101827; }

.modal[hidden] { display: none; }
.modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 18px;
  background: rgba(10, 16, 27, .52);
}
.modal-card {
  width: min(720px, 100%);
  max-height: min(88vh, 860px);
  overflow: auto;
  background: var(--card);
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.toast-stack { position: fixed; right: 16px; bottom: 16px; z-index: 70; display: grid; gap: 8px; }
.toast {
  min-width: 240px; max-width: 360px;
  background: #101827; color: #fff;
  border-radius: 14px; padding: 12px 14px;
  box-shadow: var(--shadow); font-size: 14px; font-weight: 650;
}
.toast.error { background: #7d2b27; }
.toast.ok { background: #0d3f38; }

.kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.chart-grid, .detail-grid, .split { grid-template-columns: 1.2fr .8fr; }
.kpi, .stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.kpi .label, .stat .label { color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi strong, .stat strong { display: block; margin-top: 8px; font-size: 22px; letter-spacing: -.03em; }
.kpi em { font-style: normal; color: var(--muted); font-size: 12px; }
.kpi.net { box-shadow: inset 0 3px 0 var(--accent), var(--shadow); }
.stat strong { font-size: 18px; }
.chart-box { height: 260px; position: relative; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.list { display: grid; gap: 10px; }
.list a, .list .item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding-bottom: 10px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.list a:hover { color: var(--accent-2); }
.money-pos { color: var(--ok); }
.money-neg { color: var(--danger); }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart-grid, .detail-grid, .split { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .page-head, .form-grid, .kpi-grid, .stat-grid { grid-template-columns: 1fr; }
  table.stack { min-width: 0; }
  table.stack thead { display: none; }
  table.stack tr { display: block; border: 1px solid var(--line); border-radius: 14px; margin: 10px; }
  table.stack td { display: flex; justify-content: space-between; gap: 12px; white-space: normal; border: 0; }
  table.stack td::before { content: attr(data-label); color: var(--muted); font-weight: 700; }
}
