/* Hallmark · shape: app screen · genre: playful · theme: Hum palette on Be Vietnam Pro, by request (deal manual, after Coral monochrome)
 * nav: top bar, wordmark, three tabs and one action · signature: the net-worth card on the one pear field, each asset type wearing its own colour · states: loading, empty, error, full
 * axes: light/grotesk-sans/chromatic-yellow · posture: full-palette · contrast: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H4 E4 S4 R4 V4 · weakest: S, the sheet carries the only stock surface; tables stay flat paper so density reads first */
/* Hallmark · answered F4: .btn--card is Coral's letterpress secondary (cotton stock, no fill colour); .btn--ink is the one primary per screen */
@import url("./tokens.css");
@import url("./base.css");
@import url("./fonts.css");

:root {
  /* màu sắc khai báo ở khối Hum cuối file; ở đây chỉ còn font, kích thước và các giá trị không phải màu */
  --color-desk: var(--color-paper); --color-print: var(--color-ink);
  --color-error: var(--color-loss); --color-success: var(--color-gain);
  --shade: 22% 0.03 258; --lit: 99% 0.005 95; --deep: 22% 0.03 258;
  --tex-cotton: none; --tex-desk: none;
  --font-display: "Be Vietnam Pro", ui-sans-serif, system-ui, sans-serif; --font-body: var(--font-display);
  --font-outlier: "Inter Figures", "Be Vietnam Pro", ui-sans-serif, system-ui, sans-serif;
  --control-h: 40px;
  --topbar-h: 64px;
}

body { min-height: 100dvh; }
.noscript { padding: var(--space-lg); }
.muted { color: var(--color-muted); }
.fig, .num { font-family: var(--font-outlier); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; letter-spacing: -0.01em; }
.gain, .loss { font-weight: 500; }
.gain { color: var(--color-gain); }
.loss { color: var(--color-loss); }

/* ------- surfaces (Coral) ------- */
.desk { background-color: var(--color-desk); background-image: radial-gradient(90% 120% at 0% 30%, var(--color-cotton), transparent 62%), var(--tex-desk); }
.stock { background-color: var(--color-cotton); background-image: linear-gradient(100deg, var(--color-cotton), transparent 45%), var(--tex-cotton); color: var(--color-print); box-shadow: var(--edge-stock), var(--cast-stock); border-radius: var(--radius-stock); }

/* ------- controls ------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  min-height: var(--control-h); padding: 0 var(--space-md); border: 0; border-radius: var(--radius-stock);
  font-weight: 500; font-size: var(--text-sm); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: transform var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out), opacity var(--dur-micro) linear;
  position: relative;
}
.btn::after { content: ""; position: absolute; inset: -4px 0; } /* 44px+ hit target */
.btn--card { background-color: var(--color-cotton); background-image: var(--tex-cotton); color: var(--color-print); text-shadow: 0.5px 0.75px 0 var(--color-cotton); box-shadow: var(--edge-stock), var(--cast-stock); }
.btn--ink { background: var(--color-board); color: var(--color-board-type); text-shadow: 0 -0.75px 0 var(--color-ink); box-shadow: var(--cast-stock); }
.btn--ghost { background: transparent; color: var(--color-ink-2); }
.btn--ghost:hover { background: var(--color-paper-2); }
.btn--danger { background: transparent; color: var(--color-error); box-shadow: inset 0 0 0 1px var(--color-rule-2); }
.btn--card:hover, .btn--ink:hover { transform: translateY(-1px); box-shadow: var(--edge-stock), var(--cast-stock-lift); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn--sm { --control-h: 36px; padding: 0 var(--space-sm); }

.field { display: grid; gap: var(--space-2xs); min-width: 0; }
.field__label { font-size: var(--text-sm); font-weight: 500; color: var(--color-muted); }
.field__hint { font-size: var(--text-xs); color: var(--color-muted); min-height: 1lh; }
.field__error { font-size: var(--text-sm); color: var(--color-error); min-height: 1lh; }
.input, .select, .textarea {
  width: 100%; min-height: var(--control-h); padding: 0 var(--space-sm);
  border: 1px solid var(--color-rule-2); border-radius: var(--radius-input);
  background: var(--color-cotton); color: var(--color-ink);
  transition: border-color var(--dur-micro) linear;
}
.textarea { padding: var(--space-xs) var(--space-sm); min-height: 96px; resize: vertical; line-height: 1.5; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--color-muted); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -1px; }
.input[aria-invalid="true"] { border-color: var(--color-error); }
.input.fig { text-align: right; }
.input-row { display: flex; gap: var(--space-xs); }
.input-row > .input { flex: 1; min-width: 0; }
.input-row > .select { width: auto; flex: none; }

