:root {
  --ink: #17201b;
  --muted: #607067;
  --line: #d9e1db;
  --panel: #ffffff;
  --bg: #f4f7f1;
  --green: #176b4d;
  --green-2: #0f513a;
  --blue: #245c8a;
  --gold: #a87916;
  --danger: #a64235;
  --shadow: 0 12px 32px rgba(23, 32, 27, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.login-page {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
}

.sidebar {
  min-height: 100vh;
  padding: 22px;
  display: flex;
  flex-direction: column;
  background: #10251d;
  color: #f8fbf8;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255,255,255,.14);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(16, 37, 29, .1);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 5px;
}

.brand h1,
.topbar h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.topbar p,
.panel-head span,
.status-text {
  margin: 4px 0 0;
  color: #aebdb5;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.nav-item,
.primary-btn,
.icon-btn,
.table-btn {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.nav-item {
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  text-align: left;
  color: #dce8e1;
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.primary-btn {
  min-height: 42px;
  border-radius: 8px;
  background: #dfeee5;
  color: #10251d;
  font-weight: 700;
}

.main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h2 {
  font-size: 26px;
}

.topbar p {
  color: var(--muted);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--green);
  box-shadow: var(--shadow);
  font-size: 20px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.secondary-btn {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--green);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.table-btn {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  background: #eaf1ed;
  color: var(--green-2);
  font-size: 12px;
  font-weight: 700;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  width: 112px;
  height: 112px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 10px;
}

.login-panel h1 {
  margin: 0;
}

.login-panel p {
  margin: 6px 0 22px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
  text-align: left;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-form input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.login-status {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.compact-metrics {
  padding: 0 18px 18px;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 96px;
  padding: 16px;
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 22px;
}

.panel {
  margin-top: 16px;
  overflow: hidden;
}

.panel-head {
  min-height: 68px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.panel h3 {
  font-size: 17px;
}

.panel-head span {
  color: var(--muted);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  height: 42px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  background: #f8faf7;
  font-weight: 700;
}

td.amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--danger);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: #eaf1ed;
  color: var(--green-2);
  font-size: 12px;
}

.month-row td {
  background: #eef5f1;
  color: var(--green-2);
}

.month-row td > * {
  margin-right: 10px;
}

.month-toggle {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: #d7e7dd;
  color: var(--green-2);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.inline-form {
  display: grid;
  grid-template-columns: 140px minmax(180px, 1fr) 120px;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.inline-form input,
.inline-form select,
.modal-form input,
.modal-form select,
.project-select {
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
}

.project-select {
  min-width: min(420px, 100%);
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 18px;
}

.option-grid h4 {
  margin: 0 0 10px;
}

.option-list {
  display: grid;
  gap: 8px;
}

.option-item {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.option-item.disabled {
  color: var(--muted);
  opacity: .58;
}

.modal {
  width: min(560px, calc(100vw - 24px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(23, 32, 27, .24);
}

.modal::backdrop {
  background: rgba(16, 37, 29, .42);
}

.modal-form {
  display: grid;
  gap: 12px;
  padding: 18px;
  background: var(--panel);
}

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

.modal-head h3 {
  margin: 0;
}

.modal-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 1040px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 640px) {
  .main,
  .sidebar {
    padding: 16px;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .inline-form,
  .option-grid {
    grid-template-columns: 1fr;
  }
}
