/* Advancor — light fintech look, teal brand.
   Layout: one phone-width app column, centred on larger screens, bottom tab bar. */
:root {
  --bg: #F3F7F6;
  --card: #FFFFFF;
  --soft: #E8F2EF;
  --line: #DCE8E4;
  --ink: #0E2A2F;
  --muted: #5E7976;
  --brand: #1FA393;
  --brand-deep: #0B4F5C;
  --brand-ink: #FFFFFF;
  --mint: #BFEFE7;
  --amber: #E0A230;
  --amber-soft: #FFF3DA;
  --red: #D9534F;
  --red-soft: #FDE8E7;
  --green-soft: #DDF5EF;
  --shadow: 0 1px 2px rgba(14,42,47,.05), 0 10px 30px rgba(14,42,47,.07);
  --radius: 20px;
  --display: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 560px) {
  body { background: radial-gradient(1200px 600px at 20% -10%, #D5EEE8 0%, transparent 60%), var(--bg); }
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  position: relative;
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}
.boot { display: grid; place-items: center; gap: 12px; padding-top: 30vh; color: var(--muted); }
.logo-mark {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-deep), var(--brand));
  color: #fff; display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 22px;
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 12px;
  background: rgba(243,247,246,.92);
  backdrop-filter: saturate(140%) blur(12px);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar h1 { font-family: var(--display); font-size: 22px; margin: 0; letter-spacing: -.01em; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; border: 0;
  background: var(--soft); color: var(--brand-deep);
  font-weight: 600; display: grid; place-items: center;
}

.page { padding: 4px 16px 24px; display: grid; gap: 14px; }
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 10px 2px -2px;
}
.section-title h2 { font-family: var(--display); font-size: 17px; margin: 0; font-weight: 600; }
.section-title .link { color: var(--brand); font-weight: 600; font-size: 13px; background: none; border: 0; padding: 0; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
  min-width: 0;
}
.card h3 { margin: 0; font-family: var(--display); font-size: 16px; font-weight: 600; }
.card .card-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }

