/* Nicoby Wealth — visual system.
 *
 * The brief asked for premium, calm, modern, clear, trustworthy; not corporate,
 * not cartoonish. So: a deep ink base rather than black, a restrained sage-green
 * accent rather than the usual fintech purple or alarm-red, real typographic
 * hierarchy, and generous space. Money is set in tabular figures so columns of
 * numbers line up and stop looking like a spreadsheet accident.
 *
 * Deliberately NOT the Nicoby gold-and-black — the brief allows a different
 * palette here, and gold on black reads as luxury marketing, which is the wrong
 * register for a screen that sometimes has to tell you that you are overdrawn.
 */

:root {
  color-scheme: light dark;

  /* Light */
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f2f1ed;
  --surface-3: #e9e8e3;
  --border: #e3e1db;
  --border-strong: #d2cfc7;

  --text: #1a1d1a;
  --text-2: #565a55;
  --text-3: #8a8e88;

  /* Sage — calm, not corporate. Used for "you're fine". */
  --accent: #4a6b52;
  --accent-soft: #e8efe9;
  --accent-text: #ffffff;

  /* Warning is amber, not red. Red is for actual danger only. */
  --warn: #9a6b1f;
  --warn-soft: #fbf1de;
  --danger: #a03d32;
  --danger-soft: #faeae7;
  --info: #3f5f7a;
  --info-soft: #e8eff4;

  --positive: #3d6b4a;
  --negative: #a03d32;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;

  --shadow: 0 1px 2px rgba(26, 29, 26, 0.04), 0 4px 16px rgba(26, 29, 26, 0.04);
  --shadow-lg: 0 2px 8px rgba(26, 29, 26, 0.06), 0 12px 40px rgba(26, 29, 26, 0.09);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;

  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

[data-theme='dark'] {
  --bg: #14161a;
  --surface: #1c1f24;
  --surface-2: #23272d;
  --surface-3: #2b3037;
  --border: #2c3138;
  --border-strong: #3d434b;

  --text: #eceef0;
  --text-2: #a4aab2;
  --text-3: #6d747d;

  --accent: #7fae8b;
  --accent-soft: #1e2a22;
  --accent-text: #10150f;

  --warn: #d9a441;
  --warn-soft: #2b2417;
  --danger: #e0776a;
  --danger-soft: #2d1d1a;
  --info: #7fa8c9;
  --info-soft: #1a242c;

  --positive: #7fae8b;
  --negative: #e0776a;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.35), 0 12px 40px rgba(0, 0, 0, 0.3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #14161a;
    --surface: #1c1f24;
    --surface-2: #23272d;
    --surface-3: #2b3037;
    --border: #2c3138;
    --border-strong: #3d434b;
    --text: #eceef0;
    --text-2: #a4aab2;
    --text-3: #6d747d;
    --accent: #7fae8b;
    --accent-soft: #1e2a22;
    --accent-text: #10150f;
    --warn: #d9a441;
    --warn-soft: #2b2417;
    --danger: #e0776a;
    --danger-soft: #2d1d1a;
    --info: #7fa8c9;
    --info-soft: #1a242c;
    --positive: #7fae8b;
    --negative: #e0776a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.35), 0 12px 40px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* --- Privacy mode -------------------------------------------------------
 * One class on <body> blurs every figure at once, for use in public.
 * Blur, not hide: the shape of the page stays, so nothing jumps. */
body.private .money,
body.private .blurable {
  filter: blur(9px);
  user-select: none;
  pointer-events: none;
  transition: filter 0.15s;
}

/* --- Layout ------------------------------------------------------------- */

.app {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + var(--safe-b) + 28px);
}

@media (min-width: 900px) {
  .app {
    max-width: 940px;
    padding-bottom: 40px;
  }
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 10px;
  background: linear-gradient(var(--bg) 72%, transparent);
  backdrop-filter: blur(8px);
}

.topbar h1 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
}

.topbar .sub {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 400;
  letter-spacing: 0;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 15px;
  flex: none;
  position: relative;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.icon-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

/* --- Cards -------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.card.flush {
  padding: 0;
  overflow: hidden;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin: 0 0 12px;
}

/* --- The hero figure ----------------------------------------------------
 * Decision first, data second: this is the first thing on the screen and it
 * answers the only question that matters in the moment. */

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 20px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  position: relative;
}

