:root {
  --ink: #17231c;
  --muted: #667064;
  --line: #d6dfd1;
  --paper: #ffffff;
  --field: #f6f8f4;
  --bg: #edf2ec;
  --green: #244d35;
  --green-2: #326847;
  --gold: #b8892f;
  --danger: #a04638;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  min-width: 0;
}

.sidebar {
  background: #f8faf6;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
  padding: 22px;
}

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

.brand-mark {
  align-items: center;
  background: var(--green);
  border-radius: 8px;
  color: white;
  display: grid;
  font-weight: 800;
  height: 46px;
  justify-content: center;
  width: 46px;
}

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

.brand span,
.eyebrow,
.metric span,
.metric small,
.pill,
.sync-box,
th {
  color: var(--muted);
}

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

.nav-button,
button,
select {
  border-radius: 6px;
}

.nav-button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
  cursor: pointer;
  padding: 11px 12px;
  text-align: left;
}

.nav-button.active,
.nav-button:hover {
  background: #e9f1e6;
  border-color: #c8d9c1;
  color: var(--green);
  font-weight: 700;
}

.sync-box {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
}

button {
  background: var(--green);
  border: 0;
  color: white;
  cursor: pointer;
  font-weight: 700;
  padding: 10px 14px;
}

button:hover {
  background: var(--green-2);
}

.ghost-button {
  background: #edf2ec;
  color: var(--green);
}

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

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

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

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

select,
input {
  background: white;
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 40px;
  padding: 9px 10px;
}

.view {
  display: none;
  min-width: 0;
}

.view.active {
  display: block;
}

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

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

.metric {
  display: grid;
  gap: 6px;
  min-height: 122px;
  padding: 16px;
}

.metric strong {
  color: var(--green);
  font-size: 26px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 14px 16px;
}

.pill {
  background: #f2f5ef;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  padding: 5px 9px;
  white-space: nowrap;
}

.table-wrap {
  min-width: 0;
  overflow-x: auto;
}

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

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

th {
  background: #f7f9f5;
  font-size: 12px;
  text-transform: uppercase;
}

td[contenteditable="true"] {
  background: #fffdf6;
  outline-color: var(--gold);
}

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

dialog {
  border: 1px solid var(--line);
  border-radius: 10px;
  max-width: 720px;
  padding: 0;
  width: min(92vw, 720px);
}

dialog::backdrop {
  background: rgba(20, 30, 24, 0.45);
}

.dialog-header,
.dialog-actions {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0;
  padding: 16px;
}

.dialog-header {
  border-bottom: 1px solid var(--line);
}

.dialog-actions {
  border-top: 1px solid var(--line);
}

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

.field {
  display: grid;
  gap: 6px;
}

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

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-shell {
  padding: 18px;
  width: min(100%, 460px);
}

.login-panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.login-brand {
  background: #f8faf6;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.login-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

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

.field input,
.field select {
  width: 100%;
}

.error-message {
  color: var(--danger);
  min-height: 20px;
  margin: 0;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    padding: 14px;
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .nav-button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .sync-box {
    align-items: center;
    border-top: 0;
    display: flex;
    margin-top: 0;
    padding-top: 0;
  }

  .content {
    padding: 16px;
  }

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

@media (max-width: 640px) {
  .topbar,
  .top-actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

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

  table {
    min-width: 720px;
  }
}
