:root {
  --bg: #f5efe5;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #fffdf8;
  --text: #1d232b;
  --muted: #5a6472;
  --accent: #0b6cf0;
  --accent-soft: #d8e8ff;
  --danger: #ba2d0b;
  --success: #0f7b48;
  --border: rgba(29, 35, 43, 0.12);
  --shadow: 0 18px 50px rgba(37, 45, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(11, 108, 240, 0.18), transparent 32%),
    radial-gradient(circle at right, rgba(15, 123, 72, 0.14), transparent 22%),
    linear-gradient(180deg, #fffaf2 0%, var(--bg) 100%);
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero {
  padding: 20px 0 24px;
}

.hero-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  gap: 20px;
}

.menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.menu-toggle {
  width: 56px;
  height: 56px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(29, 35, 43, 0.08);
  color: var(--text);
  box-shadow: 0 12px 30px rgba(29, 35, 43, 0.08);
  position: relative;
  overflow: hidden;
}

.menu-line {
  display: block;
  width: 24px;
  height: 2px;
  background: rgba(29, 35, 43, 0.88);
  border-radius: 999px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.menu-line:nth-of-type(2) {
  top: 18px;
}

.menu-line:nth-of-type(3) {
  top: 26px;
}

.menu-line:nth-of-type(4) {
  top: 34px;
}

.menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 160px;
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(29, 35, 43, 0.08);
  box-shadow: 0 20px 45px rgba(29, 35, 43, 0.12);
  z-index: 20;
}

.menu-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 700;
}

.menu-item:hover {
  background: rgba(11, 108, 240, 0.08);
}

.admin-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 10ch;
  font-size: clamp(2.5rem, 6vw, 4.8rem);
  line-height: 0.95;
}

.lede {
  max-width: 60ch;
  margin: 16px 0 0;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--muted);
}

.card {
  background: var(--surface);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card,
.partial-filter-card,
.input-focus-card,
#error-section,
#report-section {
  margin-top: 20px;
}

.auth-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 241, 232, 0.92)),
    var(--surface);
}

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

.auth-form {
  border: 1px solid rgba(29, 35, 43, 0.08);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.78);
}

.auth-reset-form {
  max-width: 560px;
  margin-top: 18px;
}

.auth-form-head {
  grid-column: 1 / -1;
}

.auth-form-head h3 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.auth-form-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  min-height: 4.5em;
}

.auth-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-info-button {
  width: 32px;
  height: 32px;
  min-height: unset;
  padding: 0;
  border-radius: 999px;
  background: rgba(47, 111, 214, 0.1);
  color: #2f6fd6;
  border: 1px solid rgba(47, 111, 214, 0.14);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-info-modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 25, 33, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}

.auth-info-dialog {
  width: min(100%, 420px);
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(29, 35, 43, 0.08);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(20, 25, 33, 0.18);
  padding: 20px;
}

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

.auth-info-head h3 {
  margin: 0;
  font-size: 1.1rem;
}

.auth-info-close {
  width: 32px;
  height: 32px;
  min-height: unset;
  padding: 0;
  border-radius: 999px;
  background: rgba(27, 39, 55, 0.08);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
}

.auth-emphasis {
  color: #2f6fd6;
  font-weight: 600;
}

.auth-link-button {
  padding: 0;
  justify-self: start;
}

.auth-actions-row {
  align-items: center;
  gap: 16px;
}

.input-focus-card {
  border-color: rgba(11, 108, 240, 0.18);
  background:
    linear-gradient(180deg, rgba(247, 251, 255, 0.96), rgba(237, 244, 252, 0.92)),
    var(--surface);
  box-shadow: 0 20px 60px rgba(11, 108, 240, 0.08);
}

.input-focus-card label {
  padding: 12px;
  border: 1px solid rgba(11, 108, 240, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 1rem;
  font-weight: 700;
}

.login-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 244, 238, 0.9)),
    var(--surface);
  border-color: rgba(29, 35, 43, 0.08);
}

.partial-filter-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 248, 255, 0.92)),
    var(--surface);
  border-color: rgba(11, 108, 240, 0.12);
}

.trend-card {
  margin-top: 20px;
  background:
    linear-gradient(180deg, rgba(251, 252, 255, 0.98), rgba(239, 243, 250, 0.94)),
    var(--surface);
  border-color: rgba(36, 84, 166, 0.14);
}

.admin-card {
  margin-top: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 249, 255, 0.94)),
    var(--surface);
  border-color: rgba(11, 108, 240, 0.12);
}

.login-head {
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(29, 35, 43, 0.08);
  margin-bottom: 22px;
}

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

.input-focus-card .section-head {
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(11, 108, 240, 0.12);
  margin-bottom: 22px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.4rem;
}

