:root {
  --app-cm-green: #007a5e;
  --app-cm-red: #ce1126;
  --app-cm-yellow: #fcd116;
  --app-generation-border: rgba(20, 83, 45, 0.14);
  --app-generation-border-strong: rgba(20, 83, 45, 0.22);
  --app-generation-surface: rgba(255, 255, 255, 0.94);
  --app-generation-surface-soft: rgba(247, 251, 249, 0.96);
  --app-generation-shadow: 0 22px 48px rgba(2, 6, 23, 0.08);
}

.app-generation-card .card-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

#yearbook-generation-form .form-label {
  margin-bottom: 0.35rem;
}

#yearbook-generation-form .text-muted.small {
  line-height: 1.4;
}

.app-hero,
.app-generation-hero {
  border-radius: calc(var(--app-radius) - 4px);
  border: 1px solid var(--app-generation-border-strong);
  background:
    radial-gradient(680px circle at 8% 18%, rgba(0, 122, 94, 0.16), transparent 60%),
    radial-gradient(520px circle at 88% 14%, rgba(252, 209, 22, 0.14), transparent 58%),
    radial-gradient(520px circle at 84% 85%, rgba(206, 17, 38, 0.08), transparent 54%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 250, 247, 0.98));
  box-shadow: var(--app-generation-shadow);
  overflow: hidden;
}

.app-hero-body,
.app-generation-hero-body {
  padding: 1.15rem 1.15rem 1rem;
}

.app-generation-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.95fr);
  gap: 1rem;
  align-items: start;
}

.app-generation-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 122, 94, 0.16);
  background: rgba(0, 122, 94, 0.08);
  color: rgba(0, 122, 94, 0.95);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.85rem;
}

.app-generation-hero-text {
  display: grid;
  gap: 0.45rem;
}

.app-cm-emblem {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.12);
  border: 1px solid rgba(15, 23, 42, 0.08);
  flex: 0 0 auto;
}

.app-hero-title,
.app-generation-title {
  font-size: 1.25rem;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.app-generation-hint {
  margin-top: 1rem;
  padding: 0.85rem 0.95rem;
  border-radius: 18px;
  border: 1px solid rgba(20, 83, 45, 0.12);
  background: rgba(255, 255, 255, 0.68);
}

.app-generation-hero-aside {
  display: grid;
  gap: 0.85rem;
}

.app-generation-prereqs {
  display: grid;
  gap: 0.65rem;
}

.app-generation-prereq {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.8rem 0.9rem;
  border-radius: 18px;
  border: 1px solid rgba(20, 83, 45, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: var(--app-text-muted);
  font-size: 0.92rem;
}

.app-generation-prereq i {
  color: rgba(0, 122, 94, 0.95);
  font-size: 1rem;
  margin-top: 0.1rem;
}

.app-projects-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}

.app-kpi-pill {
  border-radius: 18px;
  border: 1px solid rgba(20, 83, 45, 0.12);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 26px rgba(2, 6, 23, 0.04);
}

.app-generation-steps-row {
  margin-top: 1rem;
}

.app-generation-step {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  height: 100%;
  padding: 0.85rem 0.95rem;
  border-radius: 18px;
  border: 1px solid rgba(20, 83, 45, 0.13);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 28px rgba(2, 6, 23, 0.05);
}

.app-generation-step-icon {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(0, 122, 94, 0.12);
  color: rgba(0, 122, 94, 0.95);
  flex: 0 0 auto;
}

.app-generation-step-icon .bi {
  font-size: 1.15rem;
}

.app-generation-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.95fr);
  gap: 1.25rem;
  align-items: start;
}

.app-generation-main {
  min-width: 0;
}

.app-generation-composer {
  display: grid;
  gap: 1rem;
}

.app-generation-section {
  display: grid;
  gap: 1rem;
  padding: 1.15rem;
  border-radius: 28px;
  border: 1px solid var(--app-generation-border);
  background: var(--app-generation-surface);
  box-shadow: 0 18px 38px rgba(2, 6, 23, 0.06);
}

.app-generation-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.app-generation-section-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
  color: rgba(0, 122, 94, 0.92);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-generation-section-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: #163226;
}

.app-generation-section-copy {
  margin: 0.35rem 0 0;
  max-width: 68ch;
  color: var(--app-text-muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.app-generation-template-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(240px, 0.92fr);
  gap: 1rem;
  align-items: start;
}

.app-dropzone,
.app-generation-dropzone {
  border-radius: 24px;
  border: 1px dashed rgba(20, 83, 45, 0.32);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 250, 247, 0.92)),
    rgba(255, 255, 255, 0.92);
  padding: 1rem 1rem 0.95rem;
}

.app-generation-icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(0, 122, 94, 0.12);
  color: rgba(0, 122, 94, 0.95);
  flex: 0 0 auto;
}