/* groove: a choice of two to five */
.groove { justify-self: start; display: inline-flex; padding: var(--space-2xs); gap: var(--space-3xs); border-radius: 12px; background: var(--color-paper-2); box-shadow: var(--press-groove); max-width: 100%; overflow-x: auto; }
.groove input { position: absolute; opacity: 0; pointer-events: none; }
.groove label { display: inline-flex; align-items: center; min-height: 34px; padding: 0 var(--space-sm); border-radius: 9px; font-size: var(--text-sm); font-weight: 500; color: var(--color-muted); cursor: pointer; white-space: nowrap; transition: color var(--dur-micro) linear, box-shadow var(--dur-short) var(--ease-out); }
.groove label:hover { color: var(--color-ink); }
.groove input:checked + label { background-color: var(--color-cotton); color: var(--color-print); box-shadow: var(--edge-stock), var(--cast-stock); }
.groove input:focus-visible + label { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.groove input:disabled + label { opacity: 0.55; cursor: not-allowed; }

/* ------- login ------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-lg) var(--space-md); }
.login__card { width: min(100%, 22rem); padding: var(--space-xl) var(--space-lg); display: grid; gap: var(--space-md); }
.login__card h1 { font-size: var(--text-2xl); }
.login__card .btn { width: 100%; min-height: 48px; }

/* ------- shell ------- */
.topbar { position: sticky; top: 0; z-index: var(--z-sticky-nav); background: color-mix(in oklab, var(--color-paper) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--color-rule); }
.topbar__inner { max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); min-height: var(--topbar-h); display: flex; align-items: center; gap: var(--space-lg); }
.wordmark { font-weight: 600; letter-spacing: var(--tracking-display); font-size: var(--text-lg); text-decoration: none; white-space: nowrap; }
.wordmark:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 4px; border-radius: 2px; }
.tabs { display: flex; gap: var(--space-2xs); overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--space-sm); border-radius: var(--radius-input); font-size: var(--text-sm); font-weight: 500; color: var(--color-muted); text-decoration: none; white-space: nowrap; transition: color var(--dur-micro) linear, background-color var(--dur-micro) linear; }
.tab:hover { color: var(--color-ink); background: var(--color-paper-2); }
.tab[aria-current="page"] { color: var(--color-ink); background: var(--color-paper-3); }
.tab:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 0; }
.topbar__end { margin-left: auto; display: flex; align-items: center; gap: var(--space-xs); }
.price-clock { font-size: var(--text-xs); white-space: nowrap; }

.page { padding-block: var(--space-xl) var(--space-3xl); display: grid; gap: var(--space-xl); align-content: start; }
.page:focus { outline: none; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: var(--space-md); flex-wrap: wrap; }
.page-head h1 { font-size: var(--text-2xl); }
.section { display: grid; gap: var(--space-md); min-width: 0; align-content: start; }
.section + .section, .sheet + .section { margin-top: var(--space-lg); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-md); flex-wrap: wrap; }
.section__head h2 { font-size: var(--text-lg); }

/* ------- signature: the balance sheet ------- */
.sheet { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--space-xl) var(--space-2xl); padding: var(--space-xl); }
.sheet__total { display: grid; gap: var(--space-xs); align-content: start; }
.sheet__total .label { font-size: var(--text-sm); color: var(--color-muted); font-weight: 500; }
.sheet__figure { font-family: var(--font-outlier); font-variant-numeric: tabular-nums; font-size: clamp(2rem, 1.2rem + 3vw, 3.4rem); line-height: 1; letter-spacing: -0.04em; font-weight: 500; overflow-wrap: anywhere; }
.sheet__figure small { font-size: 0.42em; letter-spacing: 0; color: var(--color-muted); margin-left: 0.2em; }
.sheet__lines { display: grid; gap: 0; margin: 0; align-content: start; }
.sheet__lines > div { display: flex; justify-content: space-between; gap: var(--space-md); padding-block: var(--space-sm); border-bottom: 1px solid var(--color-rule); }
.sheet__lines > div:first-child { border-top: 1px solid var(--color-print); }
.sheet__lines dt { font-weight: 500; }
.sheet__lines dd { margin: 0; text-align: right; }
.sheet__alloc { grid-column: 1 / -1; display: grid; gap: var(--space-sm); }
.stamp { display: inline-block; font-weight: 600; color: var(--color-paid); transform: rotate(-3deg); font-size: var(--text-sm); border: 1.5px solid currentColor; border-radius: 4px; padding: 0 var(--space-2xs); margin-left: var(--space-xs); }

.allocbar { display: flex; height: 20px; border-radius: 2px; overflow: hidden; background: var(--color-paper-3); gap: var(--space-3xs); }
.allocbar span { display: block; min-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-lg); margin: 0; padding: 0; list-style: none; font-size: var(--text-sm); }
.legend li { display: inline-flex; align-items: center; gap: var(--space-xs); }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.s1 { background: var(--series-1); } .s2 { background: var(--series-2); } .s3 { background: var(--series-3); } .s4 { background: var(--series-4); } .s5 { background: var(--series-5); }

