:root {
  --bg: #090b10;
  --panel: #121722;
  --panel-2: #1a2130;
  --panel-3: #202a3d;
  --border: #2a344a;
  --text: #f5f7fb;
  --muted: #a9b2c3;
  --soft: #748199;
  --purple: #7c5cff;
  --purple-2: #9f8bff;
  --green: #24d27e;
  --green-dark: #0e3d2c;
  --yellow: #ffbd4a;
  --red: #ff5d73;
  --blue: #52a8ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(124,92,255,.16), transparent 34rem), var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}
.sidebar {
  background: rgba(15, 20, 31, .94);
  border-right: 1px solid var(--border);
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #7c5cff, #24d27e);
  font-weight: 950;
  color: #fff;
}
.brand strong { display: block; font-size: 18px; }
.brand small { color: var(--muted); font-weight: 700; }
.nav {
  display: grid;
  gap: 8px;
}
.nav button {
  border: 0;
  color: var(--muted);
  background: transparent;
  padding: 12px 14px;
  border-radius: 10px;
  text-align: left;
  font-weight: 800;
}
.nav button.active,
.nav button:hover {
  background: var(--panel-2);
  color: var(--text);
}
.main {
  padding: 32px;
  min-width: 0;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}
.topbar h1 {
  margin: 0 0 4px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
}
.topbar p { margin: 0; color: var(--muted); font-size: 18px; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  font-weight: 850;
  white-space: nowrap;
}
.grid {
  display: grid;
  gap: 16px;
}
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel,
.card {
  background: rgba(18, 23, 34, .92);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset;
}
.panel h2,
.card h3 {
  margin: 0 0 10px;
}
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.danger-text { color: #ff9aaa; }
.money { color: var(--green); font-weight: 950; }
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.actions-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.between {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 10px;
  font-weight: 900;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--purple), #694cff);
}
.btn.green {
  border-color: transparent;
  background: var(--green);
  color: #04120b;
}
.btn.ghost { background: transparent; }
.btn.danger {
  background: rgba(255, 93, 115, .14);
  border-color: rgba(255, 93, 115, .4);
  color: #ffdbe1;
}
.btn.small {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--panel-3);
  color: var(--muted);
  font-weight: 900;
  font-size: 12px;
}
.pill.green { color: #35e790; background: rgba(36,210,126,.13); }
.pill.yellow { color: #ffd18a; background: rgba(255,189,74,.14); }
.pill.red { color: #ff9cab; background: rgba(255,93,115,.14); }
.pill.blue { color: #9ed0ff; background: rgba(82,168,255,.14); }
.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form .full { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 850; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 13px;
  outline: none;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--purple-2); }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}
th, td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.62);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}
.modal-bg.show { display: flex; }
.modal {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal.wide { width: min(1180px, calc(100vw - 32px)); }
.modal h2 { margin-top: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 8px; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 15px;
  box-shadow: var(--shadow);
  z-index: 50;
}
.ai-box {
  background: linear-gradient(135deg, rgba(124,92,255,.16), rgba(36,210,126,.08));
  border: 1px solid rgba(124,92,255,.45);
  border-radius: 14px;
  padding: 18px;
}
.chat-answer {
  white-space: pre-wrap;
  line-height: 1.55;
  background: #0d111a;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.health-card.green { border-color: rgba(36,210,126,.5); }
.health-card.yellow { border-color: rgba(255,189,74,.55); }
.health-card.red { border-color: rgba(255,93,115,.55); }
.dashboard-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
}
.dashboard-main {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.dashboard-side {
  display: grid;
  align-content: start;
  gap: 16px;
}
.overview-panel, .dre-panel { grid-column: 1 / -1; }
.overview-metrics {
  display: grid;
  grid-template-columns: 180px 180px minmax(220px, 1fr);
  gap: 18px;
  align-items: center;
  margin-top: 18px;
}
.ring-card {
  display: grid;
  place-items: center;
  gap: 10px;
}
.ring {
  width: 138px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--panel) 58%, transparent 59%),
    conic-gradient(var(--green) 0 70%, var(--panel-3) 70% 100%);
}
.ring-card.blue .ring {
  background:
    radial-gradient(circle at center, var(--panel) 58%, transparent 59%),
    conic-gradient(var(--blue) 0 70%, var(--panel-3) 70% 100%);
}
.ring strong { font-size: 24px; }
.mini-ledger, .statement, .category-list {
  display: grid;
  gap: 10px;
}
.mini-ledger div, .statement div, .category-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 9px;
}
.statement-total {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  font-size: 18px;
  font-weight: 950;
}
.flow-chart {
  min-height: 190px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
  padding-top: 16px;
}
.flow-month { display: grid; gap: 8px; text-align: center; color: var(--muted); }
.flow-bars {
  height: 150px;
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 5px;
  border-bottom: 1px solid var(--border);
}
.flow-bars span {
  width: 24px;
  border-radius: 7px 7px 0 0;
  display: block;
}
.flow-bars .planned { background: rgba(36,210,126,.25); }
.flow-bars .received { background: var(--green); }
.compare-row { display: grid; gap: 8px; margin: 14px 0; }
.bar {
  height: 12px;
  border-radius: 999px;
  background: var(--panel-3);
  overflow: hidden;
}
.bar span { display: block; height: 100%; background: var(--green); }
.muted-bar span { background: var(--blue); }
.mini-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.mini-calendar span {
  min-height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-2);
}
.mini-calendar .has-receipt {
  color: #06130d;
  background: var(--green);
  font-weight: 950;
}
.report-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}
.reports-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
}
.reports-menu {
  display: grid;
  align-content: start;
  gap: 8px;
}
.reports-menu button, .transaction-tabs button {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  font-weight: 900;
}
.reports-menu button.active, .transaction-tabs button.active {
  color: #07140e;
  background: var(--green);
  border-color: transparent;
}
.reports-menu button:disabled, .transaction-tabs button:disabled {
  cursor: not-allowed;
  opacity: .55;
}
.transaction-head {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(140px, .5fr)) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}
.transaction-head h2 { margin: 4px 0 0; color: var(--green); }
.transaction-tabs {
  display: flex;
  gap: 10px;
  overflow: auto;
  padding-bottom: 14px;
}
.setup-list {
  margin: 10px 0 0;
  padding-left: 24px;
  color: var(--muted);
  line-height: 1.7;
}
.item-editor {
  display: grid;
  gap: 10px;
}
.item-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(80px, .5fr) minmax(120px, .7fr) 40px;
  gap: 8px;
  align-items: end;
}
.reserved-emission-modal {
  display: grid;
  gap: 16px;
}
.reserved-emission-head { align-items: flex-start; }
.month-picker { min-width: 190px; }
.reserved-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.reserved-summary > div {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 14px;
}
.reserved-summary span,
.reserved-summary strong {
  display: block;
}
.reserved-summary strong {
  margin-top: 5px;
  font-size: 19px;
}
.reserved-table-wrap table { min-width: 1040px; }
.reserved-emission-table th:first-child,
.reserved-emission-table td:first-child {
  width: 42px;
  text-align: center;
}
.reserved-emission-table tr.editing { background: rgba(82,168,255,.06); }
.compact-input {
  min-width: 130px;
  padding: 9px 10px;
  border-radius: 8px;
  margin-top: 6px;
}
.compact-textarea { min-height: 70px; }
.reserved-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.channel-switches {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.checkline {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
}
.checkline input {
  width: auto;
  margin: 0;
  accent-color: var(--green);
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 20px; }
  .grid.two, .grid.three, .grid.four, .form, .reserved-summary { grid-template-columns: 1fr; }
  .dashboard-shell, .dashboard-main, .reports-layout, .report-filters, .transaction-head { grid-template-columns: 1fr; }
  .overview-metrics { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .reserved-footer { align-items: stretch; }
  .channel-switches { align-items: stretch; }
  .checkline { width: 100%; }
}