.app-generation-icon-badge .bi {
  font-size: 1.2rem;
}

.app-dropzone .form-control,
.app-generation-dropzone .form-control {
  border-radius: 14px;
  border-color: rgba(20, 83, 45, 0.18);
  background: rgba(255, 255, 255, 0.96);
}

.app-dropzone .form-control:focus,
.app-generation-dropzone .form-control:focus {
  border-color: rgba(0, 122, 94, 0.44);
  box-shadow: 0 0 0 0.25rem rgba(0, 122, 94, 0.12);
}

.app-filename-badge {
  max-width: min(100%, 280px);
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.app-generation-callout {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 24px;
  border: 1px solid rgba(20, 83, 45, 0.12);
  background: linear-gradient(180deg, rgba(248, 251, 249, 0.98), rgba(241, 247, 243, 0.98));
}

.app-generation-callout-title {
  font-weight: 700;
  color: #163226;
}

.app-generation-checklist {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.55rem;
  color: var(--app-text-muted);
  font-size: 0.92rem;
}

.app-generation-mode-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.app-generation-mode-card {
  display: grid;
  gap: 0.35rem;
  padding: 0.9rem 0.95rem;
  border-radius: 20px;
  border: 1px solid rgba(20, 83, 45, 0.12);
  background: var(--app-generation-surface-soft);
}

.app-generation-mode-label {
  font-weight: 700;
  color: #163226;
}

.app-generation-mode-text {
  font-size: 0.92rem;
  color: var(--app-text-muted);
  line-height: 1.45;
}

.app-generation-selection-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.45rem 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 122, 94, 0.16);
  background: rgba(0, 122, 94, 0.08);
  color: rgba(0, 122, 94, 0.95);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
}

.app-generation-selection-pill span:first-child {
  display: inline-grid;
  place-items: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: rgba(0, 122, 94, 0.95);
  box-shadow: inset 0 0 0 1px rgba(0, 122, 94, 0.08);
}

.app-project-picker {
  border-radius: 24px;
  border: 1px solid rgba(20, 83, 45, 0.14);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 14px 30px rgba(2, 6, 23, 0.04);
  padding: 1rem;
}

.app-generation-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.app-project-picker-search {
  flex: 1 1 280px;
  min-width: 240px;
}

.app-generation-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.app-generation-inline-note {
  margin-top: 0.8rem;
  padding: 0.75rem 0.9rem;
  border-radius: 16px;
  border: 1px solid rgba(20, 83, 45, 0.1);
  background: rgba(0, 122, 94, 0.05);
  color: var(--app-text-muted);
  font-size: 0.9rem;
}

#yearbook-projects-loading,
#yearbook-projects-empty {
  padding: 0.75rem 0.1rem 0.2rem;
}

.app-project-picker-list {
  margin-top: 0.85rem;
  border-radius: 18px;
  border: 1px solid rgba(20, 83, 45, 0.16);
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.98);
}

.app-project-picker-list .list-group-item {
  border-left: 0;
  border-right: 0;
  border-color: rgba(20, 83, 45, 0.12);
  padding: 0.9rem 1rem;
}

.app-project-picker-list .list-group-item:first-child {
  border-top: 0;
}

.app-project-picker-list .list-group-item:hover {
  background: rgba(0, 122, 94, 0.04);
}

.app-project-picker-row {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.app-project-picker-row .form-check-input {
  margin-top: 0.2rem;
}

.app-project-picker-meta {
  color: var(--app-text-muted);
  font-size: 0.875rem;
}

.app-generation-summary-note {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  border-radius: 20px;
  border: 1px solid rgba(20, 83, 45, 0.1);
  background: rgba(252, 209, 22, 0.08);
  color: #274a3a;
}

.app-generation-summary-note .bi {
  color: rgba(0, 122, 94, 0.95);
  margin-top: 0.1rem;
}

.app-generation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

#yearbook-generation-start-btn {
  flex: 1 1 260px;
  min-height: 48px;
  border-radius: 16px;
  font-weight: 700;
}

#generations-refresh-btn {
  min-height: 48px;
  border-radius: 16px;
}

.app-progress-card {
  border-radius: 24px;
  border: 1px solid rgba(20, 83, 45, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 251, 249, 0.98));
  padding: 1rem;
}

.app-generation-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.app-progress-bar {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(20, 83, 45, 0.12);
}

.app-progress-log {
  max-height: 190px;
  overflow: auto;
  font-size: 0.875rem;
  color: var(--app-text-muted);
  border-top: 1px solid rgba(20, 83, 45, 0.12);
  padding-top: 0.9rem;
}

.app-progress-log.mt-3 {
  margin-top: 0.85rem !important;
}

.app-progress-log .app-log-line {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.4rem 0;
}

.app-progress-log .app-log-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-top: 0.35rem;
  background: rgba(20, 83, 45, 0.55);
  flex: 0 0 auto;
}

