/* Shared shell for secondary dashboard pages */
:root {
  --shell-max: 1480px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(180deg, #fcfaf7 0%, var(--bg, #f7f3ec) 100%);
  color: var(--text, #27231d);
  font-family: "Segoe UI Variable Text", Aptos, "Segoe UI", system-ui, -apple-system, sans-serif;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(33, 91, 144, 0.42);
  outline-offset: 2px;
}

.topbar,
.top-bar {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 40;
  background: rgba(255, 254, 251, 0.98);
  border-bottom: 1px solid rgba(226, 220, 209, 0.96);
  backdrop-filter: none;
}

.topbar-inner,
.top-bar {
  width: min(var(--shell-max), calc(100% - 28px));
  margin: 0 auto;
}

.topbar-inner,
.top-bar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand,
.left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: #f3d867;
  color: #162235;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  flex: 0 0 auto;
  overflow: hidden;
}

img.brand-mark {
  display: block;
  object-fit: cover;
  overflow: hidden;
  background: transparent;
  padding: 0;
}

.brand-text {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}

.brand-title {
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.76rem;
  color: var(--text-dim, #6a6258);
}

.title {
  font-weight: 800;
  font-size: 1rem;
}

.actions,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-btn,
.ghost-btn,
.primary-btn,
.utility-btn,
.refresh-btn,
.shell-button {
  min-height: 38px;
  padding: 0.55rem 0.92rem;
  border-radius: 11px;
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #fbf8f2;
  color: var(--text, #27231d);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.nav-btn:hover,
.ghost-btn:hover,
.utility-btn:hover,
.refresh-btn:hover,
.shell-button:hover {
  background: #f3eee5;
}

.nav-btn.active,
.nav-btn[aria-current="page"] {
  background: #f0e7d8;
  border-color: #decfab;
  color: #51410b;
}

.utility-btn {
  background: #f5edd2;
  border-color: #e2d2a0;
  color: #51410b;
}

.primary-btn,
.refresh-btn {
  background: #f3e7c1;
  border-color: #dfcf9d;
  color: #2b241d;
}

.primary-btn:hover,
.refresh-btn:hover {
  background: #eadcb1;
  border-color: #d8c58d;
}

.ghost-btn {
  background: #fffdfa;
}

.page {
  width: min(var(--shell-max), calc(100% - 28px));
  margin: 1.25rem auto 2rem;
  display: grid;
  gap: 1rem;
}

.hero,
.panel,
.section,
.card,
.surface-panel {
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #fffefb;
  box-shadow: none;
}

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 1.55rem 1.7rem;
  color: var(--text, #27231d);
  background: #fffefb;
}

.hero::before {
  display: none;
}

.hero::after {
  display: none;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.hero,
.panel,
.section,
.surface-panel {
  border-radius: 24px;
}

.hero h1,
.hero h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 2.1rem);
  line-height: 1.08;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.hero p,
.subtext {
  margin: 0.45rem 0 0;
  max-width: 720px;
  color: var(--text-dim, #6a6258);
  font-size: 0.9rem;
}

.hero-meta,
.hero-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.hero-meta {
  align-items: flex-end;
  justify-content: flex-end;
}

.pill,
.source-pill,
.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 36px;
  padding: 0.48rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #f7f3eb;
  color: var(--text, #27231d);
  font-size: 0.76rem;
  font-weight: 700;
}

.pill.light,
.source-pill {
  background: #f7f3eb;
  border-color: rgba(226, 220, 209, 0.96);
  color: var(--text, #27231d);
  backdrop-filter: none;
}

.panel,
.section,
.surface-panel {
  position: relative;
  overflow: hidden;
  padding: 1rem;
}

.panel-head,
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.95rem;
}

.panel-head h2,
.section-head h2 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.08;
  letter-spacing: -0.02em;
}

.panel-note,
.section-note {
  max-width: 420px;
  color: var(--text-dim, #6a6258);
  font-size: 0.82rem;
  text-align: right;
}

.eyebrow,
.panel-eyebrow {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-dim, #6a6258);
  margin-bottom: 0.28rem;
}

.panel .loading,
.panel .no-data,
.loading,
.no-data {
  text-align: center;
  padding: 2.4rem 1rem;
  color: var(--text-dim, #6a6258);
}

.stat-card,
.card,
.field,
.toggle,
.modal-card,
.candidate-item {
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #fdfbf7;
}

.summary-grid,
.kpi-row,
.grid {
  display: grid;
  gap: 0.75rem;
}

.stat-card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  padding: 0.85rem 0.95rem;
}

.stat-label {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim, #6a6258);
  font-weight: 800;
}

.stat-value {
  margin-top: 0.2rem;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.stat-card .accent { color: #a17f11; }

.table-wrap,
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid rgba(226, 220, 209, 0.96);
  border-radius: 18px;
  background: #fffefb;
}

.action-btn {
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #fbf8f2;
  color: var(--text, #27231d);
  padding: 0.42rem 0.72rem;
  border-radius: 10px;
  font: inherit;
  font-size: 0.73rem;
  font-weight: 700;
  cursor: pointer;
}

.action-btn:hover {
  background: #f3eee5;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
}

.badge-dim {
  background: #f7f3eb;
  color: var(--text-dim, #6a6258);
}

.link {
  color: #2563eb;
  font-weight: 700;
}

.link:hover {
  text-decoration: underline;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 24, 18, 0.18);
  backdrop-filter: none;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem 1rem;
  overflow-y: auto;
  z-index: 60;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  width: min(980px, 100%);
  max-height: min(88vh, 960px);
  overflow: auto;
  background: #fffefb;
  border: 1px solid rgba(226, 220, 209, 0.98);
  border-radius: 22px;
  padding: 1.15rem;
  box-shadow: 0 12px 30px rgba(36, 33, 28, 0.08);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  margin-bottom: 0.3rem;
  background: rgba(255, 254, 251, 0.98);
}

.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
}

.modal-close {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(226, 220, 209, 0.96);
  background: #fbf8f2;
  color: var(--text-dim, #6a6258);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.modal-close:hover {
  background: #f3eee5;
  color: var(--text, #27231d);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.modal-card {
  border-radius: 16px;
  padding: 0.9rem;
}

.field {
  display: grid;
  gap: 0.12rem;
  margin-bottom: 0.55rem;
  border-radius: 14px;
  padding: 0.78rem 0.86rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field-label {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim, #6a6258);
  font-weight: 800;
}

.field-value {
  font-size: 0.82rem;
  color: var(--text, #27231d);
}

.candidate-list {
  display: grid;
  gap: 0.55rem;
}

.candidate-item {
  border-radius: 14px;
  padding: 0.8rem;
}

.reason-list {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

@media (max-width: 920px) {
  .topbar-inner,
  .top-bar {
    min-height: auto;
    padding: 0.8rem 0;
    flex-direction: column;
    align-items: stretch;
  }

  .actions,
  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .nav-btn,
  .ghost-btn,
  .primary-btn,
  .utility-btn,
  .refresh-btn {
    flex: 1 1 0;
  }

  .page {
    width: min(var(--shell-max), calc(100% - 20px));
    margin-top: 1rem;
  }

  .hero,
  .panel,
  .section,
  .surface-panel {
    border-radius: 22px;
  }

  .panel-head,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-note,
  .section-note {
    text-align: left;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }
}
