:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #dbe2e1;
  --text: #15201f;
  --muted: #63706e;
  --accent: #167b66;
  --accent-2: #245c8f;
  --warn: #b54708;
  --danger: #b42318;
  --good: #087443;
  --shadow: 0 12px 28px rgba(18, 34, 33, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { border: 0; cursor: pointer; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 272px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #10211f;
  color: #f6fbf9;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 8px;
  background: linear-gradient(135deg, #31b68f, #3d83c5);
  display: grid; place-items: center; font-weight: 800;
}
.brand-title { font-size: 18px; font-weight: 800; }
.brand-subtitle { color: #b9cbc7; font-size: 12px; }
.nav { display: grid; gap: 6px; }
.nav button {
  min-height: 42px; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; color: #d8e6e2; background: transparent;
  border-radius: 8px; text-align: left;
}
.nav button.active, .nav button:hover { background: rgba(255,255,255,0.1); color: #fff; }
.role-box {
  margin-top: auto; display: grid; gap: 8px; padding: 12px;
  background: rgba(255,255,255,0.08); border-radius: 8px;
}
.role-box label { color: #d8e6e2; font-size: 12px; }
.role-box strong { font-size: 13px; }
.logout-btn { min-height: 32px; color: #fff; background: rgba(255,255,255,.12); border-radius: 6px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 22px; background: #e8efee; }
.login-card { width: min(400px, 100%); padding: 28px; background: #fff; border: 1px solid #d4dfdc; border-radius: 8px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-brand strong, .login-brand span { display: block; }
.login-brand span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.login-card h1 { margin: 0 0 6px; font-size: 24px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card form { display: grid; gap: 14px; }
.login-card .btn { width: 100%; }
.login-error { min-height: 18px; color: var(--danger); font-size: 13px; }
.password-field { position: relative; }
.password-field input { padding-right: 46px; }
.password-toggle { position: absolute; top: 50%; right: 7px; display: grid; width: 32px; height: 32px; place-items: center; transform: translateY(-50%); color: #45645d; background: transparent; border: 0; border-radius: 4px; cursor: pointer; font-size: 17px; }
.password-toggle:hover, .password-toggle:focus-visible { background: #edf4f2; outline: none; }

.main { min-width: 0; padding: 22px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.topbar h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: 0; }
.topbar p { margin: 0; color: var(--muted); }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

.btn {
  min-height: 38px; border-radius: 8px; padding: 9px 12px;
  background: var(--accent); color: white; display: inline-flex;
  align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
}
.btn.secondary { background: #e7eeec; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }

.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-col { grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.card-body { padding: 16px; }
.kpi { min-height: 116px; display: grid; align-content: space-between; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi strong { display: block; margin-top: 10px; font-size: 26px; line-height: 1.1; }
.negative { color: var(--danger) !important; }
.positive { color: var(--good) !important; }
.muted { color: var(--muted); }
.section-title { margin: 0 0 12px; font-size: 17px; }

.filters, .form-grid {
  display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px; align-items: end; margin-bottom: 14px;
}
.form-grid.compact { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
input, select, textarea {
  width: 100%; min-height: 38px; border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--text);
}
textarea { min-height: 76px; resize: vertical; }

.table-wrap { overflow: auto; border: 1px solid #b9c7c4; border-radius: 4px; }
table { width: 100%; border-collapse: collapse; min-width: 820px; background: #fff; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: #fff; font-size: 11px; font-weight: 700; background: #134f5c; position: sticky; top: 0; z-index: 1; text-align: center; }
tr:last-child td { border-bottom: 0; }
.operation-row.income td { background: #b1e1cd; }
.operation-row.expense td { background: #e0b1c5; }
.operation-row.transfer td { background: #d9d9d9; }
.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge {
  display: inline-flex; align-items: center; min-height: 24px;
  padding: 3px 8px; border-radius: 999px; background: #e7eeec;
  color: var(--text); font-size: 12px;
}
.badge.good { background: #dff7ea; color: var(--good); }
.badge.warn { background: #fff1d6; color: var(--warn); }
.badge.danger { background: #fee4e2; color: var(--danger); }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; display: grid;
  place-items: center; background: #edf3f1; color: var(--text);
}

.chart {
  height: 280px; display: flex; align-items: flex-end; gap: 10px;
  padding: 16px 10px 6px; border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.bar-group {
  flex: 1; min-width: 44px; display: grid; grid-template-columns: 1fr 1fr;
  align-items: end; gap: 3px; height: 100%; position: relative;
}
.bar { min-height: 4px; border-radius: 4px 4px 0 0; }
.bar.income { background: var(--accent); }
.bar.expense { background: var(--accent-2); }
.bar-label {
  position: absolute; bottom: -24px; left: 50%; transform: translateX(-50%);
  color: var(--muted); font-size: 11px;
}
.alert-list { display: grid; gap: 10px; }
.alert { padding: 12px; border-left: 4px solid var(--warn); background: #fff8eb; border-radius: 8px; }
.alert.danger { border-left-color: var(--danger); background: #fff0ee; }
.alert strong { display: block; margin-bottom: 4px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { min-height: 36px; padding: 8px 12px; border-radius: 8px; background: #e7eeec; color: var(--text); }
.tabs button.active { background: var(--accent); color: white; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented button { min-height: 36px; padding: 8px 12px; background: #fff; color: var(--text); border-right: 1px solid var(--line); }
.segmented button:last-child { border-right: 0; }
.segmented button.active { background: #134f5c; color: #fff; }
.report-controls { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.report-controls .tabs { margin: 0; }
.report-controls label { min-width: 180px; }
.report-sheet th { background: #134f5c; }
.salary-control { display: grid; grid-template-columns: minmax(260px, .65fr) 1fr; gap: 18px; align-items: end; }
.salary-profile { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px 16px; min-height: 38px; padding: 9px 12px; background: #edf5f2; border-left: 4px solid var(--accent); }
.salary-profile strong { font-size: 16px; }
.salary-profile span { color: var(--muted); font-size: 13px; }
.transfer-summary {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 14px 0; padding: 10px 12px; border-left: 4px solid var(--warn);
  background: #fff8eb; color: var(--text);
}
.transfer-summary span { color: var(--muted); }
.form-hint { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(12,25,24,.45);
  display: grid; place-items: center; padding: 18px; z-index: 5;
}
.modal {
  width: min(920px, 100%); max-height: 92vh; overflow: auto;
  background: white; border-radius: 8px; box-shadow: 0 22px 70px rgba(0,0,0,.28);
}
.modal header {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 16px; border-bottom: 1px solid var(--line);
}
.modal header h2 { margin: 0; font-size: 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 0 0; }
.import-box { display: grid; gap: 10px; }
.import-box textarea { min-height: 180px; font-family: Consolas, monospace; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpis, .two-col, .filters, .form-grid, .form-grid.compact { grid-template-columns: 1fr 1fr; }
  .salary-control { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .main { padding: 14px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .nav, .kpis, .filters, .form-grid, .form-grid.compact { grid-template-columns: 1fr; }
  .toolbar { width: 100%; }
  .toolbar .btn, .toolbar select { flex: 1; }
}
@media print {
  .sidebar, .toolbar, .actions, .filters, .tabs, .modal-backdrop { display: none !important; }
  .shell { display: block; }
  body, .main, .card { background: white; box-shadow: none; }
}