.app-progress-log .app-log-dot.app-log-dot-danger {
  background: rgba(220, 38, 38, 0.65);
}

.app-progress-log .app-log-dot.app-log-dot-warning {
  background: rgba(245, 158, 11, 0.8);
}

.app-progress-log code {
  font-size: 0.85em;
}

.app-generation-history {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.app-generation-history-panel {
  display: grid;
  gap: 1rem;
  align-self: start;
  position: sticky;
  top: 1rem;
  padding: 1.15rem;
  border-radius: 28px;
  border: 1px solid var(--app-generation-border);
  background:
    radial-gradient(420px circle at 100% 0%, rgba(252, 209, 22, 0.12), transparent 52%),
    linear-gradient(180deg, rgba(250, 252, 251, 0.98), rgba(244, 249, 246, 0.98));
  box-shadow: 0 18px 38px rgba(2, 6, 23, 0.06);
}

.app-generation-history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}

.app-generation-history-toggle {
  border-radius: 999px;
  white-space: nowrap;
}

.app-generation-history-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
  padding: 0.9rem 1rem;
  border-radius: 20px;
  border: 1px solid rgba(20, 83, 45, 0.1);
  background: rgba(255, 255, 255, 0.76);
}

.app-generation-history-count {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 700;
  color: #163226;
}

.app-generation-history-count span:first-child {
  font-size: 1.5rem;
  line-height: 1;
  color: rgba(0, 122, 94, 0.95);
}

.app-generation-history-tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.app-generation-history .collapse.show,
.app-generation-history .collapsing {
  display: grid;
  gap: 1rem;
}

.app-list-state {
  padding: 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
}

.app-generation-history .table-responsive {
  border-radius: 20px;
  border: 1px solid rgba(20, 83, 45, 0.12);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 26px rgba(2, 6, 23, 0.05);
}

.app-generation-history .table thead th {
  white-space: nowrap;
}

.app-generation-history #generations-table-wrap {
  max-height: 52vh;
  overflow: auto;
}

.app-generation-history #generations-table-wrap .table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(3px);
}

.app-generation-history #generations-table-wrap th:nth-child(3),
.app-generation-history #generations-table-wrap td:nth-child(3) {
  width: 148px;
  white-space: nowrap;
}

.app-generation-history .table tbody td {
  font-size: 0.94rem;
}

.app-projects-table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.15rem 0.15rem 0;
}

@media (max-width: 1399.98px) {
  .app-generation-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-generation-history-panel {
    position: static;
  }
}

@media (max-width: 1199.98px) {
  .app-generation-hero-grid,
  .app-generation-template-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 991.98px) {
  .app-hero-body,
  .app-generation-hero-body {
    padding: 1rem;
  }

  .app-generation-section,
  .app-generation-history-panel {
    padding: 1rem;
    border-radius: 24px;
  }

  .app-generation-mode-summary {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-project-picker-list {
    max-height: 300px;
  }
}

@media (max-width: 767.98px) {
  .app-generation-card .card-body {
    gap: 1rem;
  }

  .app-cm-emblem {
    width: 56px;
    height: 56px;
  }

  .app-hero-title,
  .app-generation-title {
    font-size: 1.12rem;
  }

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

  .app-generation-section-header,
  .app-generation-history-header {
    flex-direction: column;
  }

  .app-generation-selection-pill,
  .app-generation-history-toggle {
    align-self: flex-start;
  }

  .app-generation-toolbar-actions,
  .app-generation-history-tools,
  .app-generation-actions {
    width: 100%;
  }

  .app-generation-toolbar-actions .btn,
  .app-generation-history-tools .input-group,
  .app-generation-actions .btn {
    width: 100%;
  }

  .app-project-picker-search,
  .app-input-max-320,
  .app-input-max-140 {
    min-width: 100%;
    width: 100%;
  }

  .app-generation-history #generations-table-wrap th:nth-child(3),
  .app-generation-history #generations-table-wrap td:nth-child(3) {
    width: 132px;
  }
}

@media (max-width: 575.98px) {
  .app-projects-kpis {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-generation-prereq,
  .app-generation-summary-note,
  .app-generation-history-summary {
    padding: 0.85rem 0.9rem;
  }
}

[data-theme="dark"] .app-generation-hero,
[data-theme="dark"] .app-generation-section,
[data-theme="dark"] .app-generation-history-panel,
[data-theme="dark"] .app-project-picker,
[data-theme="dark"] .app-progress-card,
[data-theme="dark"] .app-generation-callout,
[data-theme="dark"] .app-generation-mode-card,
[data-theme="dark"] .app-generation-summary-note,
[data-theme="dark"] .app-generation-history-summary,
[data-theme="dark"] .app-list-state,
[data-theme="dark"] .app-generation-prereq {
  box-shadow: none;
}
