:root {
  color-scheme: light;
  --bg: #f7f8fc;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: #ffffff;
  --ink: #14142f;
  --muted: #667085;
  --line: rgba(31, 34, 64, 0.12);
  --navy: #251573;
  --navy-soft: #ebe8ff;
  --red: #e02424;
  --red-soft: #ffe8e8;
  --ice: #e8f6ff;
  --green: #0c7a61;
  --gold: #be7d13;
  --danger: #b63838;
  --shadow: 0 22px 55px rgba(28, 29, 59, 0.12);
  --glass: blur(18px) saturate(1.35);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1020;
  --surface: rgba(22, 20, 48, 0.72);
  --surface-strong: #181535;
  --ink: #f7f5ff;
  --muted: #b7b1d2;
  --line: rgba(255, 255, 255, 0.14);
  --navy: #7f6bff;
  --navy-soft: rgba(127, 107, 255, 0.22);
  --red: #ff4b55;
  --red-soft: rgba(255, 75, 85, 0.2);
  --ice: rgba(130, 213, 255, 0.16);
  --green: #60d4b6;
  --gold: #f3bd63;
  --danger: #ff7878;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(37, 21, 115, 0.08), transparent 38%),
    linear-gradient(245deg, rgba(224, 36, 36, 0.09), transparent 34%),
    repeating-linear-gradient(90deg, rgba(20, 20, 47, 0.035) 0 1px, transparent 1px 96px),
    var(--bg);
  color: var(--ink);
  font-family:
    Manrope, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
  transition:
    background 0.22s ease,
    color 0.22s ease;
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(120deg, rgba(127, 107, 255, 0.16), transparent 38%),
    linear-gradient(245deg, rgba(255, 75, 85, 0.13), transparent 34%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 96px),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

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

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  min-height: 46px;
  padding: 11px 15px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition:
    border 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

input,
select {
  border-radius: 999px;
}

textarea {
  border-radius: 18px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 21, 115, 0.45);
  background: #ffffff;
  box-shadow:
    0 0 0 4px rgba(37, 21, 115, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] select:focus,
:root[data-theme="dark"] textarea:focus {
  background: rgba(255, 255, 255, 0.13);
  box-shadow: 0 0 0 4px rgba(127, 107, 255, 0.16);
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.command-bar {
  position: sticky;
  top: 14px;
  z-index: 10;
  width: min(1480px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto minmax(320px, 1fr) auto;
  gap: 18px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
}

:root[data-theme="dark"] .command-bar {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(16, 15, 37, 0.76);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  color: var(--ink);
  text-decoration: none;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
}

.brand img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ffffff;
  box-shadow: 0 10px 24px rgba(37, 21, 115, 0.18);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  line-height: 1;
  font-weight: 950;
  letter-spacing: -0.02em;
}

.brand small {
  color: var(--muted);
  font-weight: 800;
  margin-top: 4px;
}

.nav-list {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid rgba(37, 21, 115, 0.08);
  border-radius: 999px;
  background: rgba(247, 248, 252, 0.72);
}

:root[data-theme="dark"] .nav-list {
  background: rgba(255, 255, 255, 0.06);
}

.nav-list a {
  color: #3b3f59;
  text-decoration: none;
  padding: 11px 17px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 900;
  transition:
    color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

:root[data-theme="dark"] .nav-list a {
  color: #dcd7ff;
}

.nav-list a:hover,
.nav-list a.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--navy), #3b25a2);
  box-shadow: 0 10px 22px rgba(37, 21, 115, 0.22);
}

.command-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(232, 246, 255, 0.9);
  color: var(--navy);
  font-size: 0.83rem;
  font-weight: 900;
  white-space: nowrap;
}

.theme-toggle {
  min-width: 82px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(235, 232, 255, 0.88));
  color: var(--navy);
  border: 1px solid var(--line);
}

