@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --bg-elevated: rgba(255, 255, 255, 0.72);
  --bg-strong: rgba(255, 255, 255, 0.9);
  --ink: #102033;
  --muted: #637286;
  --line: rgba(16, 32, 51, 0.1);
  --brand: #1b5cff;
  --brand-soft: #dfe8ff;
  --accent: #0ca678;
  --accent-soft: #dcf8ef;
  --warning: #f59f00;
  --warning-soft: #fff1d1;
  --danger: #e8594f;
  --danger-soft: #ffe2df;
  --shadow: 0 22px 60px rgba(27, 32, 46, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --content-width: 1180px;
  --nav-height: 76px;
  --app-height: 100dvh;
}

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

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(27, 92, 255, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(12, 166, 120, 0.14), transparent 24%),
    linear-gradient(180deg, #fbf9f4 0%, #f1ede5 100%);
}

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

button,
input {
  font: inherit;
}

.shell {
  position: relative;
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 18px);
}

.shell::before,
.shell::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.55;
}

.shell::before {
  top: -48px;
  right: -24px;
  width: 180px;
  height: 180px;
  background: rgba(27, 92, 255, 0.18);
}

.shell::after {
  bottom: 72px;
  left: -56px;
  width: 200px;
  height: 200px;
  background: rgba(12, 166, 120, 0.12);
}

.topbar,
.content,
.bottom-nav,
.assistant-fab {
  position: relative;
  z-index: 1;
}

.topbar {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 16px 10px;
}

.topbar__inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.eyebrow__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(12, 166, 120, 0.14);
}

.topbar h1,
.section-title,
.hero-card__title,
.auth-card__title {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.05;
}

.topbar p {
  margin: 8px 0 0;
  max-width: 640px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.topbar__meta {
  flex-shrink: 0;
  min-width: 108px;
  text-align: right;
}

.sync-chip {
  display: inline-flex;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.content {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 10px 16px 0;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.card,
.hero-card,
.mini-card,
.table-card,
.auth-card {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.card,
.table-card,
.auth-card {
  border-radius: var(--radius-lg);
  padding: 18px;
}

.hero-card {
  border-radius: 32px;
  padding: 22px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(27, 92, 255, 0.94), rgba(34, 120, 255, 0.86) 58%, rgba(12, 166, 120, 0.84));
  color: #fff;
}

.hero-card__badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 700;
}

.hero-card__title {
  margin-top: 18px;
  font-size: 32px;
  line-height: 1;
}

.hero-card__subtitle {
  margin-top: 10px;
  max-width: 460px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px;
  line-height: 1.55;
}

.hero-card__metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.hero-card__metric {
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.14);
}

.hero-card__metric-value {
  font-size: 23px;
  font-weight: 800;
}

.hero-card__metric-label {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.section-title {
  font-size: 20px;
  line-height: 1.1;
}

.section-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.stat-card__label,
.mini-card__label,
.list-meta,
.table-caption,
.chat-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stat-card__value,
.mini-card__value {
  margin-top: 10px;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.stat-card__delta {
  margin-top: 10px;
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(16, 32, 51, 0.06);
  font-size: 12px;
  font-weight: 700;
}

.tone-healthy {
  color: var(--accent);
}

.tone-warning {
  color: #c77f00;
}

.tone-critical {
  color: var(--danger);
}

.tone-neutral {
  color: var(--brand);
}

.pill,
.inline-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.tone-healthy,
.pill.tone-healthy {
  background: var(--accent-soft);
}

.status-pill.tone-warning,
.pill.tone-warning {
  background: var(--warning-soft);
}

.status-pill.tone-critical,
.pill.tone-critical {
  background: var(--danger-soft);
}

.status-pill.tone-neutral,
.pill.tone-neutral {
  background: var(--brand-soft);
}

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

.action-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border: 0;
  border-radius: 20px;
  background: var(--bg-strong);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(16, 32, 51, 0.06);
}

.action-btn__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: rgba(27, 92, 255, 0.08);
  font-size: 15px;
  font-weight: 800;
}

.stack-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.stack-item__title {
  font-size: 15px;
  font-weight: 800;
}

.stack-item__text {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.insight-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.insight-item {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  font-size: 14px;
  line-height: 1.55;
}

.chart-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.chart-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.chart-header h3 {
  margin: 0;
  font-size: 16px;
}

.chart-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chart-shell {
  position: relative;
  width: 100%;
  min-height: 220px;
  overflow: hidden;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(244, 241, 234, 0.92));
}

.chart-shell svg {
  display: block;
  width: 100%;
  height: 220px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.bar-strip {
  display: grid;
  grid-template-columns: repeat(var(--columns, 6), minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  min-height: 180px;
  padding-top: 8px;
}

.bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.bar__track {
  width: 100%;
  height: 156px;
  display: flex;
  align-items: end;
  border-radius: 16px;
  background: rgba(16, 32, 51, 0.06);
  overflow: hidden;
}

.bar__fill {
  width: 100%;
  border-radius: 16px 16px 0 0;
  background: linear-gradient(180deg, rgba(27, 92, 255, 0.4), rgba(27, 92, 255, 0.95));
}

.bar__fill--accent {
  background: linear-gradient(180deg, rgba(12, 166, 120, 0.35), rgba(12, 166, 120, 0.95));
}

.bar__fill--warning {
  background: linear-gradient(180deg, rgba(245, 159, 0, 0.4), rgba(245, 159, 0, 0.92));
}

.bar__label,
.bar__value {
  font-size: 12px;
  font-weight: 700;
}

.bar__value {
  color: var(--muted);
}

.table-card {
  overflow: hidden;
}

.table-card__header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.search-input,
.auth-field,
.chat-composer__input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(16, 32, 51, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.filter-chip {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(16, 32, 51, 0.06);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.table-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.table-row {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
}

.table-row__title {
  font-size: 15px;
  font-weight: 800;
}

.table-row__sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.table-stat {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(16, 32, 51, 0.05);
}

.table-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 15px;
}

.chat-layout {
  display: grid;
  gap: 16px;
}

.prompt-grid {
  display: grid;
  gap: 10px;
}

.prompt-btn {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  text-align: left;
  color: var(--ink);
}

.chat-card {
  display: flex;
  flex-direction: column;
  min-height: 60vh;
  padding: 18px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 32, 51, 0.96), rgba(24, 44, 68, 0.94));
  color: #fff;
  box-shadow: var(--shadow);
}

.chat-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.chat-card__header h2 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 22px;
}

.chat-card__header p {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.chat-box {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  min-height: 240px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 2px;
}

.chat-message {
  max-width: 88%;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  line-height: 1.5;
}

.chat-message--user {
  margin-left: auto;
  background: linear-gradient(135deg, rgba(27, 92, 255, 0.96), rgba(81, 142, 255, 0.94));
}

.chat-message--bot {
  background: rgba(255, 255, 255, 0.12);
}

.chat-composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 16px;
}

.chat-card--assistant {
  max-height: var(--assistant-panel-max-height, none);
  overflow: hidden;
}

.chat-composer--assistant {
  z-index: 1;
}

.primary-btn,
.secondary-btn,
.chat-composer__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  font-weight: 800;
  cursor: pointer;
}

