:root {
  --bg: #f3efe7;
  --surface: #ffffff;
  --surface-soft: #faf7f1;
  --ink: #15171a;
  --muted: #6b6f76;
  --line: #ded8cf;
  --marine: #044573;
  --marine-dark: #0b2f4d;
  --flamme: #bf1727;
  --ciel: #0879bf;
  --gold: #d99b2b;
  --green: #2f8a5f;
  --shadow: 0 16px 36px rgba(18, 30, 43, 0.1);
  --sidebar-width: 264px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: var(--marine-dark);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  text-decoration: none;
  padding: 8px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: var(--marine);
  font-weight: 800;
  flex: 0 0 auto;
}

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

.brand small,
.sidebar-block small {
  color: rgba(255, 255, 255, 0.66);
}

.side-nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  border: 0;
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.nav-item i {
  width: 18px;
  text-align: center;
}

.nav-item.active,
.nav-item:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
}

.sidebar-block {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 5px;
}

.block-label,
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.block-label {
  color: rgba(255, 255, 255, 0.56);
}

.workspace {
  min-width: 0;
}

.topbar {
  min-height: 70px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.menu-toggle {
  display: none;
}

.search {
  flex: 1 1 auto;
  max-width: 640px;
  min-width: 180px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: var(--muted);
}

.search input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  min-width: 0;
  color: var(--ink);
}

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

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding-left: 8px;
}

.account-chip strong,
.account-chip small {
  display: block;
  white-space: nowrap;
}

.account-chip small {
  color: var(--muted);
  font-size: 12px;
}

.avatar,
.mini-avatar {
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: var(--marine);
  color: #ffffff;
  font-weight: 800;
  flex: 0 0 auto;
}

.avatar {
  width: 38px;
  height: 38px;
}

.mini-avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
}

.icon-button,
.ghost-button,
.primary-button,
.secondary-button,
.small-button,
.filter-chip {
  border-radius: 8px;
  border: 1px solid transparent;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

.icon-button {
  width: 38px;
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--marine);
}

.ghost-button,
.secondary-button,
.small-button,
.filter-chip {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  padding: 0 12px;
}

.primary-button {
  background: var(--marine);
  color: #ffffff;
  padding: 0 14px;
}

.small-button {
  min-height: 32px;
  font-size: 13px;
}

.filter-chip {
  min-height: 34px;
  font-size: 13px;
}

.filter-chip.active {
  background: var(--marine);
  border-color: var(--marine);
  color: #ffffff;
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-head.compact {
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--flamme);
}

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

h1 {
  font-size: 32px;
  line-height: 1.05;
  margin-bottom: 0;
}

h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

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

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

.metric,
.panel,
.detail-pane,
.militant-card,
.kanban-column {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  display: grid;
  gap: 7px;
}

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

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

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

.metric.alert {
  border-color: rgba(191, 23, 39, 0.28);
}

.dashboard-grid,
.inventory-layout,
.senate-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(300px, 0.8fr);
  gap: 16px;
}

.module-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}

.dashboard-grid > *,
.inventory-layout > *,
.senate-grid > *,
.module-layout > *,
.kanban > * {
  min-width: 0;
}

.panel,
.detail-pane {
  padding: 16px;
  min-width: 0;
}

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

.panel-head p {
  margin-bottom: 0;
}

.table-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.data-table {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid #eee8df;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

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

tr:hover td {
  background: #fbf8f2;
}

.person-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.person-cell strong,
.person-cell small {
  display: block;
}

.person-cell small {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  background: #edf3f8;
  color: var(--marine);
}

.pill.red {
  background: #fff0f1;
  color: var(--flamme);
}

.pill.green {
  background: #edf8f2;
  color: var(--green);
}

.pill.gold {
  background: #fff6df;
  color: #8a5b05;
}

.detail-pane {
  position: sticky;
  top: 88px;
  display: grid;
  gap: 14px;
}

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

.detail-header .avatar {
  width: 52px;
  height: 52px;
}

.field-list {
  display: grid;
  gap: 10px;
}

.field-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  font-size: 14px;
}

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

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

.timeline-item {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  padding: 11px;
  border: 1px solid #eee8df;
  border-radius: 8px;
  background: var(--surface-soft);
}

.timeline-item time {
  color: var(--muted);
  font-size: 13px;
}

.timeline-item strong {
  display: block;
  margin-bottom: 2px;
}

.priority-list,
.request-list,
.campaign-list,
.cards-grid,
.kanban {
  display: grid;
  gap: 12px;
}

.priority-item {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: left;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ciel);
}

.status-dot.red {
  background: var(--flamme);
}

.status-dot.yellow {
  background: var(--gold);
}

.status-dot.blue {
  background: var(--ciel);
}

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

.militant-card {
  padding: 16px;
  display: grid;
  gap: 12px;
}

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

.card-top strong,
.card-top small {
  display: block;
}

.skill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inventory-layout {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.request-card {
  border: 1px solid #eee8df;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
  background: var(--surface-soft);
}

.campaign-card {
  background: #ffffff;
}

.campaign-sequence-head {
  margin-top: 18px;
}

.request-card strong {
  display: block;
}

.request-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.kanban {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.kanban-column {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.kanban-column h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.task-card {
  border: 1px solid #eee8df;
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.task-card p {
  margin-bottom: 0;
}

.territory-map {
  height: 280px;
  position: relative;
  background:
    linear-gradient(135deg, rgba(8, 121, 191, 0.08), rgba(191, 23, 39, 0.08)),
    var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.territory-map::before,
.territory-map::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(4, 69, 115, 0.18);
  background: rgba(255, 255, 255, 0.45);
  transform: rotate(-10deg);
}

.territory-map::before {
  width: 58%;
  height: 70%;
  left: 18%;
  top: 16%;
}

.territory-map::after {
  width: 32%;
  height: 38%;
  right: 10%;
  bottom: 12%;
}

.territory-map span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  z-index: 1;
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--marine);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
}

.sequence-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 12px;
}

.sequence-list li {
  padding-left: 6px;
}

.sidebar-open .sidebar {
  transform: translateX(0);
}

@media (max-width: 1180px) {
  .metrics-grid,
  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .inventory-layout,
  .senate-grid,
  .module-layout {
    grid-template-columns: 1fr;
  }

  .detail-pane {
    position: static;
  }
}

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

  .sidebar {
    position: fixed;
    z-index: 40;
    width: min(var(--sidebar-width), 88vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .topbar {
    padding: 10px 14px;
    flex-wrap: wrap;
  }

  .search {
    order: 3;
    max-width: none;
    flex-basis: 100%;
  }

  .account-chip {
    display: none;
  }

  .content {
    padding: 18px 14px;
  }

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

  h1 {
    font-size: 27px;
  }
}

@media (max-width: 620px) {
  .metrics-grid,
  .cards-grid,
  .kanban {
    grid-template-columns: 1fr;
  }

  .head-actions,
  .topbar-actions {
    width: 100%;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    flex: 1 1 auto;
  }

  .timeline-item,
  .field-row {
    grid-template-columns: 1fr;
  }
}
