:root {
  color-scheme: light;
  --page-start: #d8eaff;
  --page-mid: #eef6ff;
  --page-end: #c4ddfb;
  --shell: rgba(248, 252, 255, 0.82);
  --card: rgba(255, 255, 255, 0.88);
  --card-strong: #ffffff;
  --text: #18304d;
  --muted: #5c7592;
  --border: rgba(55, 100, 150, 0.18);
  --accent: #2769c8;
  --accent-soft: #dcecff;
  --purple: #7c3aed;
  --purple-soft: #f0e8ff;
  --green: #14845f;
  --green-soft: #def7ec;
  --amber: #b56308;
  --amber-soft: #fff0d5;
  --hidden: #9b5a13;
  --hidden-soft: #fff3dc;
  --shadow: rgba(49, 93, 143, 0.16);
}

body[data-theme="daylight"] {
  --page-start: #f4f7fb;
  --page-mid: #ffffff;
  --page-end: #e9eff6;
  --shell: rgba(255, 255, 255, 0.95);
  --card: #ffffff;
  --card-strong: #ffffff;
  --text: #223248;
  --muted: #66758a;
  --border: #dbe3ed;
  --accent: #316fc2;
  --accent-soft: #e8f1fc;
  --purple: #7137c8;
  --purple-soft: #f3edff;
  --green: #08775a;
  --green-soft: #e0f5ed;
  --amber: #a85b08;
  --amber-soft: #fff2dc;
  --hidden: #95550c;
  --hidden-soft: #fff4df;
  --shadow: rgba(39, 57, 78, 0.12);
}

body[data-theme="slate"] {
  color-scheme: dark;
  --page-start: #253c55;
  --page-mid: #172b40;
  --page-end: #304d68;
  --shell: rgba(22, 42, 61, 0.88);
  --card: rgba(37, 65, 89, 0.92);
  --card-strong: #294862;
  --text: #edf6ff;
  --muted: #b7cee2;
  --border: rgba(218, 237, 255, 0.17);
  --accent: #74b6ff;
  --accent-soft: rgba(70, 139, 212, 0.25);
  --purple: #c4a1ff;
  --purple-soft: rgba(123, 72, 184, 0.34);
  --green: #6de0b5;
  --green-soft: rgba(31, 135, 102, 0.3);
  --amber: #ffc56d;
  --amber-soft: rgba(169, 101, 22, 0.32);
  --hidden: #ffd08a;
  --hidden-soft: rgba(166, 101, 25, 0.32);
  --shadow: rgba(0, 0, 0, 0.22);
  --nested-card: rgba(62, 96, 124, 0.96);
}

body[data-theme="symphony"] {
  color-scheme: light;
  --page-start: #13091f;
  --page-mid: #241032;
  --page-end: #10243b;
  --shell: rgba(246, 243, 249, 0.96);
  --card: rgba(255, 255, 255, 0.7);
  --card-strong: #fbf9fc;
  --nested-surface: rgba(235, 231, 240, 0.86);
  --nested-surface-strong: rgba(229, 224, 235, 0.92);
  --text: #2b153d;
  --muted: #756a7e;
  --border: rgba(55, 33, 70, 0.13);
  --accent: #176fc1;
  --accent-soft: rgba(23, 111, 193, 0.09);
  --purple: #7d2dc4;
  --purple-soft: rgba(125, 45, 196, 0.09);
  --green: #087e91;
  --green-soft: rgba(8, 126, 145, 0.09);
  --amber: #bd6500;
  --amber-soft: rgba(189, 101, 0, 0.1);
  --hidden: #a33b78;
  --hidden-soft: rgba(163, 59, 120, 0.09);
  --shadow: rgba(4, 0, 12, 0.28);
  --logo-purple: #a52cff;
  --logo-blue: #0879e1;
  --logo-cyan: #19a9f5;
  --logo-gold: #ffb400;
  --logo-orange: #ff8400;
  --logo-pink: #f51aa2;
  --section-accent: var(--logo-purple);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: linear-gradient(135deg, var(--page-start), var(--page-mid) 48%, var(--page-end));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

body[data-theme="symphony"] {
  background:
    radial-gradient(circle at 8% 4%, rgba(133, 43, 201, 0.28), transparent 30rem),
    radial-gradient(circle at 92% 8%, rgba(8, 121, 225, 0.17), transparent 27rem),
    radial-gradient(circle at 82% 96%, rgba(245, 26, 162, 0.09), transparent 30rem),
    linear-gradient(135deg, var(--page-start), var(--page-mid) 48%, var(--page-end));
  background-attachment: fixed;
}

.text-muted { color: var(--muted) !important; }
.text-emphasis {
  color: var(--text);
  font-weight: 800;
}

.data-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.32rem 0.58rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.15;
  text-align: left;
  white-space: normal;
}

