:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --ink: #111827;
  --muted: #667085;
  --line: rgba(17, 24, 39, 0.12);
  --panel: rgba(255, 255, 255, 0.76);
  --panel-strong: #ffffff;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a06a;
  --green-dark: #047857;
  --gold: #f59e0b;
  --gold-dark: #92400e;
  --red: #dc2626;
  --red-dark: #991b1b;
  --tone: var(--blue);
  --tone-dark: var(--blue-dark);
  --shadow: 0 18px 42px rgba(31, 41, 55, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body.tone-done {
  --tone: var(--blue);
  --tone-dark: var(--blue-dark);
}

body.tone-warning {
  --tone: var(--gold);
  --tone-dark: var(--gold-dark);
}

body.tone-danger {
  --tone: var(--red);
  --tone-dark: var(--red-dark);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, color-mix(in srgb, var(--tone) 18%, transparent), transparent 24rem),
    linear-gradient(180deg, #fbfcff 0%, var(--bg) 38%, #eef5ff 100%);
}

body.cycle-finale {
  background:
    radial-gradient(circle at 12% 6%, rgba(255, 214, 165, 0.86), transparent 16rem),
    radial-gradient(circle at 92% 10%, rgba(186, 230, 253, 0.88), transparent 17rem),
    radial-gradient(circle at 18% 58%, rgba(221, 214, 254, 0.82), transparent 16rem),
    radial-gradient(circle at 86% 62%, rgba(187, 247, 208, 0.82), transparent 15rem),
    linear-gradient(180deg, #fff8fb 0%, #f6fbff 48%, #f7fff8 100%);
}

body.cycle-finale .hero-panel {
  border-color: rgba(255, 255, 255, 0.5);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.92), rgba(22, 160, 106, 0.86)),
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.34), transparent 9rem),
    radial-gradient(circle at 88% 14%, rgba(253, 230, 138, 0.42), transparent 10rem);
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -18px;
  left: var(--x);
  width: 8px;
  height: 14px;
  border-radius: var(--radius);
  background: var(--color);
  opacity: 0.96;
  animation: confetti-fall var(--duration) cubic-bezier(0.18, 0.78, 0.36, 1) var(--delay) forwards;
}

.confetti-piece:nth-child(3n) {
  width: 6px;
  height: 6px;
}

.confetti-piece:nth-child(4n) {
  width: 10px;
  height: 5px;
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, -20px, 0) rotate(0deg);
  }

  70% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--tx), 105vh, 0) rotate(var(--rot));
  }
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  position: relative;
  padding: max(18px, env(safe-area-inset-top)) 18px calc(96px + env(safe-area-inset-bottom));
}

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

.brand-block {
  min-width: 0;
}

.brand-logo {
  width: 86px;
  height: auto;
  display: block;
  margin: 0 0 8px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.lang-toggle {
  min-width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: var(--blue-dark);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 12px;
  font-weight: 950;
}

.eyebrow {
  min-height: 17px;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 27px;
  line-height: 1.06;
  letter-spacing: 0;
}

h2 {
  max-width: 250px;
  margin-top: 16px;
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0;
}

h3 {
  font-size: 18px;
  letter-spacing: 0;
}

.icon-button,
.tab,
.text-button,
.segmented button,
.action-tile {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px var(--line);
}

.icon-button.compact {
  width: 36px;
  height: 36px;
  background: rgba(23, 32, 26, 0.06);
}

svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.hero-panel {
  min-height: 214px;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--tone) 26%, transparent);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--tone) 94%, #111827), color-mix(in srgb, var(--tone-dark) 94%, #111827)),
    url("data:image/svg+xml,%3Csvg width='240' height='240' viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.16' stroke-width='2'%3E%3Cpath d='M20 170c40-35 77-35 112 0s72 35 108 0'/%3E%3Cpath d='M0 80h240M48 0v240M128 0v240M208 0v240'/%3E%3C/g%3E%3C/svg%3E");
  color: white;
  box-shadow: var(--shadow);
}

