:root {
  --bg: #f7f4fb;
  --surface: #ffffff;
  --surface-2: #f0ebf6;
  --text: #18131f;
  --muted: #6c6077;
  --line: #ded6e8;
  --primary: #7c2cff;
  --primary-dark: #5a19c9;
  --accent: #d7a629;
  --danger: #c9334b;
  --success: #19885a;
  --shadow: 0 16px 36px rgba(38, 17, 66, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: #120e18;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
}

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

.brand-mark {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #7c2cff, #d7a629);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

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

.brand span {
  margin-top: 2px;
  color: #c7bccf;
  font-size: 0.86rem;
}

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

.nav-item,
.ghost-button,
.primary-button,
.danger-button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 14px;
  font-weight: 700;
}

.nav-item {
  text-align: left;
  background: transparent;
  color: #d8cfdf;
}

.nav-item:hover,
.nav-item.active {
  background: #251c31;
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.ghost-button {
  display: inline-grid;
  place-items: center;
  background: #fff;
  color: #24192d;
  border: 1px solid var(--line);
}

.sidebar .ghost-button {
  background: #24192d;
  color: #fff;
  border-color: #3e314b;
}

.small {
  min-height: 34px;
  font-size: 0.86rem;
}

.file-button input {
  display: none;
}

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

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 2vw, 2.5rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.05rem;
}

.period-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

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

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

.metric {
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
}

.metric.warning strong {
  color: var(--danger);
}

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

.wide {
  grid-column: 1 / -1;
}

.panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-heading h2 {
  margin: 0;
}

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

.form-panel {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

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

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

.primary-button:hover {
  background: var(--primary-dark);
}

.danger-button {
  min-height: 34px;
  color: #fff;
  background: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  background: var(--surface-2);
}

.status-ok {
  color: var(--success);
  background: #e9f8f1;
}

.status-risk {
  color: var(--danger);
  background: #ffecef;
}

.stack-list,
.agenda-list,
.people-grid,
.catalog-grid {
  display: grid;
  gap: 10px;
}

.list-item,
.person-card,
.catalog-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.item-title {
  margin: 0;
  font-weight: 800;
}

.item-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.agenda-list {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.people-grid,
.catalog-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

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

.bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 110px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #18131f;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  color: var(--muted);
  margin: 0;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    padding: 14px;
    gap: 14px;
  }

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

  .nav-item {
    text-align: center;
  }

  .content {
    padding: 18px;
  }

  .metric-grid,
  .dashboard-grid,
  .split-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar,
  .list-item,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .nav,
  .sidebar-footer,
  .two-cols {
    grid-template-columns: 1fr;
  }

  .metric strong {
    font-size: 1.3rem;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }
}

.contact-filters { display: flex; flex-wrap: wrap; gap: 14px; margin: 20px 0; }
.contact-filters label { min-width: 200px; }
.contact-card { display: grid; gap: 12px; }
.contact-card .message-preview { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; padding: 14px; border-radius: 8px; background: var(--surface-2); }
.contact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.whatsapp-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; background: #137a48; }
.whatsapp-button:hover { background: #0d6037; }
.nav-item span:not(:empty) { float: right; background: #7c2cff; color: white; border-radius: 12px; padding: 1px 7px; }
[hidden] { display: none !important; }
@media (max-width: 620px) {
  .sidebar { position: static; }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .nav-item { padding: 6px; font-size: .8rem; }
  .contact-filters label { min-width: 0; width: 100%; }
}