:root[data-theme="dark"] .theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.workspace {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 34px 0 20px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: viewIn 0.34s ease both;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-strip,
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.hero-strip {
  min-height: 218px;
  border-radius: 8px;
  padding: clamp(24px, 4vw, 46px);
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(37, 21, 115, 0.96), rgba(44, 34, 126, 0.88)),
    linear-gradient(90deg, rgba(224, 36, 36, 0.82), transparent 48%);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

:root[data-theme="dark"] .hero-strip {
  background:
    linear-gradient(135deg, rgba(23, 17, 70, 0.98), rgba(54, 41, 144, 0.86)),
    linear-gradient(90deg, rgba(255, 75, 85, 0.72), transparent 48%);
}

.hero-strip::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 5px;
  background: linear-gradient(90deg, var(--red), #ffffff, var(--navy));
}

.hero-strip h1,
.page-heading h1 {
  margin: 0;
  line-height: 1.04;
  letter-spacing: -0.04em;
  text-wrap: balance;
}

.hero-strip h1 {
  max-width: 850px;
  font-size: clamp(2rem, 4vw, 4.5rem);
}

.page-heading h1 {
  font-size: clamp(1.9rem, 3vw, 3.1rem);
}

.hero-signal {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 180px;
}

.hero-signal span {
  display: grid;
  place-items: center;
  width: 94px;
  height: 94px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  color: #ffffff;
  font-size: 2rem;
  font-weight: 900;
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.hero-signal img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-signal strong {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.18);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-strip .eyebrow {
  color: #ffe2e2;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-pill {
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  padding: 18px 22px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
  animation: floatIn 0.45s ease both;
}

:root[data-theme="dark"] .metric-pill,
:root[data-theme="dark"] .panel {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--surface);
}

.metric-pill:nth-child(2) {
  animation-delay: 0.04s;
}

.metric-pill:nth-child(3) {
  animation-delay: 0.08s;
}

.metric-pill:nth-child(4) {
  animation-delay: 0.12s;
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.metric-pill span {
  color: var(--muted);
  font-weight: 900;
}

.metric-pill strong {
  color: var(--navy);
  font-size: clamp(1.7rem, 2.4vw, 2.55rem);
  line-height: 1;
}

.dashboard-grid,
.grid {
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  grid-template-columns: 1fr 1fr;
}

.two-column {
  grid-template-columns: minmax(360px, 0.85fr) minmax(520px, 1.15fr);
}

.message-layout {
  grid-template-columns: minmax(520px, 1.15fr) minmax(320px, 0.85fr);
}

.panel {
  display: grid;
  gap: 15px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 8px;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 4px;
}

.panel h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
  font-weight: 950;
}

.panel-copy {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.7;
}

.view-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 16px 6px 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: var(--glass);
  font-weight: 950;
}

.view-logo img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

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

.form-panel,
#profileForm {
  display: grid;
  gap: 14px;
}

.inline-control {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  min-height: 42px;
  border-radius: 999px;
  padding: 0 14px 0 10px;
  background: rgba(235, 232, 255, 0.72);
}

.inline-control input {
  width: 18px;
  min-height: 18px;
}

.inline-control label {
  color: var(--ink);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary {
  background: linear-gradient(135deg, var(--navy), #3b25a2);
  color: #ffffff;
  box-shadow: 0 12px 26px rgba(37, 21, 115, 0.2);
}

.secondary {
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  border: 1px solid var(--line);
}

:root[data-theme="dark"] .secondary {
  background: rgba(255, 255, 255, 0.08);
}

.danger-action {
  color: var(--danger);
}

.search {
  max-width: 270px;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

td {
  font-weight: 720;
}

.table-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.table-actions button {
  min-height: 36px;
  padding: 0 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 950;
}

.chip.rocket {
  color: #06473f;
  background: #d8f7ef;
}

.chip.cruise,
.chip.sailboat {
  color: #251573;
  background: var(--navy-soft);
}

.chip.plain,
.chip.boat {
  color: #71460a;
  background: #f9e9c9;
}

.chip.new,
.chip.prospect {
  color: #891d1d;
  background: var(--red-soft);
}

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

.category-guide article,
.category-mini {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.45);
  padding: 14px;
}

:root[data-theme="dark"] .category-guide article,
:root[data-theme="dark"] .category-mini {
  background: rgba(255, 255, 255, 0.06);
}

.category-guide p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.45;
}

.category-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}