.hero .label {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 6px;
}

.hero .amount {
  font-size: clamp(48px, 15vw, 68px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 10px;
}

.hero .amount.ok {
  color: var(--text);
}
.hero .amount.low {
  color: var(--warn);
}
.hero .amount.none {
  color: var(--danger);
}

.hero .why {
  font-size: 13px;
  color: var(--text-3);
  border: 0;
  background: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 100px;
  font-family: inherit;
  transition: background 0.12s;
}
.hero .why:hover {
  background: var(--surface-2);
  color: var(--text-2);
}

.hero-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 18px;
}

.hero-row > div {
  background: var(--surface);
  padding: 12px 8px;
}

.hero-row .k {
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.hero-row .v {
  font-size: 19px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

/* --- Progress ----------------------------------------------------------- */

.bar {
  height: 7px;
  background: var(--surface-3);
  border-radius: 100px;
  overflow: hidden;
  margin: 10px 0 8px;
}

.bar > span {
  display: block;
  height: 100%;
  border-radius: 100px;
  background: var(--accent);
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bar > span.warn {
  background: var(--warn);
}
.bar > span.danger {
  background: var(--danger);
}

/* A marker showing where an even pace would have you today. */
.bar-wrap {
  position: relative;
}
.bar-wrap .pace-marker {
  position: absolute;
  top: -3px;
  width: 2px;
  height: 13px;
  background: var(--text-3);
  border-radius: 2px;
  opacity: 0.7;
}

/* --- Rows --------------------------------------------------------------- */

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.row:last-child {
  border-bottom: 0;
}
.row:hover {
  background: var(--surface-2);
}
.row.static {
  cursor: default;
}
.row.static:hover {
  background: none;
}

.row .main {
  flex: 1;
  min-width: 0;
}
.row .t {
  font-weight: 550;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row .s {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row .amt {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}
.row .amt.in {
  color: var(--positive);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  font-size: 15px;
  flex: none;
}

/* --- Insights ----------------------------------------------------------- */

.insight {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid transparent;
}
.insight .t {
  font-weight: 650;
  font-size: 14.5px;
  margin-bottom: 3px;
}
.insight .b {
  font-size: 13.5px;
  line-height: 1.5;
  opacity: 0.92;
}
.insight .a {
  font-size: 13px;
  margin-top: 8px;
  font-weight: 550;
  opacity: 0.85;
}
.insight.info {
  background: var(--info-soft);
  border-color: color-mix(in srgb, var(--info) 22%, transparent);
  color: var(--info);
}
.insight.warn {
  background: var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 22%, transparent);
  color: var(--warn);
}
.insight.urgent {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
  color: var(--danger);
}

/* --- Nav ---------------------------------------------------------------- */

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px) saturate(180%);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}

.nav a {
  flex: 1;
  height: var(--nav-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color 0.12s;
}
.nav a .ic {
  font-size: 19px;
  line-height: 1;
}
.nav a.on {
  color: var(--accent);
}

@media (min-width: 900px) {
  .nav {
    position: sticky;
    top: 0;
    bottom: auto;
    max-width: 940px;
    margin: 0 auto 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding-bottom: 0;
  }
  .nav a {
    height: 52px;
    flex-direction: row;
    gap: 7px;
    font-size: 13px;
  }
  .nav a .ic {
    font-size: 15px;
  }
}

/* --- Buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.06s, background 0.12s, opacity 0.12s;
}
.btn:active {
  transform: scale(0.985);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn.ghost {
  border-color: transparent;
  background: var(--surface-2);
}
.btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}
.btn.full {
  width: 100%;
}
.btn.sm {
  padding: 8px 13px;
  font-size: 13.5px;
}

/* --- Forms -------------------------------------------------------------- */

label.field {
  display: block;
  margin-bottom: 14px;
}
label.field > .lbl {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
label.field > .hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 5px;
  line-height: 1.45;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
select,
textarea {
  width: 100%;
  padding: 12px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px prevents iOS zooming on focus */
}
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.seg {
  display: flex;
  gap: 3px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--radius-sm);
}
.seg button {
  flex: 1;
  padding: 9px 6px;
  border: 0;
  background: none;
  border-radius: 7px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
}
.seg button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  flex: none;
}
.switch input {
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.switch .track {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border-radius: 100px;
  pointer-events: none;
  transition: background 0.16s;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.16s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switch input:checked + .track {
  background: var(--accent);
}
.switch input:checked + .track::after {
  transform: translateX(18px);
}

/* --- Sheet (modal) ------------------------------------------------------ */

.sheet-back {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 10, 0.45);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.16s;
}
@media (min-width: 700px) {
  .sheet-back {
    align-items: center;
  }
}

.sheet {
  background: var(--surface);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 22px 20px calc(22px + var(--safe-b));
  animation: up 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
  box-shadow: var(--shadow-lg);
}
@media (min-width: 700px) {
  .sheet {
    border-radius: var(--radius-lg);
    padding-bottom: 22px;
  }
}

.sheet h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 680;
  letter-spacing: -0.015em;
}
.sheet .lead {
  color: var(--text-2);
  font-size: 14px;
  margin: 0 0 18px;
  line-height: 1.5;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}
@keyframes up {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
}

/* --- Derivation (tap the number) ---------------------------------------- */

.deriv {
  border-top: 1px solid var(--border);
}
.deriv-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.deriv-item .top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.deriv-item .l {
  font-size: 14.5px;
  font-weight: 550;
}
.deriv-item .v {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 14.5px;
  white-space: nowrap;
}
.deriv-item .v.pos {
  color: var(--positive);
}
.deriv-item .v.neg {
  color: var(--text-2);
}
.deriv-item .w {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 3px;
  line-height: 1.5;
}
.deriv-total {
  display: flex;
  justify-content: space-between;
  padding: 14px 0 2px;
  font-weight: 700;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

/* --- States ------------------------------------------------------------- */

.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-3);
}
.empty .ic {
  font-size: 34px;
  margin-bottom: 10px;
  opacity: 0.55;
}
.empty .t {
  font-weight: 650;
  color: var(--text-2);
  margin-bottom: 5px;
  font-size: 15px;
}
.empty .b {
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 320px;
  margin: 0 auto;
}

.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.error-box {
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  color: var(--danger);
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.banner {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  color: var(--warn);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
  display: flex;
  gap: 9px;
  align-items: center;
  line-height: 1.45;
}

/* --- Chips & misc ------------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 650;
  background: var(--surface-2);
  color: var(--text-2);
}
.chip.ok {
  background: var(--accent-soft);
  color: var(--accent);
}
.chip.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.chip.danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.chip.pending {
  background: var(--info-soft);
  color: var(--info);
}

.money {
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-3);
}
.small {
  font-size: 13px;
}
.center {
  text-align: center;
}
.stack > * + * {
  margin-top: 10px;
}
.between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

hr.sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* --- Charts ------------------------------------------------------------- */

.spark {
  width: 100%;
  height: 56px;
  display: block;
}
.spark path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.spark path.fill {
  fill: var(--accent-soft);
  stroke: none;
}
.spark path.down {
  stroke: var(--danger);
}

.catbar {
  height: 8px;
  border-radius: 100px;
  background: var(--accent);
  opacity: 0.85;
}

/* --- Coach -------------------------------------------------------------- */

.msg {
  padding: 12px 15px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 14.5px;
  line-height: 1.6;
  max-width: 88%;
  white-space: pre-wrap;
}
.msg.user {
  background: var(--accent);
  color: var(--accent-text);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg.thinking {
  color: var(--text-3);
  font-style: italic;
}

.suggest {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 0 10px;
  scrollbar-width: none;
}
.suggest::-webkit-scrollbar {
  display: none;
}
.suggest button {
  flex: none;
  padding: 8px 13px;
  border-radius: 100px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.suggest button:hover {
  background: var(--surface-2);
  color: var(--text);
}

.composer {
  position: sticky;
  bottom: calc(var(--nav-h) + var(--safe-b));
  background: var(--bg);
  padding: 10px 0;
  display: flex;
  gap: 8px;
}
@media (min-width: 900px) {
  .composer {
    bottom: 0;
  }
}

/* --- Auth --------------------------------------------------------------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth .box {
  width: 100%;
  max-width: 380px;
}
.auth .mark {
  text-align: center;
  margin-bottom: 26px;
}
.auth .mark .n {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.auth .mark .t {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 3px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