.section-copy {
  margin: 0;
  max-width: 42ch;
  color: var(--muted);
  line-height: 1.5;
}

.trend-head {
  align-items: center;
}

.trend-toggle {
  display: inline-flex;
  padding: 4px;
  border-radius: 18px;
  background: rgba(11, 108, 240, 0.08);
  gap: 4px;
}

.trend-toggle-button {
  padding: 10px 16px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.trend-toggle-button.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 8px 16px rgba(29, 35, 43, 0.08);
}

.trend-chart {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(36, 84, 166, 0.1);
}

.trend-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(36, 84, 166, 0.1);
  background: rgba(255, 255, 255, 0.7);
}

.trend-controls .actions {
  display: flex;
  align-items: end;
}

.checkbox-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
}

.checkbox-label input {
  width: 18px;
  height: 18px;
}

.admin-table-wrap {
  margin-top: 18px;
}

.admin-edit-button {
  padding: 8px 12px;
}

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  margin-bottom: 18px;
}

.trend-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.trend-legend-swatch {
  width: 28px;
  height: 0;
  border-top: 3px solid var(--swatch);
  border-radius: 999px;
  position: relative;
}

.trend-legend-swatch::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--swatch);
  position: absolute;
  right: -1px;
  top: -5px;
}

.trend-svg {
  width: 100%;
  height: auto;
  display: block;
}

.trend-grid-line {
  stroke: rgba(90, 100, 114, 0.22);
  stroke-dasharray: 5 5;
}

.trend-axis-line {
  stroke: rgba(29, 35, 43, 0.24);
  stroke-width: 1.4;
}

.trend-axis-label {
  fill: var(--muted);
  font-size: 13px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.trend-axis-title {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 700;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.error-head {
  align-items: center;
}

.error-card {
  border-color: rgba(186, 45, 11, 0.18);
  background: linear-gradient(180deg, rgba(255, 248, 246, 0.96), rgba(252, 238, 233, 0.9));
}

.error-message {
  margin: 0 0 10px;
  color: var(--danger);
  font-weight: 700;
}

.error-details {
  margin-top: 12px;
}

.error-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
}

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

label {
  display: grid;
  gap: 8px;
  font-size: 0.94rem;
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-strong);
  padding: 14px 16px;
  color: var(--text);
}

.input-focus-card input,
.input-focus-card select {
  border-color: rgba(11, 108, 240, 0.22);
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(11, 108, 240, 0.04);
  font-size: 1rem;
  font-weight: 600;
  padding: 13px 16px;
}

.input-focus-card input:focus,
.input-focus-card select:focus {
  outline: 3px solid rgba(11, 108, 240, 0.12);
  border-color: rgba(11, 108, 240, 0.42);
}

button {
  border: 0;
  border-radius: 18px;
  padding: 14px 18px;
  cursor: pointer;
  background: var(--text);
  color: white;
  font-weight: 700;
  transition: transform 140ms ease, opacity 140ms ease;
}

.secondary-button {
  background: #d6dbe3;
  color: var(--text);
}

#download-pdf.secondary-button {
  background: #d9e8ff;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button-loading {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.button-loading::after {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: rgba(255, 255, 255, 0.92);
  animation: status-spin 0.8s linear infinite;
}

.actions {
  align-self: end;
}

.actions-wide {
  grid-column: span 2;
  display: flex;
  justify-content: flex-start;
}

.project-picker {
  grid-column: 1 / -1;
}

.inline-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.partial-filter-layout {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 18px;
  align-items: start;
}

.filter-group {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(11, 108, 240, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
}

.partial-filter-layout > label {
  padding: 16px;
  border: 1px solid rgba(11, 108, 240, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.76);
}

.filter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  font-weight: 700;
}

.mini-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-action {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: none;
}

.mini-action:hover {
  transform: none;
  opacity: 0.8;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.epic-picker-group {
  grid-column: 1 / -1;
  gap: 14px;
}

.epic-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  max-height: 320px;
  overflow: auto;
  padding-right: 6px;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(29, 35, 43, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  font-size: 0.92rem;
  font-weight: 600;
}

.epic-options .filter-option {
  min-height: 56px;
}

.filter-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
}

.filter-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.export-actions {
  display: flex;
  gap: 12px;
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid rgba(29, 35, 43, 0.08);
}