/* ------- tables ------- */
.table-wrap { overflow-x: auto; min-width: 0; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; font-weight: 500; color: var(--color-muted); padding: var(--space-xs) var(--space-sm); border-bottom: 1px solid var(--color-rule-2); white-space: nowrap; }
.table td { padding: var(--space-sm); border-bottom: 1px solid var(--color-rule); vertical-align: top; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table .r { text-align: right; }
.table td.num, .table td .num { white-space: nowrap; }
.table tfoot td { font-weight: 600; border-bottom: 0; border-top: 1px solid var(--color-print); }
.table tbody tr.row-click { cursor: pointer; transition: background-color var(--dur-micro) linear; }
.table tbody tr.row-click:hover { background: var(--color-paper-2); }
.table tbody tr.row-click:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.table--hist { table-layout: fixed; }
.table--hist col.c-date { width: 7rem; } .table--hist col.c-side { width: 4.5rem; } .table--hist col.c-num { width: 10%; } .table--hist col.c-total { width: 12%; } .table--hist col.c-now { width: 12%; } .table--hist col.c-pl { width: 11%; } .table--hist col.c-loc { width: 12%; }
.table tr.detail td { background: var(--color-paper-2); padding: var(--space-md); }
.sym { font-weight: 600; }
.sub { display: block; font-size: var(--text-xs); color: var(--color-muted); font-weight: 400; }
.tag { display: inline-block; font-size: var(--text-xs); font-weight: 500; padding: var(--space-3xs) var(--space-xs); border-radius: 4px; box-shadow: inset 0 0 0 1px var(--color-rule-2); color: var(--color-ink-2); white-space: nowrap; }

/* ------- chart ------- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--color-rule); stroke-width: 1; }
.chart .bar { fill: var(--series-2); }
.chart .bar--now { fill: var(--series-1); }
.chart text { fill: var(--color-muted); font-family: var(--font-outlier); font-size: 11px; font-variant-numeric: tabular-nums; }

/* ------- two-column split ------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2xl); }

/* ------- history ------- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: center; }
.toolbar .input { width: 16rem; max-width: 100%; }
.month { display: grid; gap: var(--space-sm); }
.month__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-md); flex-wrap: wrap; padding-bottom: var(--space-xs); }
.month__head h2 { font-size: var(--text-lg); }
.month__sum { display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-lg); margin: 0; font-size: var(--text-sm); }
.month__sum div { display: flex; gap: var(--space-xs); }
.month__sum dt { color: var(--color-muted); }
.month__sum dd { margin: 0; }
.detail__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-md) var(--space-xl); }
.detail__grid dl { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-2xs) var(--space-md); }
.detail__grid dt { color: var(--color-muted); }
.detail__grid dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail__actions { grid-column: 1 / -1; display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.thumbs { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.thumb { position: relative; width: 88px; height: 88px; border-radius: var(--radius-input); overflow: hidden; background: var(--color-paper-3); box-shadow: var(--edge-stock); flex: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb a:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; display: block; }
.thumb button { position: absolute; top: 4px; right: 4px; min-height: 0; height: 24px; padding: 0 var(--space-2xs); font-size: var(--text-xs); }

/* ------- add form ------- */
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md) var(--space-lg); max-width: 52rem; }
.form .full { grid-column: 1 / -1; }
.form__total { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-md); padding-block: var(--space-md); border-top: 1px solid var(--color-print); border-bottom: 1px solid var(--color-rule); }
.form__total .fig { font-size: var(--text-xl); }
.form__actions { grid-column: 1 / -1; display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.form__actions .btn { min-height: 44px; }
.drop { display: grid; gap: var(--space-xs); padding: var(--space-md); border: 1px dashed var(--color-rule-2); border-radius: var(--radius-card); }
.drop input[type="file"] { font-size: var(--text-sm); max-width: 100%; }
.drop input[type="file"]:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* ------- states ------- */
.sk { display: block; background: var(--skeleton); border-radius: 4px; height: 14px; animation: sk 1.4s var(--ease-in-out) infinite alternate; }
.sk--fig { height: 48px; width: 60%; }
.sk--line { width: 100%; margin-block: var(--space-sm); }
@keyframes sk { from { opacity: 1; } to { opacity: 0.45; } }
.empty, .error { display: grid; gap: var(--space-sm); justify-items: start; padding: var(--space-xl) 0; border-top: 1px solid var(--color-rule); }
.empty h2, .error h2 { font-size: var(--text-lg); }
.error h2 { color: var(--color-error); }

.toasts { position: fixed; z-index: var(--z-toast); left: 50%; bottom: var(--space-lg); transform: translateX(-50%); display: grid; gap: var(--space-xs); width: min(92vw, 26rem); pointer-events: none; }
.toast { padding: var(--space-sm) var(--space-md); border-radius: var(--radius-card); background: var(--color-board); color: var(--color-board-type); font-size: var(--text-sm); box-shadow: var(--cast-stock-lift); animation: toast-in var(--dur-short) var(--ease-out); }
.toast--error { box-shadow: inset 3px 0 0 var(--color-accent), var(--cast-stock-lift); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------- responsive ------- */
@media (max-width: 60rem) {
  .sheet { grid-template-columns: minmax(0, 1fr); padding: var(--space-lg); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .price-clock { display: none; }
  .topbar__inner { flex-wrap: wrap; gap: var(--space-xs) var(--space-md); padding-block: var(--space-xs); }
  .tabs { order: 3; width: 100%; }
  .tab { font-size: var(--text-md); }
}
@media (max-width: 40rem) {
  .form { grid-template-columns: minmax(0, 1fr); }
  .detail__grid { grid-template-columns: minmax(0, 1fr); }
  .input, .select, .textarea { font-size: var(--text-md); }
  /* bảng xếp thành khối trên điện thoại; cột tên và cột hành động vẫn thấy */
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table--stack tbody tr:not(.detail) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2xs) var(--space-md); padding-block: var(--space-sm); border-bottom: 1px solid var(--color-rule); }
  .table--stack td { border: 0; padding: 0; }
  .table--stack td[data-label]::before { content: attr(data-label); display: block; font-size: var(--text-xs); color: var(--color-muted); font-family: var(--font-body); }
  .table--stack td:first-child { grid-column: 1 / -1; }
  .table--stack .r { text-align: left; }
  .table--stack tr.detail { display: block; }
  .table--stack tr.detail td { display: block; }
  .table--stack tfoot tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2xs) var(--space-md); padding-top: var(--space-sm); border-top: 1px solid var(--color-print); }
  .table--stack tfoot td { padding: 0; border: 0; }
  .table--stack tfoot td:first-child { grid-column: 1 / -1; }
  .table--hist { table-layout: auto; }
}

