:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #edf2ef;
  --line: #d8e0dc;
  --text: #17211d;
  --muted: #66736e;
  --teal: #0f766e;
  --teal-soft: #d8f3ee;
  --amber: #b7791f;
  --amber-soft: #fff3cf;
  --rose: #be123c;
  --rose-soft: #ffe4e9;
  --violet: #6d28d9;
  --shadow: 0 12px 36px rgba(18, 29, 24, 0.08);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  background: #10231f;
  color: #f8faf9;
}

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

.brand img {
  border-radius: 8px;
  background: #ffffff;
}

.brand strong,
.brand span,
.sync-box strong,
.sync-box span {
  display: block;
}

.brand strong {
  font-size: 1rem;
}

.brand span,
.sync-box span {
  color: #b8c7c0;
  font-size: 0.82rem;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #e8efeb;
  background: transparent;
  text-align: left;
}

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

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #bff4ea;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
}

.sync-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.sync-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
}

.sync-dot.online {
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.18);
}

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

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

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

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

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

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

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  box-shadow: 0 4px 18px rgba(20, 29, 24, 0.06);
}

.icon-button:hover {
  border-color: #9fb2ab;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 220px 180px;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fbfdfc;
  color: var(--text);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

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

.metric {
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--violet);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 2rem;
  line-height: 1;
}

.metric.accent-teal {
  border-left-color: var(--teal);
}

.metric.accent-amber {
  border-left-color: var(--amber);
}

.metric.accent-rose {
  border-left-color: var(--rose);
}

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

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

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.section-heading span {
  color: var(--muted);
  font-size: 0.82rem;
}

.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: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbfa;
  color: #4f5d57;
  font-size: 0.78rem;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #eef8f6;
}

.rfc {
  font-weight: 800;
  white-space: nowrap;
}

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

.status,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.status.activo,
.tag.ok {
  color: #065f46;
  background: var(--teal-soft);
}

.status.riesgo,
.tag.warn {
  color: #854d0e;
  background: var(--amber-soft);
}

.status.pendiente,
.tag.bad {
  color: #9f1239;
  background: var(--rose-soft);
}

.detail-panel {
  position: sticky;
  top: 18px;
  overflow: hidden;
}

#detailBody {
  padding: 16px;
}

.detail-title {
  margin-bottom: 14px;
}

.detail-title strong {
  display: block;
  font-size: 1.15rem;
  line-height: 1.2;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.detail-row dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-row dd {
  margin: 0;
  min-width: 0;
}

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

.activity-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  font-size: 0.86rem;
}

.activity-item strong {
  font-size: 0.78rem;
}

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

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

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

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

  .nav-item {
    justify-content: center;
  }

  .sync-box {
    display: none;
  }

  .main-panel {
    padding: 18px;
  }

  .toolbar,
  .content-grid {
    grid-template-columns: 1fr;
  }

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

  .detail-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .brand {
    justify-content: center;
  }

  .brand div,
  .nav-item span:last-child {
    display: none;
  }

  .topbar {
    align-items: flex-start;
  }

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

  .metric {
    min-height: 88px;
  }

  .activity-item {
    grid-template-columns: 1fr;
  }
}
