/* TouchPoint Investors — layout follows Apple's account/settings pages:
   large titles, inset-grouped lists, translucent bar, system type. */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --fill: rgba(118, 118, 128, 0.12);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --sep: rgba(60, 60, 67, 0.14);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --green: #1d8b3c;
  --red: #d70015;
  --orange: #b25000;
  --bar: rgba(255, 255, 255, 0.72);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 24px rgba(0, 0, 0, 0.04);
  --radius: 18px;
  --radius-sm: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --fill: rgba(118, 118, 128, 0.24);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #86868b;
    --sep: rgba(84, 84, 88, 0.6);
    --accent: #2997ff;
    --accent-hover: #47a6ff;
    --accent-soft: rgba(41, 151, 255, 0.16);
    --green: #30d158;
    --red: #ff453a;
    --orange: #ff9f0a;
    --bar: rgba(22, 22, 23, 0.72);
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; border-radius: 8px; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- boot / spinner ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--fill); border-top-color: var(--text-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- sign in ---------- */
.auth {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px max(20px, env(safe-area-inset-left)) 48px max(20px, env(safe-area-inset-right));
}
.auth-mark { width: 64px; height: 64px; margin-bottom: 24px; }
.auth h1 { font-size: 40px; line-height: 1.1; font-weight: 600; letter-spacing: -0.015em; margin: 0 0 8px; text-align: center; }
.auth .lede { color: var(--text-2); font-size: 19px; margin: 0 0 36px; text-align: center; max-width: 420px; }
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.field-float { position: relative; }
.field-float input {
  width: 100%; height: 56px; padding: 22px 16px 6px; border-radius: var(--radius-sm);
  border: 1px solid var(--sep); background: var(--surface); outline: none; font-size: 17px;
}
.field-float label { position: absolute; left: 17px; top: 17px; color: var(--text-3); pointer-events: none; transition: all .15s ease; }
.field-float input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field-float input:focus + label, .field-float input:not(:placeholder-shown) + label { top: 7px; font-size: 12px; }
.code-input { text-align: center; font-size: 28px !important; letter-spacing: .5em; padding: 10px 16px !important; font-variant-numeric: tabular-nums; }
.auth .fine { color: var(--text-3); font-size: 13px; text-align: center; margin-top: 8px; }
.auth .sent-to { text-align: center; color: var(--text-2); margin: -16px 0 18px; }
.auth .sent-to strong { color: var(--text); font-weight: 600; }
.linkish { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 6px; font-size: 15px; }
.linkish:hover { text-decoration: underline; }
.auth-links { display: flex; justify-content: center; gap: 12px; }
.form-error { color: var(--red); font-size: 14px; text-align: center; min-height: 20px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 22px; border-radius: 980px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 400; white-space: nowrap;
  transition: background .15s ease, opacity .15s ease;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.block { width: 100%; height: 50px; border-radius: var(--radius-sm); }
.btn.secondary { background: var(--fill); color: var(--text); }
.btn.secondary:hover { background: var(--sep); }
.btn.danger { background: var(--red); }
.btn.small { height: 34px; padding: 0 16px; font-size: 15px; }
.btn.ghost { background: transparent; color: var(--accent); padding: 0 10px; }
.btn.ghost:hover { background: var(--accent-soft); }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--sep);
  padding-top: env(safe-area-inset-top);
}
.bar-inner {
  max-width: 1080px; margin: 0 auto; height: 52px; display: flex; align-items: center; gap: 16px;
  padding: 0 max(20px, env(safe-area-inset-left)) 0 max(20px, env(safe-area-inset-right));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 24px; height: 24px; }
