:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #65727d;
  --line: #dbe2e8;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --primary: #176c5f;
  --primary-dark: #0f4e45;
  --accent: #c94737;
  --amber: #b7791f;
  --blue: #2563a8;
  --shadow: 0 14px 32px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

.sidebar {
  min-height: 100vh;
  padding: 24px 18px;
  background: #102b2a;
  color: #f9fbfb;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 2px solid #7ed6c3;
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #b9cac6;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button,
.ghost-button {
  border: 0;
  border-radius: 8px;
  color: inherit;
  background: transparent;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav button.active,
.nav button:hover,
.ghost-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.ghost-button {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.app-shell {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.45rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.top-actions {
  display: flex;
  gap: 12px;
  align-items: end;
}

.search {
  display: grid;
  gap: 6px;
  min-width: 280px;
  color: var(--muted);
  font-size: 0.86rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.primary-button {
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.side-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
  color: inherit;
  padding: 12px 14px;
  text-decoration: none;
}

.side-link.active,
.side-link:hover {
  background: rgba(255, 255, 255, 0.12);
}

.secondary-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  padding: 10px 12px;
}

.icon-button {
  min-width: 38px;
  height: 34px;
  padding: 0 10px;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button:hover,
.icon-button:hover {
  border-color: #9fb2bf;
  background: #f4f7f9;
}

.full {
  grid-column: 1 / -1;
}

.content {
  display: grid;
  gap: 20px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 14px;
}

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

.metric {
  padding: 18px;
}

.metric small {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
}

.metric span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.two-column,
.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 20px;
}

.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.header-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 9px;
  color: #0f4e45;
  background: #e4f4ef;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-dot.warning {
  color: #7a4a10;
  background: #fff2d6;
}

.status-dot.danger {
  color: #84281f;
  background: #ffe4df;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}

.form-grid .panel-header,
.form-grid label:has(textarea) {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.list-item strong {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.list-item small,
.empty {
  color: var(--muted);
}

.accounting-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.summary-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.summary-box small {
  display: block;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 800;
}

.summary-box span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.pill {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e9eef4;
  color: #2c465f;
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.warning {
  color: #7a4a10;
  background: #fff2d6;
}

.pill.danger {
  color: #84281f;
  background: #ffe4df;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(380px, calc(100vw - 48px));
  padding: 13px 16px;
  border-radius: 8px;
  background: #102b2a;
  color: white;
  box-shadow: 0 16px 40px rgba(16, 43, 42, 0.25);
  font-weight: 800;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.bar-list {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  gap: 8px;
}

.bar-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.bar-row strong {
  color: var(--ink);
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf1;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--blue));
}

@media print {
  .sidebar,
  .top-actions,
  .secondary-button,
  .icon-button,
  form,
  .toast {
    display: none !important;
  }

  body {
    display: block;
    background: #fff;
  }

  .app-shell {
    padding: 0;
  }

  .panel,
  .metric {
    box-shadow: none;
  }
}

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

  .sidebar {
    min-height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ghost-button {
    margin-top: 0;
  }

  .topbar,
  .top-actions,
  .two-column,
  .split-layout {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .app-shell,
  .sidebar {
    padding: 18px;
  }

  .nav,
  .metric-grid,
  .form-grid,
  .accounting-summary {
    grid-template-columns: 1fr;
  }
}