/* tiếng Việt có dấu chồng hai tầng: chừa khoảng dòng cho tiêu đề */
h1, h2, h3 { line-height: 1.25; }
.wordmark { letter-spacing: -0.02em; }
.drop input[type="file"]::file-selector-button { font: inherit; font-weight: 500; margin-right: var(--space-sm); min-height: 36px; padding: 0 var(--space-sm); border: 0; border-radius: var(--radius-stock); background: var(--color-paper); color: var(--color-ink); box-shadow: var(--edge-stock); cursor: pointer; }
.drop input[type="file"]::file-selector-button:hover { background: var(--color-paper-2); }

/* combobox: danh sách gợi ý cùng kiểu với web */
.combo { position: relative; min-width: 0; }
.combo > .input { width: 100%; }
.toolbar .combo { width: 16rem; max-width: 100%; }
.toolbar .combo > .input { width: 100%; }
.combo__list { position: absolute; z-index: var(--z-dropdown); top: calc(100% + var(--space-2xs)); left: 0; right: 0; min-width: 10rem; max-height: 16rem; overflow-y: auto; margin: 0; padding: var(--space-2xs); list-style: none; background: var(--color-paper); border: 1px solid var(--color-rule-2); border-radius: var(--radius-input); box-shadow: var(--cast-stock-lift); }
.combo__opt { padding: var(--space-xs) var(--space-sm); border-radius: 4px; font-size: var(--text-sm); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo__opt[aria-selected="true"] { background: var(--color-paper-3); }
#gold-unit { flex: none; align-self: center; }

/* tổng tài sản theo ngày */
.trend { position: relative; }
.trend__plot { width: 100%; min-width: 0; }
.chart--trend { width: 100%; height: auto; touch-action: pan-y; cursor: crosshair; }
.chart--trend:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 4px; }
.chart .line { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .line--total { stroke: var(--series-1); stroke-width: 2px; }
.chart .line--capital { stroke: var(--series-4); stroke-width: 1.5px; }
.trend__fill-top { stop-color: var(--series-1); stop-opacity: 0.08; }
.trend__fill-bottom { stop-color: var(--series-1); stop-opacity: 0; }
.trend__cursor { stroke: var(--color-muted); stroke-width: 1px; }
.trend__sum { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2xs) var(--space-sm); }
.trend__sum > .num:first-child { font-size: var(--text-xl); font-weight: 500; }
.trend__tip { position: absolute; top: 0; transform: translateX(-50%); display: grid; gap: var(--space-3xs); padding: var(--space-xs) var(--space-sm); background: var(--color-paper); border: 1px solid var(--color-rule-2); border-radius: var(--radius-input); box-shadow: var(--cast-stock-lift); font-size: var(--text-sm); white-space: nowrap; pointer-events: none; z-index: var(--z-raised); }
.swatch--line { height: 2px; width: 14px; border-radius: 0; background: var(--series-4); }

