:root {
    --bg: #161213;
    --page: #1d1819;
    --raised: #2b2527;
    --ink: #f2edec;
    --ink2: rgba(242, 237, 236, 0.72);
    --ink3: rgba(242, 237, 236, 0.5);
    --hairline: rgba(242, 237, 236, 0.14);
    --teal: #73a89a;
    --red: #ed313e;
    --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}
#app { max-width: 720px; margin: 0 auto; padding: 16px; }

h1 { font-size: 22px; font-weight: 700; margin: 8px 0 2px; }
h2 { font-size: 17px; font-weight: 700; margin: 0 0 8px; }
.sub { color: var(--ink2); margin: 0 0 16px; font-size: 13px; }
.muted { color: var(--ink3); }
.pos { color: var(--teal); font-weight: 600; }
.neg { color: var(--ink); font-weight: 600; }
.neg.red, .red { color: var(--red); }

button {
    font: inherit; color: var(--ink); background: var(--raised);
    border: 1px solid var(--hairline); border-radius: 6px;
    padding: 8px 14px; cursor: pointer; min-height: 40px;
}
button.primary { background: var(--teal); border-color: var(--teal); color: #161213; font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--red); }
button:disabled { opacity: 0.5; cursor: default; }

input, select, textarea {
    font: inherit; color: var(--ink); background: var(--bg);
    border: 1px solid var(--hairline); border-radius: 6px;
    padding: 8px 10px; min-height: 40px; width: 100%;
}
textarea { min-height: 90px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
label { display: block; font-size: 12px; color: var(--ink2); margin: 10px 0 4px; }

.card {
    background: var(--page); border: 1px solid var(--hairline);
    border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}

.tabs { display: flex; gap: 4px; margin: 14px 0; border-bottom: 1px solid var(--hairline); overflow-x: auto; }
.tabs button {
    background: none; border: none; border-radius: 0; color: var(--ink2);
    padding: 10px 12px; border-bottom: 2px solid transparent;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

/* Calendar */
.cal-head-row, .cal-row { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal {
    border: 1px solid var(--hairline); border-radius: 8px; overflow: hidden;
    overflow-x: auto; margin-top: 8px;
}
.cal-inner { min-width: 460px; }
.cal-cell {
    min-height: 52px; padding: 5px 7px; border-left: 1px solid var(--hairline);
    border-top: 1px solid var(--hairline); cursor: default; font-size: 12px;
    display: flex; flex-direction: column; gap: 1px;
}
.cal-cell:first-child { border-left: none; }
.cal-head-row .cal-cell { min-height: 0; border-top: none; background: var(--raised); color: var(--ink2); font-weight: 600; }
.cal-cell.out { opacity: 0.3; }
.cal-cell.win { background: rgba(115, 168, 154, 0.16); cursor: pointer; }
.cal-cell.loss { background: rgba(237, 49, 62, 0.10); cursor: pointer; }
.cal-cell.win .pnl { color: var(--teal); }
.cal-cell.loss .pnl { color: var(--red); }
.cal-cell.today { outline: 1px solid var(--ink3); outline-offset: -1px; }
.cal-num { color: var(--ink2); }
.cal-month { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-month h2 { margin: 0; }
.cal-month button { min-height: 36px; padding: 4px 12px; }

/* Rows / ledger */
.line {
    display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
    padding: 8px 0; border-bottom: 1px solid var(--hairline);
}
.line:last-child { border-bottom: none; }
.line .detail { color: var(--ink2); font-size: 12px; }
.line .amt { white-space: nowrap; }
.rowform { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.rowform .full { grid-column: 1 / -1; }
.kv { display: flex; justify-content: space-between; padding: 3px 0; }
.kv span:first-child { color: var(--ink2); }
.totals { font-weight: 700; border-top: 1px solid var(--hairline); margin-top: 8px; padding-top: 8px; }
.msg { margin: 8px 0; font-size: 13px; }
.msg.ok { color: var(--teal); }
.msg.err { color: var(--red); }
.entry-del { padding: 2px 8px; min-height: 28px; font-size: 12px; }

@media (max-width: 520px) {
    .rowform { grid-template-columns: 1fr; }
    .tabs button { padding: 8px 7px; font-size: 13px; white-space: nowrap; }
}
