:root {
  color-scheme: dark;
  --bg-page: #040510;
  --bg-radial-1: #5884ff38;
  --bg-radial-2: #30c4ff29;
  --bg-radial-3: #3c78eb24;
  --panel-surface: rgba(12, 16, 36, 0.86);
  --panel-border: rgba(129, 140, 248, 0.22);
  --panel-shadow: 0 24px 46px rgba(5, 9, 24, 0.45);
  --card-surface: rgba(16, 22, 50, 0.86);
  --card-border: rgba(129, 140, 248, 0.16);
  --card-shadow: 0 28px 54px rgba(5, 9, 24, 0.6);
  --card-highlight: rgba(99, 102, 241, 0.25);
  --neutral-surface: rgba(255, 255, 255, 0.1);
  --text-primary: #e8ebff;
  --text-secondary: rgba(232, 235, 255, 0.72);
  --text-muted: rgba(232, 235, 255, 0.55);
  --accent-primary: #1ea4bf;
  --accent-secondary: #32c1d6;
  --accent-weekday: #2f84e8;
  --accent-weekend: #f28c38;
  --accent-threshold: #f04563;
  --card-gradient: var(--surface-gradient-primary);
  --summary-pill-bg: rgba(30, 164, 191, 0.12);
  --summary-pill-border: rgba(30, 164, 191, 0.3);
  --summary-pill-text: #40d5f3;
  --threshold-pill-bg: rgba(240, 69, 99, 0.15);
  --threshold-pill-text: #ff899c;
  --hero-gradient: linear-gradient(135deg, rgba(99, 102, 241, 0.38), rgba(34, 211, 238, 0.2));
  --section-gradient: linear-gradient(135deg, rgba(20, 26, 54, 0.75), rgba(13, 18, 42, 0.82));
  --table-border: rgba(232, 235, 255, 0.08);
  --threshold-badge-bg: rgba(30, 164, 191, 0.18);
  --threshold-badge-text: #7be9ff;
  --transition: 200ms ease;
  --layout-width: 1120px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text-secondary);
  background:
    radial-gradient(circle at 18% 20%, var(--bg-radial-1), transparent 58%),
    radial-gradient(circle at 82% 18%, var(--bg-radial-2), transparent 55%),
    radial-gradient(circle at 70% 84%, var(--bg-radial-3), transparent 60%),
    var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.nh4-page {
  max-width: var(--layout-width);
  margin: 0 auto;
  padding: 3.2rem 1.6rem 4.2rem;
  display: flex;
  flex-direction: column;
  gap: 2.6rem;
}

.card {
  padding: clamp(1.9rem, 3vw, 2.6rem);
  border-radius: 24px;
  background: var(--card-gradient);
  border: 1px solid rgba(129, 140, 248, 0.22);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: clamp(1.4rem, 2vw, 1.8rem);
}

.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.1rem;
}

.card__header h2 {
  margin: 0;
  font-size: clamp(1.5rem, 1.3vw + 0.9rem, 1.9rem);
  color: var(--text-primary);
}

.card__header p {
  margin: 0.2rem 0 0;
  color: var(--text-secondary);
}

.summary-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  padding: 0.75rem 0.9rem;
  border-radius: 18px;
  background: rgba(30, 164, 191, 0.08);
  border: 1px solid rgba(30, 164, 191, 0.22);
}

.nh4-summary {
  gap: clamp(1.2rem, 1.8vw, 1.6rem);
}

.nh4-summary .summary-meta {
  margin: -0.2rem 0 0;
}