/* ghi chú Markdown */
.md-editor { display: grid; gap: var(--space-xs); }
.md-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-xs); }
.md-toolbar__tools { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
.md-editor__text { min-height: 180px; font-family: var(--font-body); }
.md-editor.is-drop .md-editor__text { border-style: dashed; border-color: var(--color-ink); background: var(--color-paper-2); }
.md-editor__preview { min-height: 180px; padding: var(--space-sm); border: 1px solid var(--color-rule-2); border-radius: var(--radius-input); background: var(--color-paper); }
.md { display: grid; gap: var(--space-xs); line-height: 1.6; white-space: normal; max-width: 70ch; }
.md p, .md ul, .md ol, .md blockquote { margin: 0; }
.md ul, .md ol { padding-left: 1.3em; }
.md h3, .md h4, .md h5 { margin: var(--space-xs) 0 0; font-size: var(--text-md); max-width: none; }
.md h3 { font-size: var(--text-lg); }
.md blockquote { padding-left: var(--space-sm); border-left: 2px solid var(--color-rule-2); color: var(--color-muted); }
.md code { font-family: var(--font-outlier); font-size: 0.92em; padding: 0 var(--space-2xs); border-radius: 4px; background: var(--color-paper-3); }
.md hr { border: 0; border-top: 1px solid var(--color-rule); margin: var(--space-xs) 0; width: 100%; }
.md a { text-decoration-color: var(--color-rule-2); }
.md__img { display: block; width: fit-content; max-width: 100%; }
.md__img img { max-width: min(100%, 520px); max-height: 420px; border-radius: var(--radius-input); box-shadow: var(--edge-stock); }
.md__img:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* chi tiết giao dịch: thông tin ngang phía trên, ghi chú (kèm ảnh) chiếm hết bề rộng */
.detail__body { display: grid; gap: var(--space-md); }
.detail__meta { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-xl); margin: 0; padding-bottom: var(--space-sm); border-bottom: 1px solid var(--color-rule); }
.detail__meta div { display: grid; gap: var(--space-3xs); min-width: 0; }
.detail__meta dt { font-size: var(--text-xs); color: var(--color-muted); }
.detail__meta dd { margin: 0; overflow-wrap: anywhere; }
.detail__note { display: grid; gap: var(--space-sm); min-width: 0; }
.detail__note .md { max-width: 75ch; }
.md__gallery { display: flex; flex-wrap: wrap; gap: var(--space-sm); align-items: flex-start; }
.md__gallery .md__img img, .detail__note .md__img img { max-height: 280px; max-width: min(100%, 360px); width: auto; }
.md__img { cursor: zoom-in; }
.md__img img { transition: transform var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out); }
.md__img:hover img { box-shadow: 0 0 0 2px var(--color-blue); }

.lightbox { padding: 0; border: 0; background: transparent; max-width: 96vw; max-height: 96dvh; overflow: visible; }
:root { --color-scrim: oklch(0% 0 0 / 0.78); }
.lightbox::backdrop { background: var(--color-scrim); }
.lightbox img { display: block; max-width: 96vw; max-height: calc(96dvh - 64px); width: auto; height: auto; border-radius: var(--radius-input); background: var(--color-paper); }
.lightbox__bar { display: flex; justify-content: center; gap: var(--space-xs); padding-top: var(--space-sm); }

.form__pl { margin: calc(var(--space-sm) * -1) 0 0; font-size: var(--text-sm); color: var(--color-muted); }
.form__pl .num { color: var(--color-ink); }

/* lời/lỗ nổi bật: con số chính có nền nhạt cùng màu */
.sheet__lines dd.gain, .sheet__lines dd.loss, .table td.gain, .table td.loss, .trend__sum .num.gain, .trend__sum .num.loss, .form__pl .num.gain, .form__pl .num.loss { font-weight: 600; }
.pl-chip { display: inline-block; padding: 0 var(--space-2xs); border-radius: 4px; }
.pl-chip.gain { background: var(--color-gain-bg); }
.pl-chip.loss { background: var(--color-loss-bg); }
.form__pl .num.gain, .form__pl .num.loss, .trend__sum .num.gain, .trend__sum .num.loss { padding: 0 var(--space-2xs); border-radius: 4px; }
.form__pl .num.gain, .trend__sum .num.gain { background: var(--color-gain-bg); }
.form__pl .num.loss, .trend__sum .num.loss { background: var(--color-loss-bg); }
.trend--up .line--total { stroke: var(--color-gain); }
.trend--down .line--total { stroke: var(--color-loss); }
.trend--up .trend__fill-top { stop-color: var(--color-gain); stop-opacity: 0.14; }
.trend--down .trend__fill-top { stop-color: var(--color-loss); stop-opacity: 0.14; }

.page-head__actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.trend__fill-note { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-sm); font-size: var(--text-sm); }