/* Hero */
.hero {
  border-radius: 24px; padding: 20px; color: #fff;
  background:
    radial-gradient(400px 200px at 110% -20%, rgba(191,239,231,.35), transparent 60%),
    linear-gradient(145deg, #0B4F5C 0%, #11706F 55%, #1FA393 100%);
  box-shadow: 0 18px 40px rgba(11,79,92,.28);
  position: relative; overflow: hidden;
}
.hero .label { font-size: 13px; opacity: .85; }
.hero .amount { font-family: var(--display); font-size: 38px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hero .meta { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; opacity: .92; flex-wrap: wrap; }
.hero .meta b { font-weight: 600; }
.hero svg { display: block; width: 100%; height: 56px; margin-top: 12px; }
.hero .delta { display: inline-flex; align-items: center; gap: 4px; background: rgba(255,255,255,.16); padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.stat { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 12px; border: 0; text-align: left; min-width: 0; }
.stat .k { color: var(--muted); font-size: 11.5px; font-weight: 500; }
.stat .v { font-family: var(--display); font-weight: 600; font-size: 18px; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.warn .v { color: var(--amber); }

/* Segmented control */
.seg { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--brand-deep); box-shadow: 0 1px 3px rgba(14,42,47,.12); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--card); padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.chip.on { background: var(--brand-deep); border-color: var(--brand-deep); color: #fff; }

/* Charts */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--body); font-size: 10.5px; fill: var(--muted); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bar-anim { transform-box: fill-box; transform-origin: bottom; animation: rise .7s cubic-bezier(.2,.8,.2,1) both; }
.line-anim { stroke-dasharray: 2000; animation: draw 1.2s ease-out both; }
@keyframes rise { from { transform: scaleY(.02); } to { transform: scaleY(1); } }
@keyframes draw { from { stroke-dashoffset: 2000; } to { stroke-dashoffset: 0; } }
@keyframes grow { from { transform: scaleX(.02); } to { transform: scaleX(1); } }

/* Lists */
.list { display: grid; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 12px 2px;
  border: 0; border-bottom: 1px solid var(--line); background: none; width: 100%; text-align: left;
}
.row:last-child { border-bottom: 0; }
.row .ic {
  width: 42px; height: 42px; border-radius: 13px; background: var(--soft); color: var(--brand-deep);
  display: grid; place-items: center; flex: none; font-family: var(--display); font-weight: 600; font-size: 13px; line-height: 1.05; text-align: center;
}
.row .ic small { display: block; font-size: 10px; font-weight: 500; color: var(--muted); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r { text-align: right; flex: none; }
.row .r .amt { font-weight: 600; font-variant-numeric: tabular-nums; }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-top: 3px; }
.pill.confirmed, .pill.paid { background: var(--green-soft); color: #0F7B67; }
.pill.unreviewed, .pill.sent { background: var(--amber-soft); color: #9A6A0D; }
.pill.cancelled { background: #EEF2F1; color: var(--muted); }
.pill.draft { background: var(--soft); color: var(--brand-deep); }
.pill.overdue { background: var(--red-soft); color: var(--red); }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; font-size: 14px; }
.warn-line { color: #9A6A0D; background: var(--amber-soft); border-radius: 12px; padding: 8px 10px; font-size: 13px; }

/* Calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head b { font-family: var(--display); font-size: 16px; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--soft); color: var(--brand-deep); display: grid; place-items: center; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal .dow { font-size: 11px; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.cal .d { aspect-ratio: 1; border-radius: 12px; border: 0; background: none; font-size: 13.5px; display: grid; place-items: center; position: relative; font-variant-numeric: tabular-nums; }
.cal .d.out { color: #B5C6C3; }
.cal .d.today { box-shadow: inset 0 0 0 1.5px var(--brand); font-weight: 600; }
.cal .d.sel { background: var(--brand-deep); color: #fff; }
.cal .dots { position: absolute; bottom: 5px; left: 0; right: 0; display: flex; justify-content: center; gap: 3px; }
.cal .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--brand); }
.cal .dots i.u { background: var(--amber); }
.cal .dots i.c { background: #B5C6C3; }
.cal .d.sel .dots i { background: #fff; }

/* Take-home waterfall */
.wf { display: grid; gap: 10px; margin-top: 6px; }
.wf-row { display: grid; grid-template-columns: 128px 1fr 72px; gap: 10px; align-items: center; font-size: 13.5px; }
.wf-track { height: 22px; position: relative; background: #F1F6F5; border-radius: 7px; overflow: hidden; }
.wf-bar { position: absolute; top: 0; bottom: 0; border-radius: 7px; transform-origin: left; animation: grow .8s cubic-bezier(.2,.8,.2,1) both; }
.wf-row .val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.wf-row.total { border-top: 1px dashed var(--line); padding-top: 10px; font-weight: 600; }
.big-num { font-family: var(--display); font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.big-num small { font-family: var(--body); font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 6px; letter-spacing: 0; }
.note { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 12px; }
.note b { color: var(--brand-deep); }
.inline-input { width: 56px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px; text-align: center; background: #fff; }

/* Horizontal bars */
.hbars { display: grid; gap: 12px; }
.hbar .top { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.hbar .top .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hbar .top .val { font-weight: 600; font-variant-numeric: tabular-nums; flex: none; }
.hbar .track { height: 9px; background: #EEF4F3; border-radius: 99px; margin-top: 6px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand-deep), var(--brand)); transform-origin: left; animation: grow .9s cubic-bezier(.2,.8,.2,1) both; }
.hbar .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.rate-good { color: #0F7B67; font-weight: 600; }

/* Heatmap */
.heat { display: grid; grid-template-columns: 16px repeat(13, 1fr); gap: 4px; font-size: 10px; color: var(--muted); align-items: center; }
.heat .c { aspect-ratio: 1; border-radius: 4px; background: #EEF4F3; }
.heat .l1 { background: #BDE7DE; } .heat .l2 { background: #6CCBBB; } .heat .l3 { background: #1FA393; } .heat .l4 { background: #0B4F5C; }

/* Progress */
.progress { height: 10px; background: #EEF4F3; border-radius: 99px; overflow: hidden; margin: 8px 0 6px; }
.progress span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand), var(--brand-deep)); transform-origin: left; animation: grow .9s both; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini { background: #F6FAF9; border-radius: 14px; padding: 12px; }
.mini .k { font-size: 12px; color: var(--muted); }
.mini .v { font-family: var(--display); font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Buttons */
.btn { border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 600; background: var(--brand-deep); color: #fff; width: 100%; font-size: 15px; }
.btn.secondary { background: var(--soft); color: var(--brand-deep); }
.btn.danger { background: var(--red-soft); color: var(--red); }
.btn.small { width: auto; padding: 8px 12px; font-size: 13px; border-radius: 11px; }
.btn:disabled { opacity: .5; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.fab {
  position: fixed; z-index: 25;
  right: max(18px, calc(50% - 240px + 18px));
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  border: 0; border-radius: 18px; padding: 14px 18px; font-weight: 600;
  background: linear-gradient(135deg, var(--brand-deep), var(--brand)); color: #fff;
  box-shadow: 0 12px 28px rgba(11,79,92,.35); display: flex; align-items: center; gap: 8px;
}

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  padding: 8px max(10px, env(safe-area-inset-left, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-right, 0px));
  background: rgba(255,255,255,.94); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar nav { max-width: 480px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tab { border: 0; background: none; display: grid; justify-items: center; gap: 3px; padding: 6px 0; color: #8AA19E; font-size: 11.5px; font-weight: 600; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--brand-deep); }
.tab.on .tab-ic { background: var(--green-soft); }
.tab-ic { padding: 3px 14px; border-radius: 999px; display: grid; place-items: center; transition: background .2s; }

/* Sheet (bottom modal) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(14,42,47,.38); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s both; }
.sheet {
  background: var(--bg); width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto;
  border-radius: 26px 26px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  animation: up .28s cubic-bezier(.2,.8,.2,1) both;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: #C9D8D5; margin: 0 auto 12px; }
.sheet h2 { font-family: var(--display); font-size: 20px; margin: 0 0 12px; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.form { display: grid; gap: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin: 0 0 5px 2px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 13px; border-radius: 13px; border: 1px solid var(--line); background: #fff; font-size: 15.5px;
}
.field textarea { min-height: 70px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.calc { display: flex; justify-content: space-between; background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 14px; }
.calc b { font-family: var(--display); font-size: 18px; }
.status-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.status-pick button { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 4px; font-weight: 600; font-size: 13px; color: var(--muted); }
.status-pick button.on { border-color: var(--brand-deep); background: var(--brand-deep); color: #fff; }
.inline-action { display: flex; gap: 8px; align-items: flex-end; }
.inline-action .field { flex: 1; }

/* Login */
.login { padding: calc(56px + env(safe-area-inset-top, 0px)) 22px 40px; display: grid; gap: 22px; }
.login .brand { display: flex; align-items: center; gap: 12px; }
.login .brand b { font-family: var(--display); font-size: 24px; }
.login h1 { font-family: var(--display); font-size: 30px; line-height: 1.15; margin: 0; letter-spacing: -.02em; text-wrap: balance; }
.login p { color: var(--muted); margin: 0; }
.perks { display: grid; gap: 10px; }
.perk { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); font-size: 14px; }
.perk .ic { width: 34px; height: 34px; border-radius: 10px; background: var(--green-soft); color: var(--brand-deep); display: grid; place-items: center; flex: none; }
.demo-banner { background: var(--amber-soft); color: #7A5508; font-size: 12.5px; text-align: center; padding: 8px 12px; }
.demo-banner button { border: 0; background: none; color: #7A5508; font-weight: 700; text-decoration: underline; padding: 0; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60;
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: calc(100% - 32px);
}

/* Invoice print view */
.invoice-doc { background: #fff; border-radius: 16px; padding: 18px; box-shadow: var(--shadow); font-size: 13.5px; }
.invoice-doc table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.invoice-doc th, .invoice-doc td { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.invoice-doc td.n, .invoice-doc th.n { text-align: right; }
.invoice-doc .tot { font-family: var(--display); font-size: 18px; font-weight: 700; text-align: right; margin-top: 10px; }
@media print {
  body * { visibility: hidden; }
  .invoice-doc, .invoice-doc * { visibility: visible; }
  .invoice-doc { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 360px) { .wf-row { grid-template-columns: 90px 1fr 66px; } .stats { gap: 8px; } }

/* Chart readout + tap targets */
.readout { font-size: 12.5px; color: var(--muted); min-height: 18px; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.readout.live { color: var(--brand-deep); font-weight: 600; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover, .chart .hit.on { fill: rgba(31,163,147,.09); }
.heat .c { cursor: pointer; }
.heat .c.on { outline: 2px solid var(--ink); outline-offset: 1px; }
.card.row { padding: 14px 16px; border-bottom: 0; }
.list { grid-template-columns: minmax(0, 1fr); }
.row { min-width: 0; }
.wf-row > div:first-child { white-space: nowrap; }
.wf-row .inline-input { width: 44px; padding: 3px 4px; margin-left: 4px; }