.hero-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.hero-copy p {
  max-width: 250px;
  margin-top: auto;
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  line-height: 1.48;
}

.status-pill {
  width: fit-content;
  max-width: 100%;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 800;
}

.streak-ring {
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  align-self: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle, color-mix(in srgb, var(--tone-dark) 88%, #111827) 56%, transparent 57%),
    conic-gradient(#ffffff var(--progress, 0deg), rgba(255, 255, 255, 0.24) 0deg);
}

.streak-ring span {
  font-size: 32px;
  font-weight: 850;
  grid-area: 1 / 1;
}

.streak-ring small {
  margin-top: 46px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 10px;
  font-weight: 800;
  grid-area: 1 / 1;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 22px;
}

.habit-panel {
  margin: 16px 0 18px;
  padding: 16px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--tone) 9%, white);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 20%, transparent);
}

.habit-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.habit-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--tone-dark);
  font-size: 12px;
  font-weight: 900;
}

.habit-head h3 {
  color: var(--ink);
  font-size: 17px;
}

.habit-head > span {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: white;
  color: var(--tone-dark);
  font-size: 12px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 20%, transparent);
}

.habit-track {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin: 14px 0 12px;
}

.habit-dot {
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 20%, transparent);
}

.habit-dot.is-filled {
  background: var(--tone);
  box-shadow: 0 4px 10px color-mix(in srgb, var(--tone) 24%, transparent);
}

.habit-panel p {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.recovery-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.recovery-actions[hidden] {
  display: none;
}

.action-tile {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex-direction: column;
  padding: 12px 8px;
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tile-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--tone) 10%, white);
  color: var(--tone-dark);
  font-weight: 900;
}

.action-tile span:last-child {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 800;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 12px;
}

.section-heading > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-button {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 13px;
  font-weight: 850;
}

.text-button.subtle {
  background: rgba(37, 99, 235, 0.1);
  color: var(--blue-dark);
}

.timeline,
.lead-list,
.follow-list {
  display: grid;
  gap: 10px;
}

.empty-state,
.entry-card,
.lead-card,
.follow-card,
.stat-card,
.principle-panel {
  border-radius: 8px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(18px);
}

.empty-state {
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.empty-state.compact {
  padding: 13px;
  font-size: 13px;
}

.entry-card,
.lead-card,
.follow-card {
  padding: 14px;
}

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

.card-title {
  min-width: 0;
}

.card-title strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 16px;
}

.card-title span,
.card-meta,
.lead-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.38;
}

.tag {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--blue) 10%, white);
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 850;
}

.tag.warn {
  background: #fff7df;
  color: var(--gold-dark);
}

.tag.hot {
  background: #fee2e2;
  color: var(--red-dark);
}

.lead-note {
  margin-top: 10px;
  overflow-wrap: anywhere;
}

.crm-ready,
.crm-missing {
  margin-top: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}

.crm-ready {
  background: #eaf1ff;
  color: var(--blue-dark);
}

.crm-missing {
  background: #fff7df;
  color: var(--gold-dark);
}

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

.mini-button {
  min-height: 36px;
  flex: 1;
  border: 0;
  border-radius: 8px;
  background: rgba(23, 32, 26, 0.07);
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.card-actions .mini-button {
  flex-basis: calc(33.333% - 6px);
}

.mini-button.primary {
  background: var(--blue);
  color: white;
}

.mini-button.crm {
  flex-basis: 100%;
  background: #eaf1ff;
  color: var(--blue-dark);
}

.mini-button.is-loading {
  opacity: 0.68;
  pointer-events: none;
}

.search-wrap {
  margin-bottom: 12px;
}

.lead-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 46px;
  padding: 0 13px;
}

textarea {
  resize: vertical;
  padding: 12px 13px;
  line-height: 1.4;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(23, 32, 26, 0.07);
}