.category-mini strong {
  width: 100%;
  color: var(--ink);
  font-weight: 950;
}

.category-mini span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

:root[data-theme="dark"] .category-mini span {
  background: rgba(255, 255, 255, 0.08);
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.result-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

/* Upcoming occasions (dashboard) */

.upcoming-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.upcoming-item {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.5);
}

:root[data-theme="dark"] .upcoming-item {
  background: rgba(255, 255, 255, 0.06);
}

.upcoming-date {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 36px;
  border-radius: 12px;
  padding: 0 8px;
  background: var(--navy-soft);
  color: var(--navy);
  font-weight: 950;
  font-size: 0.82rem;
  white-space: nowrap;
}

.upcoming-body {
  display: grid;
  gap: 2px;
}

.upcoming-body strong {
  font-weight: 900;
}

.upcoming-body small {
  color: var(--muted);
  font-weight: 750;
}

/* Directory controls: category chips, sort, export */

.directory-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

:root[data-theme="dark"] .filter-chip {
  background: rgba(255, 255, 255, 0.06);
}

.filter-chip.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--navy), #3b25a2);
  border-color: transparent;
}

.directory-controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sort-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.sort-label select {
  min-height: 38px;
  padding: 0 12px;
  width: auto;
}

/* Feedback bar inside the directory table */

.feedback-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.feedback-track {
  display: inline-block;
  width: 56px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}

.feedback-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}

.feedback-fill.high {
  background: var(--green);
}

.feedback-fill.mid {
  background: var(--gold);
}

.feedback-fill.low {
  background: var(--red);
}

/* History view */

.history-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 560px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.5);
}

:root[data-theme="dark"] .history-item {
  background: rgba(255, 255, 255, 0.06);
}

.history-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.history-body strong {
  font-weight: 900;
}

.history-body small {
  color: var(--muted);
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Settings helpers */

.field-hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.5;
}

.connection-result {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--muted);
}

.connection-result.success {
  color: var(--green);
}

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

.settings-panel {
  max-width: 920px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 44px));
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  border-radius: 999px;
  background: var(--ink);
  color: #ffffff;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

@media (max-width: 1160px) {
  .command-bar {
    grid-template-columns: 1fr;
    border-radius: 28px;
  }

  .brand,
  .command-actions {
    justify-content: center;
  }

  .nav-list {
    overflow-x: auto;
    justify-content: flex-start;
  }

  .two-column,
  .message-layout,
  .dashboard-grid,
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding: 10px;
  }

  .command-bar {
    top: 8px;
    gap: 10px;
    padding: 8px;
  }

  .brand {
    min-width: 0;
  }

  .brand img {
    width: 44px;
    height: 44px;
  }

  .nav-list {
    padding: 5px;
  }

  .nav-list a {
    flex: 1 0 auto;
    padding: 10px 13px;
    text-align: center;
  }

  .command-actions,
  .hero-strip,
  .page-heading,
  .panel-heading {
    display: grid;
  }

  .command-actions {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .connection-pill {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .workspace {
    padding-top: 22px;
  }

  .hero-strip {
    min-height: 0;
    padding: 24px;
  }

  .hero-signal {
    display: grid;
    justify-self: start;
  }

  .hero-signal span {
    width: 74px;
    height: 74px;
  }

  .two-column,
  .message-layout,
  .dashboard-grid,
  .metrics,
  .field-grid,
  .category-guide {
    grid-template-columns: 1fr;
  }

  .metric-pill {
    min-height: 88px;
  }

  .form-actions button,
  .command-actions button {
    width: 100%;
  }

  .search {
    max-width: none;
  }

  .directory-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .directory-controls-right {
    justify-content: space-between;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    min-width: 0;
    width: 100%;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.74);
    padding: 8px;
  }

  td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    padding: 10px 6px;
    text-align: right;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 950;
    text-transform: uppercase;
    text-align: left;
  }

  .table-actions {
    width: auto;
  }
}