.summary-stat {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.summary-label {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.summary-value {
  font-size: 1.45rem;
  font-weight: 600;
  color: #6feeff;
  text-shadow: 0 0 14px rgba(111, 238, 255, 0.55);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: clamp(1rem, 1.8vw, 1.5rem);
}

.summary-card {
  padding: 1.1rem 1.4rem;
  border-radius: 18px;
  background: rgba(16, 20, 46, 0.82);
  border: 1px solid rgba(129, 140, 248, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.summary-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
  color: var(--text-primary);
}

.summary-card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.94rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(1.2rem, 2.2vw, 1.8rem);
}

.control-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.4rem 1.6rem;
  border-radius: 20px;
  background: rgba(12, 16, 36, 0.82);
  border: 1px solid rgba(129, 140, 248, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.control-block h3 {
  margin: 0;
  font-size: 1.07rem;
  color: var(--text-primary);
}

.file-input {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 56px;
  border-radius: 16px;
  border: 2px dashed rgba(30, 164, 191, 0.32);
  background: rgba(30, 164, 191, 0.08);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.file-input input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.file-input:hover {
  border-color: rgba(30, 164, 191, 0.6);
  background: rgba(30, 164, 191, 0.14);
}

.file-label {
  font-weight: 600;
  color: var(--accent-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid rgba(30, 164, 191, 0.28);
  background: rgba(30, 164, 191, 0.18);
  color: var(--accent-primary);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition);
}

.btn:hover,
.btn:focus-visible {
  outline: none;
  transform: translateY(-1px);
  background: rgba(30, 164, 191, 0.28);
  border-color: rgba(30, 164, 191, 0.4);
  box-shadow: 0 14px 26px rgba(30, 164, 191, 0.24);
}

.btn--ghost {
  background: rgba(30, 164, 191, 0.14);
}

.btn--sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
}

.btn:disabled,
.btn:disabled:hover,
.btn:disabled:focus-visible {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
  box-shadow: none;
  background: rgba(30, 164, 191, 0.12);
  border-color: rgba(30, 164, 191, 0.18);
}

.load-status {
  min-height: 1.1rem;
  font-size: 0.85rem;
  color: var(--accent-primary);
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.control-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.control-field label {
  font-weight: 600;
  color: var(--text-primary);
}

.control-field select,
.control-field input[type="number"] {
  border-radius: 14px;
  border: 1px solid rgba(129, 140, 248, 0.28);
  background: rgba(9, 14, 36, 0.86);
  color: var(--text-primary);
  padding: 0.65rem 0.9rem;
  font-size: 0.95rem;
}

.control-field select:focus,
.control-field input[type="number"]:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18);
}

.date-range {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.date-range__inputs {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.date-range__inputs input {
  border-radius: 12px;
  border: 1px solid rgba(129, 140, 248, 0.28);
  background: rgba(9, 14, 36, 0.86);
  color: var(--text-primary);
  padding: 0.55rem 0.75rem;
  font-size: 0.92rem;
}

.date-range__inputs input:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.18);
}

.date-range__separator {
  color: var(--text-muted);
  font-weight: 600;
}

.threshold-inputs {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.threshold-highlight {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.threshold-highlight__item {
  padding: 0.75rem 1rem;
  border-radius: 14px;
  background: rgba(10, 18, 42, 0.74);
  border: 1px solid rgba(129, 140, 248, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.threshold-highlight__label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.threshold-highlight__value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-primary);
}

#thresholdSlider {
  flex: 1;
  accent-color: var(--accent-primary);
}

#thresholdNumber {
  width: 80px;
}

.threshold-detail {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
}

.chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(1.1rem, 1.6vw, 1.6rem);
}

.chart-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1.2rem 1.4rem 1.4rem;
  border-radius: 20px;
  background: rgba(12, 16, 36, 0.86);
  border: 1px solid rgba(129, 140, 248, 0.22);
  box-shadow: var(--panel-shadow);
  min-height: 380px;
}

.chart-header h3 {
  margin: 0;
  font-size: 1.02rem;
  color: var(--text-primary);
}

.chart-header p {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.chart-tooltip {
  position: absolute;
  top: 1.4rem;
  right: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 200px;
  padding: 0.75rem 0.95rem;
  border-radius: 14px;
  background: rgba(18, 30, 56, 0.92);
  box-shadow: 0 18px 32px rgba(4, 12, 24, 0.45);
  pointer-events: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 2;
}

.chart-tooltip--hidden {
  opacity: 0;
  transform: translateY(-6px);
  visibility: hidden;
}

.chart-tooltip__title {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

.chart-tooltip__body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.chart-tooltip__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.55rem;
  align-items: center;
}

.chart-tooltip__bullet {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
}

.chart-tooltip__label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.chart-tooltip__value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-panel canvas {
  width: 100% !important;
  max-height: 360px;
  border-radius: 14px;
}

.chart-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.chip {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  background: var(--threshold-badge-bg);
  color: var(--threshold-badge-text);
}

.hours-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: clamp(1.1rem, 2.2vw, 1.8rem);
  align-items: start;
}

.hours-table {
  overflow-x: auto;
  border-radius: 18px;
  background: rgba(12, 16, 36, 0.86);
  border: 1px solid rgba(129, 140, 248, 0.22);
  box-shadow: var(--panel-shadow);
}

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

th,
td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--table-border);
  text-align: left;
  font-size: 0.92rem;
}

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

.hours-placeholder,
.preview-placeholder {
  text-align: center;
  color: var(--text-muted);
}

.hours-notes {
  padding: 1.2rem 1.4rem;
  border-radius: 18px;
  background: rgba(12, 16, 36, 0.82);
  border: 1px solid rgba(129, 140, 248, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.hours-notes h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  color: var(--text-primary);
}

.hours-notes ul {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.45rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.preview-table-wrapper {
  overflow-x: auto;
  border-radius: 18px;
  background: rgba(12, 16, 36, 0.86);
  border: 1px solid rgba(129, 140, 248, 0.22);
  box-shadow: var(--panel-shadow);
}

.page-footer {
  margin-top: 2.4rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.page-footer p {
  margin: 0.2rem 0;
}

@media (max-width: 768px) {
  .nh4-page {
    padding: 2.6rem 1.25rem 3.4rem;
  }

  .threshold-inputs {
    flex-direction: column;
    align-items: stretch;
  }

  #thresholdNumber {
    width: 100%;
  }

  table {
    min-width: 360px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