/* biểu đồ tròn phân bổ */
.donut { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: var(--space-xl) var(--space-2xl); align-items: center; }
.donut__chart { position: relative; width: 100%; max-width: 280px; aspect-ratio: 1; }
.donut__chart svg { width: 100%; height: 100%; overflow: visible; }
.donut__seg { stroke: var(--color-paper); stroke-width: 2px; cursor: pointer; transition: transform var(--dur-short) var(--ease-out), opacity var(--dur-short) var(--ease-out); outline: none; }
.donut.is-active .donut__seg { opacity: 0.35; }
.donut .donut__seg.is-on { opacity: 1; transform: translate(var(--dx), var(--dy)); }
.donut__seg:focus-visible { stroke: var(--color-focus); stroke-width: 2.5px; }
.donut__center { position: absolute; inset: 24%; display: grid; place-content: center; text-align: center; gap: var(--space-3xs); pointer-events: none; }
.donut__c-label { font-size: var(--text-sm); color: var(--color-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9rem; }
.donut__c-pct { font-size: var(--text-2xl); font-weight: 600; line-height: 1.1; }
.donut__c-pct:empty { display: none; }
.donut__c-val { font-size: var(--text-sm); font-weight: 500; }
.donut__legend { list-style: none; margin: 0; padding: 0; display: grid; }
.donut__legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto minmax(8rem, auto); align-items: center; gap: var(--space-sm); padding: var(--space-xs) var(--space-xs); border-bottom: 1px solid var(--color-rule); border-radius: 4px; cursor: default; transition: background-color var(--dur-micro) linear, opacity var(--dur-short) var(--ease-out); }
.donut__legend li:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
.donut.is-active .donut__legend li { opacity: 0.45; }
.donut .donut__legend li.is-on { opacity: 1; background: var(--color-paper-2); }
.donut__name { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.donut__pct { text-align: right; font-weight: 600; }
.donut__val { text-align: right; color: var(--color-ink-2); }
.d1 { fill: var(--donut-1); background: var(--donut-1); } .d2 { fill: var(--donut-2); background: var(--donut-2); }
.d3 { fill: var(--donut-3); background: var(--donut-3); } .d4 { fill: var(--donut-4); background: var(--donut-4); }
.d5 { fill: var(--donut-5); background: var(--donut-5); } .d6 { fill: var(--donut-6); background: var(--donut-6); }
.d7 { fill: var(--donut-7); background: var(--donut-7); } .d8 { fill: var(--donut-8); background: var(--donut-8); }
.donut__legend .swatch.d7, .donut__legend .swatch.d8 { box-shadow: inset 0 0 0 1px var(--color-rule-2); }
@media (max-width: 48rem) {
  .donut { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .donut__legend { width: 100%; }
  .donut__legend li { grid-template-columns: 12px minmax(0, 1fr) auto; }
  .donut__val { grid-column: 2 / -1; text-align: left; font-size: var(--text-sm); }
}

/* Đang nắm giữ: nhóm theo loại */
.table--hold .group-row th, .table--hold .group-row td { background: var(--color-paper-2); font-weight: 600; border-bottom: 1px solid var(--color-rule-2); padding-top: var(--space-sm); padding-bottom: var(--space-sm); }
.table--hold .group-row th { color: var(--color-ink); text-align: left; padding-left: var(--space-sm); border-radius: 4px 0 0 4px; white-space: nowrap; }
.table--hold .group-row th .swatch { display: inline-block; vertical-align: middle; margin-right: var(--space-xs); }
.table--hold .group-row th .sub { margin-left: var(--space-xs); }
.table--hold .group-row td:last-child { padding-right: var(--space-sm); border-radius: 0 4px 4px 0; }
.table--hold .group-row th .sub { display: inline; font-weight: 400; }
.table--hold .group-row td .sub { font-weight: 400; }
.table--hold .hold-row td:first-child { padding-left: var(--space-xl); }
.table--hold .hold-group + .hold-group .group-row th, .table--hold .hold-group + .hold-group .group-row td { border-top: var(--space-md) solid var(--color-paper); }
@media (max-width: 40rem) {
  .table--hold .group-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2xs) var(--space-md); padding: var(--space-sm); background: var(--color-paper-2); border-radius: 4px; margin-top: var(--space-sm); }
  .table--hold .group-row th { grid-column: 1 / -1; padding: 0; background: none; }
  .table--hold .group-row td { padding: 0; background: none; border: 0; }
  .table--hold .group-row td:empty { display: none; }
  .table--hold td.na { display: none; }
  .table--hold .hold-row td:first-child { padding-left: 0; }
  .table--hold .hold-group + .hold-group .group-row th, .table--hold .hold-group + .hold-group .group-row td { border-top: 0; }
}


/* =====================================================================
   Màu sắc (Hum): giấy ấm, mực xanh than, mỗi màu nhấn một việc —
   lê (vàng) cho hành động chính và thẻ tổng tài sản, xanh dương cho liên kết/focus,
   san hô cho chi tiêu, bạc hà cho tăng trưởng; mỗi loại tài sản một màu riêng.
   ===================================================================== */
