:root {
  --bg: #0f1115;
  --panel: #171a21;
  --line: #262b36;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --accent: #4ade80;
  --neg: #f87171;
  --chip: #1f2430;
  --a-stock: #4ade80;
  --a-liquid: #60a5fa;
  --a-other: #fbbf24;
}
* { box-sizing: border-box; }
body {
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 0 20px 40px;
  max-width: 1340px;
}
.layout { display: flex; gap: 20px; align-items: flex-start; }
.main { flex: 1; min-width: 0; }
.chat {
  width: 340px; flex-shrink: 0;
  position: sticky; top: 16px;
  height: 540px;
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
.chat-head { padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 14px; display: flex; gap: 8px; align-items: center; text-transform: uppercase; letter-spacing: 1.5px; font-family: "Cinzel", Georgia, serif; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-quote { display: flex; align-items: center; gap: 8px; margin: 0 12px 8px; padding: 7px 10px; border-left: 3px solid var(--accent); background: var(--chip); border-radius: 0 8px 8px 0; font-size: 12px; }
.chat-quote[hidden] { display: none; }
.chat-quote .cq-text { flex: 1; min-width: 0; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-quote .cq-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 11px; padding: 0; }
.msg { padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; max-width: 92%; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #08130c; }
.msg.ai { align-self: flex-start; background: var(--chip); }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; background: var(--chip); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.chat-form button { background: var(--accent); color: #08130c; border: none; border-radius: 10px; padding: 0 14px; font-weight: 700; cursor: pointer; }
@media (max-width: 900px) { .layout { flex-direction: column; } .chat { width: 100%; height: 400px; position: static; } }
header { display: flex; align-items: center; gap: 10px; padding: 24px 0 8px; }
header h1 {
  margin: 0;
  font-family: "Cinzel", "Playfair Display", Georgia, "Times New Roman", serif;
  font-size: 30px; font-weight: 700; letter-spacing: 1.5px;
  background: linear-gradient(180deg, #fdfdfd 0%, #cdd3df 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
header .crown { width: 30px; height: 24px; margin-bottom: 6px; filter: drop-shadow(0 1px 2px rgba(233,185,73,0.35)); }
header .sub { color: var(--muted); font-size: 13px; margin-left: 6px; }

.hero-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 14px; margin: 12px 0 20px; }
.hcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; }
.label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.value-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 5px 0; }
.value { font-size: 36px; font-weight: 700; }
.value-usd { font-size: 16px; font-weight: 600; color: var(--muted); }
.box-value { font-size: 27px; font-weight: 700; display: block; margin: 5px 0; }
.today-inline { display: flex; align-items: baseline; gap: 8px; margin-top: 4px; }
.today-inline .today-val { font-size: 18px; font-weight: 700; }
.card-updated { color: #79828f; font-size: 10px; font-weight: 600; letter-spacing: 1.4px; margin-top: auto; padding-top: 14px; text-transform: uppercase; font-family: "Cinzel", Georgia, serif; }
.stock-page-updated { margin: 0 0 14px; }
@media (max-width: 780px) { .hero-row { grid-template-columns: 1fr; } }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  background: none; border: none; color: var(--muted);
  padding: 10px 14px; cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.panel { display: none; }
.panel.active { display: block; }

.row-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.row-form input, .row-form select {
  background: var(--chip); border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font-size: 13px;
}
.row-form label { color: var(--muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.row-form button {
  background: var(--accent); color: #0b1a10; border: none; font-weight: 600;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
.cols { display: flex; gap: 20px; align-items: flex-start; }
.cols #by-category { max-width: 280px; }
.pos { color: var(--accent); }
.neg { color: var(--neg); }
.note { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.muted { color: var(--muted); }
td select { background: var(--chip); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 4px; }
td input.bal { background: var(--chip); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 5px 8px; width: 120px; }
.filter-row { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.filter-row label { color: var(--muted); font-size: 11px; display: flex; gap: 5px; align-items: center; text-transform: uppercase; letter-spacing: 0.5px; }
.filter-row select { background: var(--chip); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 3px 7px; font-size: 12px; }
.tag { background: var(--chip); color: var(--accent); font-size: 10px; padding: 1px 6px; border-radius: 6px; vertical-align: middle; }
button.x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; }
button.x:hover { color: var(--neg); }

/* inline double-click editing */
td.editable { cursor: text; }
td.editable:hover { text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.edit { background: var(--chip); border: 1px solid var(--accent); color: var(--text); border-radius: 6px; padding: 4px 6px; width: 130px; font-size: 13px; }

/* swipe-a-row-right to ask the assistant */
tr[data-ctx] { transition: transform .12s, background .12s; touch-action: pan-y; }
tr[data-ctx].swiped { transform: translateX(10px); }
tr[data-ctx].selected { background: rgba(74,222,128,0.12); box-shadow: inset 3px 0 0 var(--accent); }

/* Assets overview */
.assets-total { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.assets-total .k { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: 1px; }
.assets-total .v { font-size: 30px; font-weight: 700; }
.asset-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--chip); margin-bottom: 22px; }
.asset-bar span { display: block; height: 100%; }
.asset-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.asset-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.ac-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.ac-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.ac-name { color: var(--muted); font-size: 13px; }
.ac-val { margin-left: auto; font-size: 18px; font-weight: 600; }
.ac-list div { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; border-top: 1px solid var(--line); }
.ac-list .empty { color: var(--muted); border: none; }
.ac-list .more { color: var(--muted); font-size: 12px; cursor: pointer; justify-content: flex-start; }
.ac-list .more:hover { color: var(--text); }

/* IOU date column: keep the date on one line */
#ious th:nth-child(4), #ious td:nth-child(4) { white-space: nowrap; min-width: 100px; }

/* Daily summaries */
.day-toggle { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.day-tab { background: var(--chip); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 7px 12px; font-size: 12px; cursor: pointer; }
.day-tab.active { color: #08130c; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.day-stats { display: flex; gap: 30px; margin-bottom: 18px; flex-wrap: wrap; }
.day-stats > div { display: flex; flex-direction: column; }
.day-stats .k { color: var(--muted); font-size: 12px; }
.day-stats .v { font-size: 22px; font-weight: 700; margin-top: 3px; }
.day-stats .sub-note { color: var(--muted); font-size: 11px; }
.day-breakdowns { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.day-bd { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; min-width: 210px; }
.day-bd .bd-h { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.day-bd .r { display: flex; justify-content: space-between; gap: 24px; font-size: 13px; padding: 3px 0; }
.more-tab { font-style: italic; }
/* Daily calendar ("More…") */
.cal-head { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 14px; }
.cal-title { font-family: "Cinzel", Georgia, serif; font-size: 16px; font-weight: 700; letter-spacing: 0.5px; min-width: 170px; text-align: center; }
.cal-nav { background: var(--chip); border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 16px; line-height: 1; }
.cal-nav:hover { border-color: var(--accent); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; text-align: center; padding-bottom: 4px; }
.cal-cell { min-height: 56px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 3px; background: var(--panel); }
.cal-cell.empty { border: none; background: none; }
.cal-cell .cal-day { color: var(--muted); font-size: 12px; }
.cal-cell.has { cursor: pointer; background: var(--chip); }
.cal-cell.has:hover { border-color: var(--accent); }
.cal-net { font-size: 12px; font-weight: 600; }
.cal-dayhead { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.cal-daytitle { font-family: "Cinzel", Georgia, serif; font-size: 16px; font-weight: 700; }
.cal-back { background: var(--chip); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 5px 10px; font-size: 12px; cursor: pointer; }
.cal-back:hover { border-color: var(--accent); }
@media (max-width: 700px) { .asset-cards { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .cols { flex-direction: column; } .cols #by-category { max-width: none; } }
