:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --line-strong: #d1d5db;
  --section: #eef0f3;
  --head: #111827;
  --soft: #f8fafc;
  --good: #15803d;
  --bad: #b91c1c;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 16px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 12px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: calc(100vh - 32px);
}

.bp-card {
  min-height: calc(100vh - 32px);
  border: 1px solid #e6e6e6;
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.05);
}

.bp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  background: var(--head);
  color: #fff;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 190px;
}

.brand strong {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
}

.brand span {
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
}

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

.nav {
  justify-content: flex-end;
}

.nav a,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.nav a {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.14);
}

.button.primary {
  border-color: var(--head);
  background: var(--head);
  color: #fff;
}

.button:hover {
  border-color: var(--line-strong);
}

.content {
  padding: 14px 16px 18px;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.message {
  padding: 9px 12px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  background: #f0fdf4;
  color: var(--good);
  font-weight: 700;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 12px;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
}

h1 {
  margin: 2px 0 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
}

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

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

.metrics {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  margin-bottom: 12px;
}

.metric {
  min-height: 82px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.metric span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.metric strong {
  font-size: 26px;
  line-height: 1;
}

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

.panel {
  border: 1px solid #e6e6e6;
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.panel + .panel,
.form-panel + .form-panel {
  margin-top: 12px;
}

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

.table-wrap {
  width: 100%;
  overflow: auto;
}

.table-wrap::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink);
  font-size: 12px;
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 42px;
  background: #fafafa;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

tbody tr:hover td {
  background: #fafafa;
}

tr:last-child td {
  border-bottom: 0;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--section);
  color: #4b5563;
  font-size: 11px;
  font-weight: 800;
}

.pill.good {
  background: #dcfce7;
  color: var(--good);
}

.pill.warn {
  background: #fee2e2;
  color: var(--bad);
}

.search {
  display: flex;
  gap: 8px;
}

.search input,
.field-control,
.entry-table input,
.entry-table select,
.entry-table textarea {
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.search input {
  width: min(360px, 52vw);
}

.field-control:focus,
.entry-table input:focus,
.entry-table select:focus,
.entry-table textarea:focus,
.search input:focus {
  outline: 2px solid rgba(17, 24, 39, 0.12);
  border-color: var(--head);
}

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

.facts {
  padding: 4px 14px;
}

.fact {
  display: grid;
  gap: 4px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}

.fact:last-child {
  border-bottom: 0;
}

.fact span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.data-form {
  display: block;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 14px;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.field.wide {
  grid-column: span 2;
}

.field-error,
.form-errors {
  color: var(--bad);
  font-size: 11px;
  font-weight: 700;
}

.form-errors {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
}

.entry-table {
  min-width: 1120px;
}

.entry-table td {
  height: 46px;
  padding: 7px 8px;
}

.entry-table input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
  margin: 7px 0 0;
}

.entry-table ul.errorlist {
  margin: 4px 0 0;
  padding: 0;
  color: var(--bad);
  list-style: none;
  font-size: 10px;
  font-weight: 700;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

@media (max-width: 980px) {
  body {
    padding: 0;
  }

  .bp-card {
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .bp-header,
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav,
  .actions {
    justify-content: flex-start;
  }

  .metrics,
  .two-col,
  .detail-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .field.wide {
    grid-column: span 1;
  }
}