:root {
  --color-paper: oklch(97% 0.012 95); --color-paper-2: oklch(94.5% 0.018 95); --color-paper-3: oklch(91% 0.022 95);
  --color-ink: oklch(22% 0.03 258); --color-ink-2: oklch(31% 0.03 258); --color-muted: oklch(48% 0.02 258);
  --color-rule: oklch(89% 0.016 95); --color-rule-2: oklch(82% 0.02 95);
  --color-card: oklch(99.3% 0.005 95); --color-edge: oklch(84% 0.035 88);
  --color-pear: oklch(88% 0.17 98); --color-pear-deep: oklch(73% 0.16 90); --color-pear-ink: oklch(22% 0.03 258);
  --color-blue: oklch(52% 0.18 255); --color-blue-soft: oklch(93% 0.04 250);
  --color-coral: oklch(70% 0.19 25); --color-coral-soft: oklch(93% 0.045 25);
  --color-mint: oklch(84% 0.13 155); --color-mint-soft: oklch(94% 0.05 155);
  --color-accent: var(--color-pear); --color-accent-2: var(--color-blue); --color-focus: var(--color-blue);
  --color-board: var(--color-ink); --color-board-type: var(--color-paper); --color-paid: oklch(22% 0.03 258);
  --color-gain: oklch(50% 0.15 152); --color-loss: oklch(54% 0.21 26);
  --color-gain-bg: oklch(52% 0.15 152 / 0.13); --color-loss-bg: oklch(56% 0.21 26 / 0.12);
  --color-gain-on-pear: oklch(40% 0.13 152); --color-loss-on-pear: oklch(45% 0.2 26);
  --color-scrim: oklch(22% 0.03 258 / 0.78);
  --color-coral-deep: oklch(57% 0.2 25);
  --tag-buy-ink: oklch(42% 0.17 258); --tag-sell-bg: oklch(94% 0.05 60); --tag-sell-ink: oklch(46% 0.14 50);
  --tag-in-ink: oklch(40% 0.11 155); --tag-out-ink: oklch(48% 0.18 25);
  /* mỗi loại tài sản một màu */
  --type-cash: oklch(70% 0.13 195);   /* tiền mặt: xanh ngọc */
  --type-gold: oklch(80% 0.16 85);    /* vàng: vàng kim */
  --type-stock: oklch(55% 0.19 258);  /* cổ phiếu: xanh dương */
  --type-fund: oklch(62% 0.17 300);   /* chứng chỉ quỹ: tím */
  --type-crypto: oklch(72% 0.17 50);  /* crypto: cam */
  --series-1: var(--type-cash); --series-2: var(--type-gold); --series-3: var(--type-stock); --series-4: var(--type-fund); --series-5: var(--type-crypto);
  /* 8 màu cho biểu đồ theo mã */
  --donut-1: oklch(55% 0.19 258); --donut-2: oklch(80% 0.16 85); --donut-3: oklch(70% 0.13 195); --donut-4: oklch(72% 0.17 50);
  --donut-5: oklch(62% 0.17 300); --donut-6: oklch(70% 0.19 25); --donut-7: oklch(78% 0.13 150); --donut-8: oklch(82% 0.05 258);
  --radius-card: 22px; --radius-stock: 14px; --radius-input: 12px;
  --shadow-card: 0 1px 2px oklch(22% 0.03 258 / 0.06), 0 14px 32px -18px oklch(22% 0.03 258 / 0.28);
  --edge-stock: 0 0 0 1px var(--color-edge);
  --cast-stock: 0 1px 2px oklch(22% 0.03 258 / 0.08); --cast-stock-lift: 0 6px 16px -6px oklch(22% 0.03 258 / 0.25);
  --press-groove: inset 0 0 0 1px var(--color-rule-2);
  --skeleton: var(--color-paper-3);
  --tracking-display: -0.03em; --display-weight: 700;
}

body { background: var(--color-paper); }
.t-cash { fill: var(--type-cash); background: var(--type-cash); } .t-gold { fill: var(--type-gold); background: var(--type-gold); }
.t-stock { fill: var(--type-stock); background: var(--type-stock); } .t-fund { fill: var(--type-fund); background: var(--type-fund); }
.t-crypto { fill: var(--type-crypto); background: var(--type-crypto); }
.swatch { width: 12px; height: 12px; border-radius: 4px; }

/* thanh trên */
.topbar { background: color-mix(in oklab, var(--color-paper) 88%, transparent); border-bottom-color: var(--color-rule); }
.wordmark { font-weight: 700; display: inline-flex; align-items: center; gap: var(--space-xs); }
.wordmark::before { content: ""; width: 22px; height: 22px; border-radius: 7px; background: var(--color-pear); box-shadow: inset 0 -3px 0 var(--color-pear-deep); }
.tab { border-radius: var(--radius-pill); padding: 0 var(--space-md); color: var(--color-ink-2); }
.tab:hover { background: var(--color-paper-3); }
.tab[aria-current="page"] { background: var(--color-ink); color: var(--color-paper); }

/* nút: hành động chính màu lê có mép dưới; phụ là thẻ giấy có mép */
.btn { border-radius: var(--radius-stock); font-weight: 600; }
.btn--ink { background: var(--color-pear); color: var(--color-pear-ink); text-shadow: none; box-shadow: inset 0 -4px 0 var(--color-pear-deep); padding-bottom: var(--space-2xs); }
.btn--ink:hover { box-shadow: inset 0 -5px 0 var(--color-pear-deep), var(--cast-stock-lift); }
.btn--ink:active { box-shadow: inset 0 -1px 0 var(--color-pear-deep); }
.btn--card { background: var(--color-card); background-image: none; color: var(--color-ink); text-shadow: none; box-shadow: inset 0 0 0 1px var(--color-edge), inset 0 -3px 0 var(--color-edge); padding-bottom: var(--space-3xs); }
.btn--card:hover { box-shadow: inset 0 0 0 1px var(--color-edge), inset 0 -4px 0 var(--color-edge), var(--cast-stock-lift); }
.btn--ghost:hover { background: var(--color-paper-3); }
.btn--danger { color: var(--color-loss); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--color-loss) 35%, transparent); }
.btn--danger:hover { background: var(--color-loss-bg); }

/* chọn nhiều: viên thuốc mực xanh than */
.groove { background: var(--color-paper-3); box-shadow: none; border-radius: var(--radius-pill); }
.groove label { border-radius: var(--radius-pill); color: var(--color-ink-2); }
.groove input:checked + label { background: var(--color-ink); color: var(--color-paper); box-shadow: none; }

/* ô nhập */
.input, .select, .textarea { background: var(--color-card); border-color: var(--color-rule-2); border-radius: var(--radius-input); }
.input:hover, .textarea:hover { border-color: var(--color-muted); }