.nav { display: flex; gap: 2px; margin-left: 18px; }
.nav a {
  color: var(--text-2); font-size: 14px; padding: 6px 12px; border-radius: 980px;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--fill); }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.account-select {
  appearance: none; -webkit-appearance: none; border: 0; background: var(--fill); border-radius: 980px;
  height: 32px; padding: 0 30px 0 14px; font-size: 14px; max-width: 240px; text-overflow: ellipsis; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2386868b' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(180deg, #a1a1a6, #6e6e73); color: #fff; font-size: 13px; font-weight: 600;
  display: grid; place-items: center; flex: none;
}
.menu {
  position: absolute; right: max(20px, env(safe-area-inset-right)); top: calc(52px + env(safe-area-inset-top));
  background: var(--surface); border-radius: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.18); border: 1px solid var(--sep);
  min-width: 240px; padding: 6px; z-index: 30;
}
.menu .who { padding: 10px 12px; color: var(--text-2); font-size: 13px; border-bottom: 1px solid var(--sep); margin-bottom: 4px; word-break: break-all; }
.menu button { width: 100%; text-align: left; background: none; border: 0; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.menu button:hover { background: var(--fill); }

/* mobile tab bar */
.tabbar { display: none; }
@media (max-width: 760px) {
  .nav { display: none; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--sep); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--text-3); padding: 4px 0; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--accent); }
  .tabbar svg { width: 24px; height: 24px; }
  main { padding-bottom: 96px !important; }
  .account-select { max-width: 150px; }
}