.segmented button {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.segmented button.is-selected {
  background: white;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(23, 32, 26, 0.08);
}

.month-switcher {
  display: grid;
  grid-template-columns: 36px 1fr 36px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.month-switcher strong {
  text-align: center;
  font-size: 16px;
  font-weight: 900;
}

.calendar-panel {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(18px);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-weekdays {
  margin-bottom: 7px;
}

.calendar-weekdays span {
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  font-weight: 900;
}

.day-cell {
  min-width: 0;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-direction: column;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.day-cell.is-empty {
  background: transparent;
  box-shadow: none;
}

.day-cell.is-done {
  background: var(--blue);
  color: white;
  box-shadow: 0 5px 13px rgba(37, 99, 235, 0.18);
}

.day-cell.is-today {
  box-shadow:
    inset 0 0 0 2px var(--gold),
    0 5px 13px rgba(245, 158, 11, 0.12);
}

.day-cell.is-selected {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.day-cell.is-makeup {
  background: var(--green);
  color: white;
}

.day-cell strong {
  font-size: 15px;
  line-height: 1;
}

.day-cell span {
  color: currentColor;
  opacity: 0.72;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.compact-list {
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  min-height: 86px;
  display: flex;
  justify-content: center;
  flex-direction: column;
  padding: 14px;
}

.stat-card span {
  font-size: 25px;
  font-weight: 900;
}

.stat-card.level-stat {
  background: color-mix(in srgb, var(--blue) 9%, white);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--blue) 18%, transparent);
}

.stat-card.level-stat span {
  color: var(--blue-dark);
}

.stat-card p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.principle-panel {
  margin-top: 14px;
  padding: 18px;
  color: var(--blue-dark);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 4;
  width: min(100%, 480px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 0 auto;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(250, 248, 242, 0.88);
  backdrop-filter: blur(22px);
}

.tab {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-direction: column;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.tab svg {
  width: 22px;
  height: 22px;
}

.tab.is-active {
  background: color-mix(in srgb, var(--tone) 12%, white);
  color: var(--tone-dark);
}

.sheet {
  width: min(calc(100% - 24px), 456px);
  max-height: calc(100vh - 26px);
  margin: auto auto 12px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.sheet::backdrop {
  background: rgba(23, 32, 26, 0.32);
  backdrop-filter: blur(4px);
}

.sheet form {
  display: grid;
  gap: 13px;
  padding: 8px 16px 18px;
}

.detail-content {
  display: grid;
  gap: 14px;
  padding: 8px 16px 18px;
}

.sheet-handle {
  width: 42px;
  height: 5px;
  justify-self: center;
  border-radius: 999px;
  background: rgba(23, 32, 26, 0.18);
}

.sheet-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.detail-grid {
  display: grid;
  gap: 9px;
}

.detail-field {
  padding: 11px 12px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.06);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.11);
}

.detail-field span {
  display: block;
  margin-bottom: 5px;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 900;
}

.detail-field p {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.42;
  overflow-wrap: anywhere;
}

.detail-heading {
  margin-top: 2px;
}

.detail-timeline {
  max-height: 38vh;
  overflow: auto;
  padding-right: 2px;
}

.sheet-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

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

.sync-warning {
  padding: 12px;
  border-radius: 8px;
  background: #fff7df;
  color: var(--gold-dark);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;
}

.identity-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.06);
  color: var(--blue-dark);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.identity-card strong {
  font-size: 13px;
  font-weight: 900;
}

.identity-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.identity-card.is-connected {
  background: #eaf7ef;
  color: var(--green-dark);
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.16);
}

.primary-button {
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-weight: 900;
}

@media (min-width: 481px) {
  body {
    background-color: #ece5d9;
  }

  .app-shell {
    min-height: calc(100vh - 28px);
    margin-top: 14px;
    margin-bottom: 14px;
    border: 1px solid rgba(23, 32, 26, 0.1);
    border-radius: 28px;
    background:
      radial-gradient(circle at 8% 0%, color-mix(in srgb, var(--tone) 16%, transparent), transparent 24rem),
      linear-gradient(180deg, #fbfcff 0%, var(--bg) 38%, #eef5ff 100%);
    overflow: hidden;
  }
}
