:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #eef2f4;
  --ink: #172026;
  --muted: #66727c;
  --line: #dce2e6;
  --accent: #0f766e;
  --accent-2: #b45309;
  --danger: #b91c1c;
  --good: #047857;
  --shadow: 0 14px 38px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

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

.sidebar {
  background: #172026;
  color: white;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #0f766e;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

.brand p,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.sidebar .brand p {
  color: #a7b2bb;
}

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

.nav-item {
  border: 0;
  background: transparent;
  color: #d9e1e6;
  text-align: left;
  padding: 11px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

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

.topbar,
.section-head,
.panel-header,
.modal-head,
.modal-actions,
.data-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 22px;
}

.topbar h2,
.section-head h3,
.panel h3,
.modal h3 {
  margin: 0;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.button,
.icon-button {
  border: 0;
  cursor: pointer;
  border-radius: 8px;
}

.button {
  background: var(--accent);
  color: white;
  padding: 10px 14px;
  font-weight: 700;
}

.button.ghost {
  background: var(--surface-2);
  color: var(--ink);
}

.button.danger {
  background: var(--danger);
}

.icon-button {
  width: 36px;
  height: 36px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 22px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.field input,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: white;
  color: var(--ink);
}

.field.compact {
  width: 168px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

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

.kpi {
  padding: 18px;
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.kpi strong {
  font-size: 24px;
}

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

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

.panel {
  padding: 18px;
}

.chart-panel {
  margin-bottom: 14px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

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

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

.section-head {
  margin-bottom: 14px;
}

.table-wrap {
  overflow: auto;
}

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

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

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fafafa;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
}

.link-button.danger {
  color: var(--danger);
}

.modal {
  width: min(920px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
}

.modal::backdrop {
  background: rgba(23, 32, 38, 0.45);
}

.modal form {
  display: grid;
  gap: 18px;
}

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

.phase-editor {
  display: grid;
  gap: 8px;
}

.phase-row {
  display: grid;
  grid-template-columns: 1.5fr 100px 120px;
  gap: 8px;
}

.data-panel {
  max-width: 980px;
}

.data-panel p {
  color: var(--muted);
  line-height: 1.55;
}

textarea {
  margin-top: 16px;
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.file-button input {
  display: none;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
  }

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

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

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

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