/* ---------- page ---------- */
main {
  max-width: 1080px; margin: 0 auto;
  padding: 40px max(20px, env(safe-area-inset-left)) 80px max(20px, env(safe-area-inset-right));
}
.eyebrow { color: var(--text-2); font-size: 14px; font-weight: 600; margin: 0 0 6px; }
.title { font-size: 40px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 8px; text-wrap: balance; }
.subtitle { color: var(--text-2); font-size: 19px; margin: 0 0 32px; }
@media (max-width: 760px) { .title { font-size: 32px; } .subtitle { font-size: 17px; } main { padding-top: 24px; } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 40px 0 12px; }
.section-head h2 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.section-head .aside { color: var(--text-2); font-size: 15px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; min-width: 0; }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; min-width: 0; }
.stat .k { color: var(--text-2); font-size: 14px; margin-bottom: 6px; }
.stat .v { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .s { color: var(--text-3); font-size: 13px; margin-top: 4px; }
.stat.hero { grid-column: span 2; }
.stat.hero .v { font-size: 44px; }
@media (max-width: 520px) { .stat.hero .v { font-size: 34px; } .stat .v { font-size: 24px; } }

/* chart */
.chart-wrap { overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; }
@media (max-width: 520px) { .chart.card { padding: 16px 10px; } .chart.card .lbl, .chart.card .val { font-size: 22px; } }
.chart .bar-rect { fill: var(--accent); }
.chart .bar-rect.latest { fill: var(--accent); }
.chart .bar-rect.past { fill: var(--accent); opacity: .35; }
.chart .grid { stroke: var(--sep); stroke-width: 1; }
.chart .lbl { fill: var(--text-3); font-size: 12px; font-family: var(--font); }
.chart .val { fill: var(--text-2); font-size: 12px; font-weight: 600; font-family: var(--font); }

/* inset grouped list */
.group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.group + .group-label { margin-top: 28px; }
.group-label { display: flex; justify-content: space-between; align-items: baseline; color: var(--text-2); font-size: 13px; text-transform: uppercase; letter-spacing: .02em; padding: 0 20px 8px; margin-top: 28px; }
.group-label:first-child { margin-top: 0; }
.group-label .num { text-transform: none; }
.group-foot { color: var(--text-3); font-size: 13px; padding: 8px 20px 0; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; min-height: 56px; position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 20px; right: 0; border-top: 1px solid var(--sep); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-size: 17px; overflow-wrap: anywhere; }
.row .d { color: var(--text-2); font-size: 14px; }
.row .amt { font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.row .amt.pos { color: var(--green); }
.row .key { color: var(--text); width: 42%; flex: none; }
.row .val { color: var(--text-2); text-align: right; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row.clickable { cursor: pointer; }
.row.clickable:hover { background: var(--surface-2); }
.chev { color: var(--text-3); flex: none; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 980px; background: var(--fill); color: var(--text-2); margin-left: 6px; vertical-align: 2px; }
.pill.warn { background: rgba(255, 159, 10, .16); color: var(--orange); }
.doc-icon { width: 36px; height: 44px; flex: none; }
.doc-actions { display: flex; gap: 6px; flex: none; }

.empty { text-align: center; padding: 48px 24px; color: var(--text-2); }
.empty h3 { color: var(--text); font-size: 20px; margin: 0 0 6px; font-weight: 600; }
.empty p { margin: 0 auto; max-width: 420px; }

/* ---------- admin ---------- */
.seg { display: inline-flex; background: var(--fill); border-radius: 10px; padding: 2px; gap: 2px; margin-bottom: 24px; flex-wrap: wrap; }
.seg a { padding: 6px 16px; border-radius: 8px; font-size: 14px; color: var(--text); }
.seg a:hover { text-decoration: none; }
.seg a.active { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); font-weight: 500; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .meta { color: var(--text-2); font-size: 15px; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; color: var(--text-2); font-weight: 500; font-size: 13px; padding: 12px 16px; border-bottom: 1px solid var(--sep); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--sep); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--surface-2); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .sub { color: var(--text-3); font-size: 13px; overflow-wrap: anywhere; }
td.note { color: var(--orange); font-size: 13px; }
tfoot td { font-weight: 600; border-top: 1px solid var(--sep); }
.warn-text { color: var(--orange); }

/* sheet (modal) */
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.sheet { background: var(--surface); border-radius: 22px; width: 100%; max-width: 640px; box-shadow: 0 20px 70px rgba(0,0,0,.3); }
.sheet.wide { max-width: 820px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--sep); }
.sheet-head h3 { margin: 0; font-size: 19px; font-weight: 600; }
.sheet-body { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.sheet-foot { display: flex; justify-content: space-between; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--sep); flex-wrap: wrap; }
.sheet-foot .right { display: flex; gap: 10px; margin-left: auto; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 560px) { .fields { grid-template-columns: 1fr; } }
.f { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.f.full { grid-column: 1 / -1; }
.f label { font-size: 13px; color: var(--text-2); }
.f input, .f select, .f textarea, .cell-input {
  border: 1px solid var(--sep); background: var(--surface); border-radius: 10px; padding: 10px 12px; font-size: 16px; outline: none; width: 100%;
}
.f textarea { min-height: 72px; resize: vertical; }
.f input:focus, .f select:focus, .f textarea:focus, .cell-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.f .hint { font-size: 12px; color: var(--text-3); }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.cell-input { padding: 6px 10px; text-align: right; font-variant-numeric: tabular-nums; max-width: 150px; margin-left: auto; display: block; }
select.cell-input { text-align: left; max-width: 100%; }
.alloc-table td { vertical-align: middle; }
.sum-line { display: flex; justify-content: space-between; font-weight: 600; font-size: 17px; padding: 4px 2px; }
.drop {
  border: 2px dashed var(--sep); border-radius: var(--radius); padding: 32px; text-align: center; color: var(--text-2); cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { color: var(--text); display: block; font-size: 17px; margin-bottom: 4px; }
.status-ok { color: var(--green); }
.status-err { color: var(--red); }
.audit td { font-size: 13px; }
.audit code { font-size: 12px; color: var(--text-2); word-break: break-all; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: rgba(29, 29, 31, .92); color: #fff; padding: 12px 20px; border-radius: 980px; font-size: 15px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); max-width: calc(100vw - 40px);
}
.toast.err { background: var(--red); }
@media (max-width: 760px) { .toast { bottom: calc(92px + env(safe-area-inset-bottom)); } }

footer.foot { max-width: 1080px; margin: 0 auto; padding: 0 max(20px, env(safe-area-inset-left)) 40px; color: var(--text-3); font-size: 12px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.card + .card { margin-top: 16px; }
.card.warn-text { background: rgba(255, 159, 10, .12); box-shadow: none; }