.status {
  margin: 18px 0 0;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.status.error {
  color: var(--danger);
}

.status.loading::after {
  content: "";
  width: 15px;
  height: 15px;
  border-radius: 999px;
  border: 2px solid rgba(11, 108, 240, 0.18);
  border-top-color: var(--accent);
  animation: status-spin 0.8s linear infinite;
}

@keyframes status-spin {
  to {
    transform: rotate(360deg);
  }
}

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

.summary-card {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
}

.summary-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-card strong {
  font-size: 1.3rem;
  line-height: 1.2;
}

.slip-gain-group {
  grid-column: span 1;
  position: relative;
  background:
    radial-gradient(circle at top right, rgba(11, 108, 240, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(232, 239, 252, 0.98), rgba(219, 229, 246, 0.94));
  border-color: rgba(11, 108, 240, 0.18);
  box-shadow: 0 24px 60px rgba(11, 108, 240, 0.12);
}

.totals-group {
  grid-column: span 1;
  background: linear-gradient(180deg, rgba(255, 252, 246, 0.96), rgba(244, 238, 228, 0.9));
}

.project-group {
  grid-column: span 1;
  background: linear-gradient(180deg, rgba(246, 249, 255, 0.96), rgba(235, 241, 252, 0.9));
}

.performance-group {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, rgba(250, 248, 255, 0.96), rgba(239, 234, 248, 0.9));
}

.slip-gain-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.slip-gain-header p {
  margin: 0;
  color: #2454a6;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.slip-gain-header strong {
  font-size: 1.35rem;
}

.slip-gain-grid {
  display: grid;
  gap: 10px;
}

.slip-gain-item,
.metric-item {
  border-radius: 16px;
  padding: 14px;
  display: grid;
  gap: 4px;
  border: 1px solid transparent;
}

.slip-gain-item span,
.metric-item span {
  font-size: 0.85rem;
  color: var(--muted);
}

.slip-gain-item small {
  font-size: 0.82rem;
  font-weight: 700;
}

.metric-item.neutral {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(29, 35, 43, 0.08);
}

.performance-group .slip-gain-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: start;
}

.performance-group .metric-item {
  padding: 11px 12px;
  gap: 3px;
  min-height: 116px;
  align-content: start;
}

.performance-group .metric-item strong {
  font-size: 1.1rem;
  min-height: 2.4em;
  display: flex;
  align-items: center;
}

.metric-progress-track {
  width: 100%;
  height: 10px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(11, 108, 240, 0.12);
  overflow: hidden;
}

.metric-progress-fill {
  height: 100%;
  border-radius: inherit;
}

.slip-gain-item.positive {
  background: rgba(15, 123, 72, 0.12);
  border-color: rgba(15, 123, 72, 0.2);
}

.slip-gain-item.negative {
  background: rgba(186, 45, 11, 0.12);
  border-color: rgba(186, 45, 11, 0.2);
}

.slip-gain-group .slip-gain-item strong {
  font-size: 1.8rem;
  line-height: 1;
}

.slip-gain-group .slip-gain-item small {
  font-size: 0.88rem;
  opacity: 0.8;
}

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

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.debug-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.debug-output {
  margin: 16px 0 0;
  padding: 16px;
  overflow: auto;
  border-radius: 16px;
  background: #1d232b;
  color: #f3f6fb;
  font-size: 0.85rem;
  line-height: 1.5;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.table-empty-cell {
  color: var(--muted);
  font-style: italic;
}

th {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

td:nth-child(2) {
  min-width: 280px;
  white-space: normal;
}

.positive {
  color: var(--success);
  font-weight: 700;
}

.negative {
  color: var(--danger);
  font-weight: 700;
}

.progress-track {
  width: 180px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
}

.hidden {
  display: none;
}

.route-hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .hero-topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
  }

  .auth-layout,
  .form-grid,
  .summary-grid,
  .partial-filter-layout {
    grid-template-columns: 1fr;
  }

  .trend-head {
    align-items: flex-start;
  }

  .trend-toggle {
    width: 100%;
    justify-content: stretch;
  }

  .trend-toggle-button {
    flex: 1 1 0;
  }

  .trend-controls {
    grid-template-columns: 1fr;
  }

  .epic-options {
    grid-template-columns: 1fr;
  }

  .page {
    width: min(100vw - 20px, 1180px);
    padding-top: 24px;
  }

  .card {
    padding: 18px;
  }

  h1 {
    max-width: none;
  }

  .auth-form {
    padding: 16px;
  }

  .auth-form-head h3 {
    margin-bottom: 0;
  }

  .auth-form-head p {
    display: none;
  }

  #auth-copy {
    font-size: 0.92rem;
    line-height: 1.45;
  }

  .auth-card .auth-form,
  .auth-card .auth-reset-form {
    grid-template-columns: 1fr;
  }

  .auth-card .auth-form-head,
  .auth-card .actions-wide {
    grid-column: auto;
  }

  .auth-card label {
    justify-items: start;
    text-align: left;
  }

  .auth-actions-row {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}
