:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172026;
  --muted: #667085;
  --line: #dce3ea;
  --line-strong: #c7d2de;
  --teal: #007b83;
  --teal-dark: #005d63;
  --red: #bd3026;
  --amber: #a15c00;
  --shadow: 0 16px 45px rgba(15, 30, 45, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(430px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-card h1,
.page-title h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.login-card p,
.page-title p {
  color: var(--muted);
  line-height: 1.65;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: #10262b;
  color: #f5fbfb;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 8px 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand strong {
  display: block;
  font-size: 18px;
  letter-spacing: 0;
}

.brand span {
  display: block;
  color: rgba(255, 255, 255, 0.68);
  margin-top: 4px;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  text-align: left;
  border-radius: 6px;
  padding: 11px 12px;
}

.nav-button:hover,
.nav-button.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 10px 4px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-footer strong {
  display: block;
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 26px;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: #e8f4f5;
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}

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

.panel-header h2,
.section-heading {
  margin: 0;
  font-size: 20px;
}

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

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

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

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

.stat {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.analytics-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.analytics-toolbar strong,
.analytics-toolbar span {
  display: block;
}

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

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
}

.segmented button {
  border: 0;
  background: transparent;
  padding: 10px 14px;
  color: var(--muted);
  font-weight: 800;
}

.segmented button.is-active {
  background: var(--teal);
  color: #ffffff;
}

.chart-wrap {
  display: grid;
  gap: 12px;
}

.line-chart {
  width: 100%;
  min-height: 230px;
  overflow: visible;
}

.line-chart line {
  stroke: var(--line-strong);
  stroke-width: 1.4;
}

.line-chart .chart-grid-line {
  stroke: var(--line);
}

.line-chart polyline {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.line-chart text {
  fill: var(--muted);
  font-size: 12px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.bar-list,
.funnel-list,
.journey-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 2fr);
  gap: 14px;
  align-items: center;
}

.bar-row strong,
.bar-row span {
  display: block;
}

.bar-row span {
  color: var(--muted);
  font-size: 13px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef3;
}

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #68b8bd);
}

.funnel-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  background: #ffffff;
}

.funnel-row span,
.funnel-row strong {
  position: relative;
  z-index: 1;
}

.funnel-row i {
  position: absolute;
  inset: auto auto 0 0;
  height: 4px;
  background: var(--teal);
}

.journey-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
}

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

.journey-head span,
.journey-head time {
  color: var(--muted);
  font-size: 13px;
}

.journey-head strong,
.journey-head span {
  display: block;
}

.journey-card ol {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.journey-card li {
  display: grid;
  grid-template-columns: 150px 130px minmax(160px, 1fr) minmax(160px, 1fr);
  gap: 10px;
  align-items: start;
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

.journey-card li time,
.journey-card li span,
.journey-card li em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
}

.journey-card li strong {
  font-size: 14px;
}

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

.field {
  display: grid;
  gap: 7px;
}

.field.full,
.field-object,
.field-list,
.form-actions,
.table-wrap {
  grid-column: 1 / -1;
}

.field label,
.field-title {
  font-weight: 700;
  font-size: 14px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  padding: 11px 12px;
  color: var(--text);
}

.field textarea {
  min-height: 116px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 3px solid rgba(0, 123, 131, 0.16);
  border-color: var(--teal);
}

.field-object,
.field-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--panel-soft);
}

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

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

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

.list-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.image-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  align-items: center;
}

.image-preview {
  width: 90px;
  height: 68px;
  border-radius: 6px;
  object-fit: cover;
  background: #e8eef3;
  border: 1px solid var(--line);
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 14px;
  min-height: 40px;
  font-weight: 800;
  text-decoration: none;
}

.button.primary {
  background: var(--teal);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--teal-dark);
}

.button.secondary {
  background: #ffffff;
  border-color: var(--line-strong);
  color: var(--text);
}

.button.danger {
  background: #fff4f2;
  border-color: #f0b8b2;
  color: var(--red);
}

.button.ghost {
  background: transparent;
  color: inherit;
}

.button.small {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 13px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.tab {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  border-radius: 999px;
  padding: 9px 13px;
}

.tab.is-active {
  background: #e8f4f5;
  border-color: #9ed2d5;
  color: var(--teal-dark);
  font-weight: 800;
}

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

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

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.image-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #edf2f6;
}

.image-card div {
  padding: 10px;
  display: grid;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 380px;
  background: #10262b;
  color: #ffffff;
  padding: 14px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toast.is-error {
  background: var(--red);
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: relative;
    height: auto;
  }

  .grid.two,
  .grid.three,
  .analytics-stats,
  .form-grid,
  .object-grid {
    grid-template-columns: 1fr;
  }

  .analytics-toolbar,
  .bar-row,
  .journey-head,
  .journey-card li {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .main {
    padding: 18px;
  }

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