/* mỗi phần là một thẻ */
.page > .section, .month { background: var(--color-card); border-radius: var(--radius-card); padding: var(--space-lg); box-shadow: var(--shadow-card); }
.page > .section + .section, .sheet + .section { margin-top: 0; }
.page { gap: var(--space-lg); }
.section__head h2, .month__head h2 { font-size: var(--text-xl); }

/* thẻ tổng tài sản: mảng màu lê duy nhất */
.sheet.stock { background: var(--color-pear); background-image: none; color: var(--color-pear-ink); border-radius: var(--radius-card); box-shadow: inset 0 -6px 0 var(--color-pear-deep), var(--shadow-card); }
.sheet__total .label, .sheet__total .muted { color: color-mix(in oklab, var(--color-pear-ink) 72%, var(--color-pear)); }
.sheet__figure { font-weight: 600; }
.sheet__figure small { color: inherit; opacity: 0.6; }
.sheet__lines > div { border-bottom-color: color-mix(in oklab, var(--color-pear-ink) 16%, transparent); }
.sheet__lines > div:first-child { border-top-color: var(--color-pear-ink); }
.sheet__lines .gain { color: var(--color-gain-on-pear); }
.sheet__lines .loss { color: var(--color-loss-on-pear); }
.sheet__lines .sub { color: inherit; opacity: 0.75; }
.stamp { filter: none; color: var(--color-ink); background: var(--color-coral); border: 0; border-radius: 6px; padding: 1px var(--space-xs); transform: rotate(-4deg); box-shadow: 0 2px 0 var(--color-coral-deep); }

/* bảng */
.table th { color: var(--color-muted); border-bottom-color: var(--color-rule-2); }
.table td { border-bottom-color: var(--color-rule); }
.table tbody tr.row-click:hover { background: var(--color-paper-2); }
.table tr.detail td { background: var(--color-paper-2); }
.table tfoot td { border-top-color: var(--color-ink); }
.table--hold .group-row th, .table--hold .group-row td { background: var(--color-paper-2); }
.table--hold .hold-group + .hold-group .group-row th, .table--hold .hold-group + .hold-group .group-row td { border-top-color: var(--color-card); }

/* nhãn Mua/Bán/Thu/Chi có màu */
.tag { box-shadow: none; font-weight: 600; border-radius: var(--radius-pill); padding: var(--space-3xs) var(--space-sm); }
.tag--buy { background: var(--color-blue-soft); color: var(--tag-buy-ink); }
.tag--sell { background: var(--tag-sell-bg); color: var(--tag-sell-ink); }
.tag--in { background: var(--color-mint-soft); color: var(--tag-in-ink); }
.tag--out { background: var(--color-coral-soft); color: var(--tag-out-ink); }
.pl-chip { border-radius: 6px; padding: 0 var(--space-xs); }

/* biểu đồ */
.chart .bar { fill: var(--color-coral); }
.chart .bar--now { fill: var(--color-coral-deep); }
.chart .line--capital { stroke: var(--color-rule-2); stroke-width: 2px; }
.swatch--line { background: var(--color-rule-2); }
.chart .grid { stroke: var(--color-rule); }
.donut__seg { stroke: var(--color-card); stroke-width: 3px; }
.donut__c-pct { font-weight: 700; }
.donut .donut__legend li.is-on { background: var(--color-paper-2); }

/* đăng nhập: nền lê */
.login.desk { background: var(--color-pear); background-image: none; }
.login__card.stock { background: var(--color-card); background-image: none; border-radius: var(--radius-card); box-shadow: var(--shadow-card); }

/* ghi chú, chi tiết, lightbox */
.md-editor__preview { background: var(--color-card); border-radius: var(--radius-input); }
.md__img img { border-radius: 12px; box-shadow: 0 0 0 1px var(--color-rule-2); }
.md a { color: var(--color-blue); text-decoration-color: color-mix(in oklab, var(--color-blue) 40%, transparent); }
.detail__meta { border-bottom-color: var(--color-rule-2); }
.combo__list { background: var(--color-card); border-radius: var(--radius-input); }
.combo__opt[aria-selected="true"] { background: var(--color-blue-soft); }
.toast { background: var(--color-ink); color: var(--color-paper); border-radius: var(--radius-stock); }
.toast--error { box-shadow: inset 4px 0 0 var(--color-coral), var(--cast-stock-lift); }
.lightbox img { border-radius: 14px; }

@media (max-width: 40rem) {
  .page > .section, .month { padding: var(--space-md); border-radius: 18px; }
}
.page > .table-wrap, .page > .form { background: var(--color-card); border-radius: var(--radius-card); padding: var(--space-lg); box-shadow: var(--shadow-card); }
.page > .form { max-width: 60rem; }
@media (max-width: 40rem) { .page > .table-wrap, .page > .form { padding: var(--space-md); border-radius: 18px; } }
.chart .bar { rx: 6px; }
/* trên nền lê, nút chính đổi sang mực để không lẫn vào nền */
.login .btn--ink { background: var(--color-ink); color: var(--color-paper); box-shadow: inset 0 -4px 0 var(--color-ink-2); }
