:root {
  --bg: #f5f7fb;
  --panel: #fff;
  --text: #182033;
  --muted: #657086;
  --brand: #2952cc;
  --line: #e4e9f2;
  --good: #047857;
  --bad: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 230px;
  background: #101828;
  color: #fff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand { font-weight: 800; font-size: 23px; margin-bottom: 25px; }
.brand span { color: #8fb3ff; }
.sidebar a { color: #dbe4ff; text-decoration: none; padding: 11px 12px; border-radius: 12px; }
.sidebar a:hover { background: #1d2939; }

.main {
  margin-left: 230px;
  padding: 28px;
  max-width: 1500px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.page-head p,
.hint { color: var(--muted); }

.panel,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  margin: 18px 0;
  box-shadow: 0 10px 30px rgba(16, 24, 40, .05);
}

.login-card { max-width: 460px; margin: 8vh auto; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi {
  background: linear-gradient(180deg, #fff, #f8fbff);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.kpi span { display: block; color: var(--muted); font-size: 13px; }
.kpi strong {
  display: block;
  font-size: 26px;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  color: #475467;
  background: #f8fafc;
}

input,
select,
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #cfd6e4;
  border-radius: 12px;
  margin-top: 6px;
  background: #fff;
}

label {
  display: block;
  margin: 8px 0;
  font-weight: 600;
  color: #344054;
}

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(260px, 1fr)); gap: 14px; }
.wide { grid-column: 1 / -1; }
.form-row { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 12px; }

.button,
button {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 11px 16px;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 700;
}

.button.secondary {
  background: #eef4ff;
  color: #2446a6;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  background: #eef4ff;
  color: #2446a6;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
}

.tag.muted { background: #eee; color: #555; }
.tag.credit { background: #ecfdf3; color: #047857; }
.tag.debit { background: #fff1f3; color: #b42318; }
.positive { color: var(--bad); font-weight: 700; }
.negative { color: var(--good); font-weight: 700; }

.ledger-table {
  font-size: 13px;
  display: block;
  width: 100%;
  overflow-x: auto;
}
.ledger-table th,
.ledger-table td { white-space: nowrap; }
.ledger-table td:nth-child(4),
.ledger-table td:nth-child(11) {
  white-space: normal;
  min-width: 180px;
}

.total-row td {
  background: #f8fafc;
  font-weight: 800;
  border-top: 2px solid var(--line);
}

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.flash.success { background: #ecfdf3; color: #027a48; }
.flash.error { background: #fef3f2; color: #b42318; }
.analytics-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.note li { margin-bottom: 8px; }

@media (max-width: 900px) {
  .sidebar { position: static; width: auto; }
  .main { margin-left: 0; padding: 16px; }
  .kpi-grid,
  .form-grid,
  .form-row,
  .analytics-grid { grid-template-columns: 1fr; }
  table {
    font-size: 13px;
    display: block;
    overflow: auto;
  }
}
