:root {
  color-scheme: light;
  --bg: #f2f6ee;
  --surface: #ffffff;
  --surface-muted: #e9f3df;
  --line: #d4e3cc;
  --text: #09160f;
  --muted: #5f6e5e;
  --green: #0c482f;
  --green-strong: #052d20;
  --leaf: #86c947;
  --mint: #dcf4cd;
  --gold: #e6b33d;
  --rose: #b95a56;
  --blue: #4677a8;
  --shadow: 0 18px 45px rgba(11, 37, 22, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #07150e;
  color: #f5fbf4;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  border-right: 4px solid var(--leaf);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.brand-logo {
  width: 78px;
  height: 46px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  padding: 4px;
}

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

.brand span,
.sidebar-footer {
  color: #aebcad;
  font-size: 13px;
}

.brand strong {
  line-height: 1.15;
}

.nav-list {
  display: grid;
  gap: 6px;
  margin-top: 34px;
}

.nav-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dbe8da;
  text-align: left;
  padding: 0 12px;
}

.nav-item:hover,
.nav-item.active {
  background: #123420;
  color: #ffffff;
}

.nav-item.active {
  box-shadow: inset 3px 0 0 var(--leaf);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--leaf);
  box-shadow: 0 0 0 4px rgba(134, 201, 71, 0.16);
}

.workspace {
  min-width: 0;
  padding: 28px clamp(18px, 3vw, 42px) 42px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 40px);
  line-height: 1.05;
}

h2 {
  font-size: 19px;
  margin-bottom: 14px;
}

h3 {
  font-size: 15px;
  margin-bottom: 7px;
}

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

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(34vw, 360px);
  min-width: 190px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-wrap input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  text-decoration: none;
}

.primary-button {
  background: linear-gradient(135deg, var(--green-strong), var(--green));
  color: #fff;
  font-weight: 750;
}

.secondary-button {
  background: var(--surface);
  color: var(--green-strong);
  border-color: var(--line);
  font-weight: 700;
}

.compact-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.compact-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.action-cell {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.danger-button {
  color: #8a1f1f;
  border-color: #e2b8b8;
}

.sort-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 0;
  text-align: left;
  text-transform: uppercase;
}

.icon-button {
  width: 42px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric {
  min-height: 130px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  width: 72px;
  height: 5px;
  background: var(--leaf);
}

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

.metric strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 34px;
  line-height: 1;
}

.metric.clickable,
.clickable-row {
  cursor: pointer;
}

.metric.clickable:hover,
.clickable-row:hover {
  background: var(--surface-muted);
}

.centered-metric {
  text-align: center;
}

.centered-metric::after {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.hero-message {
  max-width: 780px;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.12;
}

.inline-select select {
  width: 100%;
  min-height: 36px;
  margin-top: 4px;
}

.compact-metrics .metric {
  min-height: 112px;
}

.compact-metrics .metric strong {
  font-size: 30px;
  line-height: 1.05;
}

.compact-metrics .metric strong.single-line {
  font-size: 24px;
  white-space: nowrap;
}

.compact-metrics .centered-metric {
  text-align: center;
}

.compact-metrics .centered-metric::after {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
}

.metric p {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
  margin-top: 16px;
}

.side-stack {
  display: grid;
  align-content: start;
  gap: 16px;
}

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

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

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar.no-margin {
  margin-bottom: 0;
}

.table-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.table-tools input {
  min-height: 34px;
  min-width: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
}

.table-wrap.is-collapsed {
  display: none;
}

.table-wrap th {
  cursor: pointer;
}

.transport-items {
  display: grid;
  gap: 10px;
}

.transport-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 0.45fr);
  gap: 10px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-muted);
}

.segmented button {
  border: 0;
  border-radius: 7px;
  background: transparent;
  min-height: 32px;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 700;
}

.segmented button.active {
  background: var(--surface);
  color: var(--green-strong);
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover {
  background: #f7faf5;
}

tbody tr.selected-row {
  background: #eef8e7;
  box-shadow: inset 3px 0 0 var(--leaf);
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.chip.green {
  background: var(--mint);
  color: var(--green-strong);
}

.chip.gold {
  background: #fff0ce;
  color: #7d5410;
}

.chip.rose {
  background: #ffe4e2;
  color: #8a312c;
}

.chip.blue {
  background: #e3eef9;
  color: #24527e;
}

.detail-list {
  display: grid;
  gap: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.detail-row span {
  color: var(--muted);
}

.timeline {
  display: grid;
  gap: 12px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 12px;
}

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

.timeline-item {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
}

.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--green);
}

.timeline-item p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

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

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric-grid + .panel {
  margin-top: 16px;
}

.report-card,
.doc-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  min-height: 170px;
}

.report-card p,
.doc-card p {
  color: var(--muted);
  min-height: 44px;
}

.mini-table {
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 10px 0 14px;
  max-height: 150px;
}

.mini-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.mini-table th,
.mini-table td {
  border-bottom: 1px solid var(--line);
  padding: 7px 6px;
  text-align: left;
  white-space: nowrap;
}

.brand-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  align-items: center;
  gap: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(5, 45, 32, 0.97), rgba(12, 72, 47, 0.94)),
    radial-gradient(circle at 85% 15%, rgba(134, 201, 71, 0.22), transparent 32%);
  color: #fff;
  padding: 22px;
  box-shadow: var(--shadow);
}

.brand-hero h2 {
  font-size: clamp(23px, 3vw, 34px);
  margin-bottom: 8px;
}

.brand-hero p {
  max-width: 760px;
  color: #dbeed5;
  margin-bottom: 0;
}

.hero-logo {
  width: 100%;
  max-height: 160px;
  object-fit: contain;
  justify-self: end;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  padding: 10px;
}

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

.doc-card {
  min-height: 154px;
}

.doc-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 17px;
}

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

.doc-kpi {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdf8;
  padding: 14px;
}

.doc-kpi span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.doc-kpi strong {
  display: block;
  margin-top: 7px;
  font-size: 23px;
}

.template-link {
  color: var(--green-strong);
  font-weight: 800;
  text-decoration: none;
}

.template-link:hover {
  text-decoration: underline;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #17251d;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: 0.2s ease;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 16, 10, 0.58);
  padding: 18px;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: min(760px, 100%);
  max-height: min(88vh, 760px);
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .brand div:last-child,
  .nav-item span:last-child,
  .sidebar-footer span:last-child {
    display: none;
  }

  .brand-logo {
    width: 48px;
  }

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 0;
  }

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

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

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: block;
    padding: 10px;
  }

  .brand,
  .sidebar-footer {
    display: none;
  }

  .nav-list {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    margin: 0;
  }

  .nav-item {
    min-height: 40px;
  }

  .workspace {
    padding: 18px 14px 34px;
  }

  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-wrap {
    width: 100%;
  }

  .metric-grid,
  .report-grid,
  .doc-grid,
  .doc-kpis,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .brand-hero {
    grid-template-columns: 1fr;
  }

  .hero-logo {
    justify-self: start;
    max-width: 210px;
  }
}
