:root {
  --bg: #F2F4F3;
  --card: #FFFFFF;
  --ink: #111814;
  --ink-2: #33403A;
  --line: #D9DEDB;
  --brand: #0F3D2E;
  --brand-2: #1A6B4F;
  --buy: #127A45;
  --sell: #B3261E;
  --warn-bg: #FFF4CC;
  --warn-ink: #5C4400;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; color: var(--ink); }
h2 { font-size: 17px; font-weight: 800; margin-bottom: 10px; }

.paper-banner {
  position: sticky; top: 0; z-index: 10;
  background: var(--warn-bg); color: var(--warn-ink);
  font-weight: 800; font-size: 13px; text-align: center;
  padding: calc(6px + env(safe-area-inset-top)) 16px 6px;
  border-bottom: 2px solid #E8C94A;
}

.screen { min-height: 80vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card h1 { font-size: 26px; margin-bottom: 6px; }
.login-card input { text-align: center; font-size: 24px; letter-spacing: 6px; margin: 12px 0; }

#app { max-width: 720px; margin: 0 auto; padding: 0 16px calc(90px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 10px; }
.topbar h1 { font-size: 22px; font-weight: 900; }
.status { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #E3E8E5; color: var(--ink); }
.pill.good { background: #D5F0E1; color: #0B5530; }
.pill.bad { background: #FBDAD7; color: #8A1A13; }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; border: 1px solid var(--line); }
.help { font-size: 14px; color: var(--ink-2); margin: 8px 0 0; }
.error { color: var(--sell); font-weight: 700; }
.ok { color: var(--buy); font-weight: 700; }

input, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
input:focus, textarea:focus { outline: none; border-color: var(--brand-2); }
label { display: block; font-weight: 700; margin-bottom: 10px; }
label input { margin-top: 4px; font-weight: 400; }
.switch-row { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.switch-row input { width: 24px; height: 24px; margin: 0; }

button { font: inherit; cursor: pointer; border: none; border-radius: 10px; padding: 10px 16px; font-weight: 700; }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--brand); color: #fff; }
.wide { width: 100%; padding: 14px; font-size: 17px; }
.link { background: none; color: var(--brand-2); padding: 10px 0; text-decoration: underline; }
.approve { background: var(--buy); color: #fff; flex: 1; padding: 12px; }
.reject { background: #fff; color: var(--sell); border: 2px solid var(--sell); flex: 1; padding: 12px; }

/* chat */
.messages { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.msg { max-width: 92%; padding: 11px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .tools { display: block; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.msg.thinking { color: var(--ink-2); font-style: italic; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); background: var(--bg); padding: 8px 0; }
.chat-form textarea { resize: none; max-height: 140px; }
.empty { text-align: center; color: var(--ink-2); padding: 30px 10px; }
.empty b { color: var(--ink); }

/* proposals */
.prop-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.prop-title { font-size: 19px; font-weight: 900; }
.prop-title.buy { color: var(--buy); }
.prop-title.sell { color: var(--sell); }
.tag { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 6px; background: #E3E8E5; text-transform: uppercase; }
.tag.pending { background: var(--warn-bg); color: var(--warn-ink); }
.tag.filled { background: #D5F0E1; color: #0B5530; }
.tag.rejected, .tag.expired { background: #ECECEC; color: #444; }
.tag.open { background: #DCE8FB; color: #18407F; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; font-size: 15px; }
.facts dt { font-weight: 700; }
.facts dd { margin: 0; }
.reason { background: #F6F8F7; border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.note { font-size: 14px; font-weight: 700; color: var(--warn-ink); margin: 6px 0; }
.actions { display: flex; gap: 10px; margin-top: 10px; }

/* portfolio */
.big { font-size: 30px; font-weight: 900; }
.pnl.up { color: var(--buy); } .pnl.down { color: var(--sell); }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: none; }
.row b { font-size: 17px; }
.right { text-align: right; }

/* tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button { flex: 1; background: none; border-radius: 0; padding: 14px 4px; color: var(--ink-2); font-size: 15px; }
.tabs button.active { color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }
.badge { display: inline-block; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--sell); color: #fff; font-size: 12px; }
.msg.assistant { white-space: normal; }
.msg.assistant p { margin: 0 0 8px; }
.msg.assistant p:last-child, .msg.assistant ul:last-child { margin-bottom: 0; }
.msg.assistant ul { margin: 0 0 8px; padding-left: 20px; }
.msg.assistant .link { display: block; padding: 6px 0 0; }
