:root {
  --bg: #eef1f3;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #111827;
  --muted: #64707d;
  --line: #d7dde3;
  --strong-line: #b8c1ca;
  --blue: #1f5f99;
  --teal: #14746f;
  --amber: #a15c00;
  --red: #a83232;
  --green: #217346;
  --nav: #18212b;
  --nav-2: #243140;
  --shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

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

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.nav {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100vh;
  padding: 18px 14px;
  color: #eef4f8;
  background: var(--nav);
}

.brand {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  padding: 6px 8px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: #2b7a78;
  font-weight: 800;
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
}

.brand-subtitle {
  margin-top: 2px;
  color: #aab8c4;
  font-size: 12px;
}

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

.nav-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 0;
  padding: 7px 9px;
  color: #dce5ec;
  background: transparent;
  text-align: left;
}

.nav-item span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #b8c9d6;
  font-size: 11px;
  font-weight: 800;
}

.nav-item.active,
.nav-item:hover {
  background: var(--nav-2);
  color: #fff;
}

.nav-footer {
  margin-top: auto;
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.small-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.source-pill {
  margin-top: 8px;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e6eef5;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
}

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

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

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

h1 {
  font-size: 24px;
  line-height: 1.1;
}

.subtitle,
.section-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

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

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.actor-input,
.filters input,
.filters select {
  height: 34px;
  border: 1px solid var(--line);
  padding: 0 9px;
  color: var(--ink);
  background: var(--surface);
}

.actor-input {
  width: 160px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  font-size: 18px;
  line-height: 1;
}

.kpi-band {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.kpi,
.admin-tile {
  min-height: 76px;
  border: 1px solid var(--line);
  padding: 12px;
  background: var(--surface);
}

.kpi span,
.admin-tile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi strong,
.admin-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 10px;
}

.section-head h2 {
  font-size: 18px;
}

.segmented {
  display: flex;
  border: 1px solid var(--line);
  background: var(--surface);
}

.segmented button {
  min-width: 86px;
  height: 32px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  color: #fff;
  background: var(--blue);
}

.filters {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 120px 140px 150px minmax(120px, 1fr) 86px;
  gap: 8px;
  margin-bottom: 10px;
}

.filters label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.filters button,
.action-bar button {
  height: 34px;
  align-self: end;
  border: 1px solid var(--blue);
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.table-shell {
  overflow: auto;
  max-height: calc(100vh - 238px);
  border: 1px solid var(--line);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #44515e;
  background: var(--surface-2);
  font-size: 11px;
  text-transform: uppercase;
}

td {
  overflow-wrap: anywhere;
}

tr:hover td {
  background: #f2f7fa;
}

.row-button {
  border: 0;
  padding: 0;
  color: var(--blue);
  background: transparent;
  text-align: left;
  font-weight: 800;
}

.status,
.priority,
.risk {
  display: inline-block;
  min-width: 28px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.status.approved,
.risk.high {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.status.pending_review,
.status.in_review,
.risk.medium {
  color: #fff;
  background: var(--amber);
  border-color: var(--amber);
}

.status.rejected,
.risk.low {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.priority.p1,
.priority.p2 {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.detail-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  display: none;
  width: min(560px, 96vw);
  overflow: auto;
  border-left: 1px solid var(--strong-line);
  padding: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-drawer.open {
  display: block;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.drawer-head h2 {
  margin-top: 4px;
  font-size: 18px;
  line-height: 1.25;
}

.drawer-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.meta-item {
  border: 1px solid var(--line);
  padding: 8px;
  background: var(--surface-2);
}

.meta-item span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-item strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.action-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.action-bar .danger {
  border-color: var(--red);
  background: var(--red);
}

.drawer-section {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  margin-top: 12px;
}

.drawer-section h3 {
  margin-bottom: 8px;
  font-size: 13px;
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-row {
  border: 1px solid var(--line);
  padding: 8px;
  background: var(--surface-2);
  font-size: 12px;
}

.mini-row strong {
  display: block;
  margin-bottom: 4px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
}

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

  .nav {
    min-height: 0;
  }

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

  .kpi-band,
  .filters,
  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 620px) {
  .workspace {
    padding: 12px;
  }

  .kpi-band,
  .filters,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .segmented {
    overflow: auto;
  }

  .segmented button {
    min-width: 104px;
  }
}