.primary-btn,
.chat-composer__send {
  background: linear-gradient(135deg, #1b5cff, #4d8eff);
  color: #fff;
}

.secondary-btn {
  background: rgba(16, 32, 51, 0.08);
  color: var(--ink);
}

.settings-stack {
  display: grid;
  gap: 14px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(16, 32, 51, 0.08);
}

.settings-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.settings-row:first-child {
  padding-top: 0;
}

.bottom-nav {
  position: fixed;
  right: 12px;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  left: 12px;
}

.bottom-nav__rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 8px;
  border: 1px solid rgba(16, 32, 51, 0.08);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px rgba(27, 32, 46, 0.14);
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 58px;
  padding: 8px 2px;
  border-radius: 18px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.bottom-nav__item.is-active {
  background: rgba(27, 92, 255, 0.1);
  color: var(--brand);
}

.bottom-nav__icon {
  font-size: 14px;
  line-height: 1;
}

.assistant-fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 24px);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 52px;
  border-radius: 999px;
  background: linear-gradient(135deg, #102033, #204268);
  color: #fff;
  box-shadow: 0 20px 40px rgba(16, 32, 51, 0.24);
}

.assistant-fab__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #7ef3c8;
  box-shadow: 0 0 0 8px rgba(126, 243, 200, 0.18);
}

@media (max-width: 767px) {
  .page-assistant .content {
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 24px);
  }

  .page-assistant .chat-layout {
    min-height: var(--assistant-screen-min-height, auto);
  }

  .page-assistant .chat-card--assistant {
    min-height: clamp(360px, 62vh, 560px);
    padding: 16px 16px 0;
    border-radius: 24px;
  }

  .page-assistant .chat-card__header {
    margin-bottom: 12px;
  }

  .page-assistant .chat-box {
    min-height: 0;
    max-height: none;
    padding-bottom: 12px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .page-assistant .chat-composer--assistant {
    position: sticky;
    bottom: var(--assistant-bottom-dock, calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 16px));
    margin-top: 0;
    padding: 12px 0 12px;
    background: linear-gradient(180deg, rgba(24, 44, 68, 0), rgba(24, 44, 68, 0.9) 24%, rgba(24, 44, 68, 1) 100%);
  }

  .page-assistant .chat-composer__send {
    white-space: nowrap;
  }
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 430px;
}

.auth-card__title {
  font-size: 28px;
}

.auth-card__subtitle {
  margin: 10px 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-error {
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.auth-footnote {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

@media (min-width: 720px) {
  .grid--cards {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .dashboard-layout {
    display: grid;
    grid-template-columns: 1.45fr 0.95fr;
    gap: 16px;
  }

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

  .triple-column {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }

  .chat-layout {
    grid-template-columns: 0.92fr 1.08fr;
    align-items: start;
  }

  .bottom-nav__rail {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

@media (min-width: 1080px) {
  .content {
    padding-left: 20px;
    padding-right: 20px;
  }

  .topbar {
    padding-left: 20px;
    padding-right: 20px;
  }

  .table-row {
    grid-template-columns: 1.35fr 1fr;
    align-items: center;
  }

  .table-row__stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
