:root {
  color-scheme: light;
  --bg: #f3f7ff;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --text: #0b1220;
  --muted: #64748b;
  --line: #dbe7f7;
  --accent: #0b1220;
  --accent-blue: #1268ff;
  --accent-blue-2: #00a3ff;
  --accent-soft: #eaf2ff;
  --success: #087f5b;
  --warning: #a35a00;
  --gradient: linear-gradient(135deg, #07111f 0%, #0b3b91 52%, #00a3ff 100%);
  --gradient-button: linear-gradient(135deg, #07111f 0%, #1268ff 58%, #00a3ff 100%);
  --shadow: 0 18px 50px rgba(15, 52, 107, 0.12);
  --button-shadow: 0 12px 28px rgba(18, 104, 255, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background:
    radial-gradient(circle at top right, rgba(18, 104, 255, 0.14), transparent 34vw),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-required {
  display: block;
}

body.auth-required .sidebar,
body.auth-required .app {
  display: none;
}

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

.login-screen {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(0, 163, 255, 0.35), transparent 28vw),
    var(--gradient);
}

body.auth-required .login-screen {
  display: grid;
}

.login-card {
  display: grid;
  width: min(390px, 100%);
  gap: 16px;
  padding: 28px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(0, 35, 92, 0.36);
}

.login-card .brand-mark {
  width: 142px;
  height: 58px;
  background: transparent;
  color: inherit;
  box-shadow: none;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: #b42318;
  font-size: 13px;
  font-weight: 700;
}

.login-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar {
  min-height: 100vh;
  padding: 24px 18px;
  background:
    radial-gradient(circle at top left, rgba(0, 163, 255, 0.32), transparent 160px),
    linear-gradient(180deg, #07111f 0%, #081a33 52%, #06101d 100%);
  color: #ffffff;
  box-shadow: 18px 0 60px rgba(8, 26, 51, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px 6px 28px;
}

.brand-mark {
  display: block;
  width: 156px;
  height: 104px;
  object-fit: contain;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.menu {
  display: grid;
  gap: 8px;
}

.menu-item {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #c7d8f4;
  text-align: left;
  cursor: pointer;
}

.menu-item:hover,
.menu-item.active {
  background: linear-gradient(135deg, rgba(18, 104, 255, 0.24), rgba(0, 163, 255, 0.14));
  color: #ffffff;
  box-shadow: inset 3px 0 0 #00a3ff;
}

.app {
  min-width: 0;
  padding: 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: #4d6b95;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 18px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button,
.row-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.primary-button {
  padding: 11px 16px;
  background: var(--gradient-button);
  color: #ffffff;
  font-weight: 700;
  box-shadow: var(--button-shadow);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.primary-button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(18, 104, 255, 0.34);
}

.hidden {
  display: none;
}

.secondary-button {
  padding: 11px 16px;
  background: linear-gradient(135deg, #eaf2ff 0%, #d8e9ff 100%);
  color: #0b3b91;
  font-weight: 700;
}

.text-button {
  padding: 8px 10px;
  background: transparent;
  color: var(--accent-blue);
  font-weight: 700;
}

.icon-button {
  width: 34px;
  height: 34px;
  background: var(--accent-soft);
  color: var(--accent-blue);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.stat,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat {
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.96)),
    radial-gradient(circle at top right, rgba(18, 104, 255, 0.18), transparent 90px);
}

.stat span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  font-size: 30px;
  color: #0b3b91;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, var(--panel-soft) 100%);
}

.filters {
  display: flex;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 4px rgba(18, 104, 255, 0.12);
  outline: 0;
}

input,
select {
  height: 40px;
  padding: 0 12px;
}

textarea {
  padding: 10px 12px;
  resize: vertical;
}

.list {
  display: grid;
  gap: 0;
}

.empty {
  padding: 22px 18px;
  color: var(--muted);
}

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.list-item:last-child {
  border-bottom: 0;
}

.list-item strong {
  display: block;
  margin-bottom: 3px;
}

.list-item span,
td small {
  color: var(--muted);
}

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

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

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: #5b6d86;
  font-size: 12px;
  text-transform: uppercase;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #edf4ff;
  color: #0b3b91;
  font-size: 12px;
  font-weight: 700;
}

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

.row-button {
  padding: 7px 9px;
  background: linear-gradient(135deg, #eaf2ff 0%, #d8e9ff 100%);
  color: #0b3b91;
  font-size: 12px;
  font-weight: 700;
}

.row-button.convert {
  background: linear-gradient(135deg, #e6fff5 0%, #c8f7e4 100%);
  color: var(--success);
}

.calendar-panel {
  margin-top: 18px;
}

.calendar-range {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  text-transform: capitalize;
}

.segmented-control {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef5ff;
}

.segmented-control button {
  min-width: 86px;
  padding: 9px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #0b3b91;
  cursor: pointer;
  font-weight: 800;
}

.segmented-control button.active {
  background: var(--gradient-button);
  color: #ffffff;
  box-shadow: var(--button-shadow);
}

.calendar-grid {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.calendar-grid-day {
  grid-template-columns: minmax(0, 1fr);
}

.calendar-grid-week {
  grid-template-columns: repeat(7, minmax(130px, 1fr));
}

.calendar-grid-month {
  grid-template-columns: repeat(7, minmax(120px, 1fr));
}

.calendar-day-card {
  min-height: 132px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.calendar-day-card[data-calendar-day] {
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.calendar-day-card[data-calendar-day]:hover {
  border-color: rgba(18, 104, 255, 0.55);
  box-shadow: 0 12px 28px rgba(18, 104, 255, 0.12);
  transform: translateY(-1px);
}

.calendar-day-card.today {
  border-color: rgba(18, 104, 255, 0.55);
  box-shadow: 0 12px 28px rgba(18, 104, 255, 0.12);
}

.calendar-day-card.muted-day {
  opacity: 0.55;
}

.calendar-day-card > span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-day-card > strong {
  display: block;
  margin-top: 4px;
  color: #0b3b91;
  font-size: 24px;
}

.calendar-selected-day {
  grid-column: 1 / -1;
  min-height: 132px;
  padding: 18px;
  border: 1px solid rgba(18, 104, 255, 0.28);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #eef5ff 100%);
  box-shadow: 0 14px 34px rgba(18, 104, 255, 0.10);
}

.calendar-selected-day > div > span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-selected-day > div > strong {
  display: block;
  margin-top: 4px;
  color: #0b3b91;
  font-size: 22px;
}

.calendar-empty {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.calendar-items {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.calendar-item {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 9px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, #eaf2ff 0%, #d8e9ff 100%);
  color: #0b3b91;
  cursor: pointer;
  text-align: left;
}

.calendar-item strong {
  font-size: 12px;
}

.calendar-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}

dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
  overflow: auto;
}

dialog::backdrop {
  background: rgba(15, 18, 24, 0.45);
}

.lead-form {
  display: grid;
  gap: 14px;
  padding: 22px;
}

.modal-header,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.lead-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.assessment-modal {
  max-width: 760px;
  padding-bottom: 32px;
}

#assessment-dialog {
  width: min(920px, calc(100vw - 28px));
}

#assessment-dialog .modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding-bottom: 10px;
  background: #ffffff;
}

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

.assessment-summary > div,
.assessment-score-grid > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.assessment-summary span,
.assessment-score-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.assessment-summary strong,
.assessment-score-grid strong {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 18px;
}

.assessment-section {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  scroll-margin-top: 90px;
}

.assessment-section h3 {
  color: var(--ink);
  font-size: 18px;
}

.assessment-section p {
  color: var(--muted);
  line-height: 1.5;
}

.assessment-answer {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.assessment-answer strong {
  display: block;
  color: var(--ink);
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .menu {
    grid-template-columns: repeat(2, 1fr);
  }

  .app {
    padding: 20px;
  }

  .topbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: stretch;
  }

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

  .calendar-grid-week,
  .calendar-grid-month {
    grid-template-columns: 1fr;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    flex: 1;
    min-width: 0;
  }

  .filters,
  .form-row {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}