.stage-badge {
  justify-content: flex-start;
  text-align: left;
  color: var(--accent);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
}

.assessment-badge {
  color: var(--purple);
  background: var(--purple-soft);
  border-color: color-mix(in srgb, var(--purple) 28%, transparent);
}

.activity-status-badge {
  white-space: nowrap;
}

.activity-status-edit-trigger {
  cursor: pointer;
  font: inherit;
}

.activity-status-edit-trigger:hover,
.activity-status-edit-trigger:focus-visible {
  filter: brightness(1.12);
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.activity-status-progressing {
  color: #38c987;
  background: color-mix(in srgb, #38c987 14%, transparent);
  border-color: color-mix(in srgb, #38c987 48%, transparent);
}

.activity-status-pending {
  color: #f4b942;
  background: color-mix(in srgb, #f4b942 14%, transparent);
  border-color: color-mix(in srgb, #f4b942 48%, transparent);
}

.activity-status-stalled {
  color: #f06b72;
  background: color-mix(in srgb, #f06b72 14%, transparent);
  border-color: color-mix(in srgb, #f06b72 48%, transparent);
}

.activity-status-closed-won {
  color: #147a52;
  background: color-mix(in srgb, #38c987 18%, transparent);
  border-color: color-mix(in srgb, #38c987 52%, transparent);
}

.activity-status-not-assessed {
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 10%, transparent);
  border-color: color-mix(in srgb, var(--muted) 28%, transparent);
}

.data-badge-empty {
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 8%, transparent);
  border-color: color-mix(in srgb, var(--muted) 18%, transparent);
}

.app-header,
.app-shell {
  background: var(--shell);
  border: 1px solid var(--border);
  box-shadow: 0 18px 46px var(--shadow);
  backdrop-filter: blur(20px);
}

.app-header {
  border-radius: 20px;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-shell { border-radius: 24px; }

.aurora-shell,
.unified-app-workspace {
  color: var(--text);
  background: var(--shell);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 20px 50px var(--shadow);
  backdrop-filter: blur(24px);
}

.unified-dashboard-header {
  align-items: flex-start;
}

.unified-app-workspace > .app-shell {
  padding: 0 !important;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

body[data-theme="symphony"] .app-header,
body[data-theme="symphony"] .app-shell,
body[data-theme="symphony"] .aurora-shell {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 24px 70px rgba(2, 0, 8, 0.38);
}

body[data-theme="symphony"] .app-header {
  position: relative;
  overflow: hidden;
}

body[data-theme="symphony"] .app-header::before {
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  content: "";
  background: linear-gradient(90deg, #a52cff, #0879e1 48%, #f51aa2);
}

body[data-theme="symphony"] .aurora-shell {
  border-top-width: 1px;
}

body[data-theme="symphony"] .unified-app-workspace > .app-shell {
  border: 0;
  box-shadow: none;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  text-decoration: none;
}

.brand-lockup picture { display: block; }

.brand-logo {
  width: min(285px, 60vw);
  height: auto;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.brand-logo-white,
.brand-logo-colour { display: none; }
body[data-theme="slate"] .brand-logo-black { display: none; }
body[data-theme="slate"] .brand-logo-white { display: block; }
body[data-theme="symphony"] .brand-logo-black,
body[data-theme="symphony"] .brand-logo-white { display: none; }
body[data-theme="symphony"] .brand-logo-colour { display: block; }

.brand-name,
.brand-subtitle { display: block; }
.brand-name { font-weight: 750; line-height: 1.1; }
.brand-subtitle { color: var(--muted); font-size: 0.75rem; }

@media (max-width: 575.98px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-logo { width: min(250px, 75vw); }
}

.app-card,
.aurora-card {
  display: block;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 10px 28px var(--shadow);
}

body[data-theme="slate"] .app-card .app-card,
body[data-theme="slate"] .app-card .aurora-card,
body[data-theme="slate"] .aurora-card .aurora-card,
body[data-theme="slate"] .app-shell .app-card {
  background: var(--nested-card);
  border-color: rgba(226, 241, 255, 0.24);
}

body[data-theme="symphony"] .app-card,
body[data-theme="symphony"] .aurora-card {
  position: relative;
  box-shadow: 0 8px 24px rgba(34, 16, 48, 0.07);
}

body[data-theme="symphony"] .app-card:not(:has(.app-card, .aurora-card))::before,
body[data-theme="symphony"] .aurora-card:not(:has(.app-card, .aurora-card))::before {
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 0;
  width: 3px;
  content: "";
  background: var(--section-accent);
  pointer-events: none;
}

body[data-theme="symphony"] .app-card .app-card,
body[data-theme="symphony"] .app-card .aurora-card,
body[data-theme="symphony"] .aurora-card .app-card,
body[data-theme="symphony"] .aurora-card .aurora-card {
  background: var(--nested-surface);
  border-color: var(--border);
  box-shadow: none;
}

body[data-theme="symphony"] .app-card .app-card:not(:has(.app-card, .aurora-card))::before,
body[data-theme="symphony"] .app-card .aurora-card:not(:has(.app-card, .aurora-card))::before,
body[data-theme="symphony"] .aurora-card .app-card:not(:has(.app-card, .aurora-card))::before,
body[data-theme="symphony"] .aurora-card .aurora-card:not(:has(.app-card, .aurora-card))::before {
  top: 14px;
  bottom: 14px;
  width: 2px;
}

body[data-theme="symphony"] .row > :nth-child(6n + 1) > .admin-section-card { --section-accent: var(--logo-purple); }
body[data-theme="symphony"] .row > :nth-child(6n + 2) > .admin-section-card { --section-accent: var(--logo-blue); }
body[data-theme="symphony"] .row > :nth-child(6n + 3) > .admin-section-card { --section-accent: var(--logo-cyan); }
body[data-theme="symphony"] .row > :nth-child(6n + 4) > .admin-section-card { --section-accent: var(--logo-gold); }
body[data-theme="symphony"] .row > :nth-child(6n + 5) > .admin-section-card { --section-accent: var(--logo-orange); }
body[data-theme="symphony"] .row > :nth-child(6n) > .admin-section-card { --section-accent: var(--logo-pink); }

.btn-primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover,
.btn-primary:focus {
  color: #fff;
  background: color-mix(in srgb, var(--accent) 82%, #000);
  border-color: color-mix(in srgb, var(--accent) 82%, #000);
}

body[data-theme="symphony"] .btn-primary {
  background: #39204d;
  border-color: #39204d;
  box-shadow: none;
}

body[data-theme="symphony"] .btn-primary:hover,
body[data-theme="symphony"] .btn-primary:focus {
  background: #241231;
  border-color: #241231;
}

body[data-theme="symphony"] .btn-soft,
body[data-theme="symphony"] .btn-outline-light {
  background: rgba(255, 255, 255, 0.34);
}

.btn-soft,
.btn-outline-light {
  color: var(--text);
  background: var(--card);
  border-color: var(--border);
}

.btn-soft:hover,
.btn-outline-light:hover {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.form-control,
.form-select {
  color: var(--text);
  background: var(--card-strong);
  border-color: var(--border);
}

.form-control:focus,
.form-select:focus {
  color: var(--text);
  background: var(--card-strong);
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem color-mix(in srgb, var(--accent) 20%, transparent);
}

.table,
.table > :not(caption) > * > * {
  --bs-table-color: var(--text);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border);
  color: var(--text);
  background: transparent;
}

.modal-content {
  color: var(--text);
  background: var(--card-strong);
  border: 1px solid var(--border);
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-nav a {
  padding: 0.55rem 0.9rem;
  color: var(--muted);
  border-radius: 10px;
  text-decoration: none;
}

.admin-nav a:hover,
.admin-nav a.active {
  color: var(--text);
  background: var(--accent-soft);
}

.admin-section-card { text-decoration: none; transition: transform 150ms ease; }
.admin-section-card:hover { transform: translateY(-2px); }
.admin-icon { display: block; color: var(--accent); font-size: 1.8rem; margin-bottom: 1rem; }
.section-title {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 800;
}

.theme-option {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
}

.theme-option:has(input:checked) { border-color: var(--accent); }
.theme-preview { height: 75px; border-radius: 12px; border: 1px solid var(--border); }
.theme-preview-aurora-light { background: linear-gradient(135deg, #d8eaff, #ffffff, #c4ddfb); }
.theme-preview-daylight { background: linear-gradient(135deg, #f4f7fb, #ffffff, #e9eff6); }
.theme-preview-slate { background: linear-gradient(135deg, #253c55, #172b40, #304d68); }
.theme-preview-symphony {
  background:
    linear-gradient(90deg, #a52cff, #0879e1 48%, #f51aa2) top / 100% 4px no-repeat,
    linear-gradient(135deg, #160b22 0 28%, #f4f1f6 28% 100%);
}

.table-responsive {
  border-radius: 12px;
  scrollbar-width: thin;
}

.responsive-data-table { min-width: 920px; }
.touch-action { min-width: 42px; min-height: 42px; }
.auth-shell { max-width: 520px; }
.snapshot-opportunity-cards { display: none; }
.snapshot-opportunity-card {
  border-left: 4px solid var(--accent);
}
.snapshot-opportunity-card.snapshot-hidden-row {
  background: var(--hidden-soft);
  border-left-color: var(--hidden);
}
.snapshot-opportunity-name {
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.snapshot-opportunity-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  padding: 0.8rem 0;
  margin: 0.8rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.snapshot-opportunity-facts > div { min-width: 0; }
.snapshot-opportunity-facts span:not(.snapshot-card-label) {
  display: block;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.snapshot-card-label {
  display: block;
  margin-bottom: 0.18rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.045em;
  text-transform: uppercase;
}
.snapshot-card-summary {
  line-height: 1.45;
  white-space: pre-line;
}

@media (max-width: 767.98px) {
  .container {
    max-width: 100%;
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
    padding-left: 0;
    padding-right: 0;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 0.8rem;
  }

  .unified-app-workspace {
    padding: 1rem !important;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .unified-dashboard-header {
    align-items: stretch;
  }

  .unified-dashboard-header .dashboard-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .unified-dashboard-header .dashboard-actions > span { grid-column: 1 / -1; }
  .unified-dashboard-header .dashboard-actions > a,
  .unified-dashboard-header .dashboard-actions > form,
  .unified-dashboard-header .dashboard-actions > form .btn { width: 100%; }

  .app-header nav,
  .app-nav {
    width: 100%;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-header nav > .small { grid-column: 1 / -1; }
  .app-header nav > a,
  .app-header nav > form,
  .app-header nav > form .btn { width: 100%; }

  .app-shell {
    padding: 1rem !important;
    border-radius: 18px;
  }

  .app-card,
  .aurora-card { border-radius: 14px; }

  .app-shell > .app-card,
  .auth-shell {
    padding: 1rem !important;
  }

  .admin-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.75rem;
    scrollbar-width: thin;
  }

  .admin-nav a { flex: 0 0 auto; }
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }

  .mobile-stack {
    align-items: stretch !important;
    flex-direction: column !important;
  }

  .mobile-stack > .btn,
  .mobile-stack > a.btn,
  .mobile-stack > form,
  .mobile-stack > form .btn { width: 100%; }

  .mobile-scroll-hint::after {
    content: "Swipe table sideways to see more";
    display: block;
    padding-top: 0.45rem;
    color: var(--muted);
    font-size: 0.75rem;
    text-align: right;
  }

  .responsive-data-table {
    min-width: 820px;
    font-size: 0.86rem;
  }

  .responsive-data-table th,
  .responsive-data-table td { padding: 0.65rem 0.55rem; }

  .modal-dialog { margin: 0.5rem; }
  .modal-dialog-scrollable { height: calc(100% - 1rem); }

  .modal-footer {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .modal-footer > .btn,
  .modal-footer > form,
  .modal-footer > form .btn,
  .modal-footer > div { width: 100%; }

  .modal-footer > div {
    display: grid !important;
    grid-template-columns: 1fr;
  }

  .display-6 { font-size: clamp(1.8rem, 10vw, 2.5rem); }
  .snapshot-library-card { padding: 1.1rem !important; }
  .snapshot-opportunity-table { display: none; }
  .snapshot-opportunity-cards {
    display: grid;
    gap: 0.75rem;
  }

  .mobile-full-width,
  .mobile-full-width .btn { width: 100%; }
}

@media (max-width: 420px) {
  .app-header nav,
  .app-nav,
  .unified-dashboard-header .dashboard-actions { grid-template-columns: 1fr; }
  .brand-logo { width: min(220px, 80vw); }
}

.global-year-filter {
  padding: 0.75rem 1rem;
  background: color-mix(in srgb, var(--card) 88%, var(--accent) 12%);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.global-year-filter .form-select {
  width: auto;
  min-width: 9rem;
  color: var(--text);
  background-color: var(--card);
  border-color: var(--border);
  font-weight: 750;
}

@media (max-width: 575.98px) {
  .global-year-filter .form-select { width: 100%; }
  .global-year-filter > div:last-child { width: 100%; }
}
