/* ============================================================
   BASE — biến, reset, layout, bảng, nút, nav, bottom-nav, animation, media query
   (toàn bộ style.css trừ các khối feature đã tách sang css/features/)
   ============================================================ */

  :root {
    /* Flat tối giản kiểu Linear — nền phẳng, phân tầng bằng độ sáng */
    --bg-deep: #08090a;
    --bg-main: #0f1011;
    --bg-card: #191a1b;                 /* card = mặt phẳng đặc, sáng hơn nền 1 bậc */
    --bg-card-solid: #191a1b;
    --glass-border: rgba(255,255,255,0.08);   /* viền hairline duy nhất */
    --text-main: #f7f8f8;
    --text-dim: #8a8f98;
    --text-faint: #62666d;
    --cyan: #7170ff;                    /* accent tím Linear duy nhất */
    --cyan-glow: transparent;           /* giữ biến cho tương thích — không còn glow */
    --green: #34d399;
    --green-glow: transparent;
    --red: #fb7185;
    --red-glow: transparent;
    --violet: #a78bfa;
    --hairline: rgba(255, 255, 255, 0.07);
    --ana-divider: rgba(255, 255, 255, 0.12);
    --amber: #fbbf24;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-card: none;
    --ease: cubic-bezier(0.2, 0, 0, 1);
    --font: 'Be Vietnam Pro', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
    --font-serif: 'Be Vietnam Pro', 'Instrument Serif', Georgia, 'Times New Roman', serif;
    --font-mono: 'Be Vietnam Pro', 'Geist Mono', ui-monospace, SFMono-Regular, monospace;
    --chart-tip-bg: #191a1b;
    --chart-tip-border: var(--glass-border);
    --chart-tip-text: #f7f8f8;
    --chart-tip-sub: #8a8f98;
    --chart-tip-strong: #f7f8f8;
    --chart-axis: #8a8f98;
    --chart-split: rgba(229,231,235,0.08);
  }

  * { box-sizing: border-box; }

  body {
    margin: 0;
    min-height: 100vh;
    container-type: inline-size;
    padding: 28px 2px 118px;
    background: var(--bg-deep);   /* flat: nền phẳng duy nhất */
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font);
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
    position: relative;
    overflow-x: hidden;
  }

  /* ---------- Thanh công cụ ---------- */
  .toolbar {
    position: relative;
    z-index: 2;
    max-width: 1216px;
    margin: 0 auto 22px;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: none;
    animation: fadeUp .7s ease both;
  }
  .toolbar input[type="file"] {
    padding: 8px 12px;
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .25s, box-shadow .25s;
  }
  .toolbar input[type="file"]:hover {
    border-color: var(--cyan);
    box-shadow: none;
  }
  .toolbar input[type="file"]::file-selector-button {
    background: rgba(255,255,255,0.05);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 4px 10px;
    margin-right: 10px;
    cursor: pointer;
    transition: all .25s;
  }
  .toolbar input[type="file"]::file-selector-button:hover {
    border-color: var(--cyan);
    box-shadow: none;
  }

  .status { font-size: 12.5px; color: var(--text-dim); }
  .status.error { color: var(--red); }
  .status.ok { color: var(--green); }

  /* ---------- Dashboard ---------- */
  .dashboard {
    position: relative;
    z-index: 2;
    max-width: 1216px;
    margin: 0 auto;
    display: none;
  }
  .dashboard.show { animation: fadeUp .6s ease both; }

  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .top-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 32px;
    padding: 18px 22px;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: var(--bg-card);
    box-shadow: none;
    margin-bottom: 18px;
    animation: fadeUp .75s .08s ease both;
  }
  .top-info .field { display: flex; gap: 8px; font-size: 13px; align-items: baseline; }
  .top-info .label { color: var(--text-dim); font-weight: 600; letter-spacing: .3px; }
  .top-info .value {
    color: var(--text-main);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
  }

  /* ---------- Tiêu đề mục ---------- */
  .section-title {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
    font-weight: 700;
    padding: 12px 16px;
    font-size: 15px;
    letter-spacing: 1px;
    border-radius: 12px 12px 0 0;
    background: var(--bg-main);
    border: 1px solid var(--glass-border);
    border-bottom: none;
    margin-top: 30px;
    overflow: hidden;
  }
  .section-title::before {           /* vạch neon bên trái */
    content: "";
    width: 4px;
    height: 62%;
    border-radius: 4px;
    background: var(--cyan);
    box-shadow: none;
  }
  .section-title::after {            /* ánh sáng lướt qua */
    content: "";
    position: absolute;
    top: 0; left: -60%;
    width: 46%;
    height: 130%;
    background: none;
    transform: skewX(-20deg);
  }
  .section-title.small { font-size: 13px; text-align: center; }

  .section-title.sec-title-toggle { justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
  .section-title.sec-title-toggle .sec-arrow {
    color: #fbbf24; font-size: 15px; font-weight: 900; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(251,191,36,.12); border: 1px solid rgba(251,191,36,.35);
    transition: transform .2s ease, background .2s;
    flex-shrink: 0;
  }
  .section-title.sec-title-toggle:hover .sec-arrow { background: rgba(251,191,36,.22); }
  .section-title.sec-title-toggle.open .sec-arrow { transform: rotate(180deg); }

  .section-title .total-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    letter-spacing: 0;
  }
  /* Bọc "Ngày cập nhật" + "Tổng giá trị" xếp dọc: tổng nằm ngay dưới nhãn ngày cập nhật */
  /* Tiêu đề Quỹ: giá trị tổng làm trung tâm, ngày cập nhật nhỏ bên dưới */
  .fund-title-grid.section-title::before,
  .fund-title-grid.section-title::after { display: none !important; }
  .fund-title-grid.section-title { padding-left: 16px; padding-right: 16px; width: 100%; }
  .fund-title-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    text-align: center;
    width: 100%;
  }
  .fund-title-grid .total-inline { justify-content: center; width: 100%; }
  .fund-title-grid .fund-update { align-self: center; }
  .fund-title-grid .fund-meta {
    margin-left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding-left: 0;
    padding-right: 0;
    border-left: none;
    align-self: center;
    justify-content: center;
    width: 100%;
  }
  .fund-title-grid .total-value { font-size: 26px; font-weight: 800; letter-spacing: -.3px; }
  .fund-title-grid .total-pl { font-size: 14px; }
  .fund-title-grid .total-unit { display: none; }
  .fund-title-grid .fund-update { font-size: 12px; }
  .section-title .fund-meta {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }
  .fund-title-grid .fund-update { background: none; border: none; padding: 0; color: var(--text-faint); }
  .fund-title-grid .fund-update #fund-update-date { text-shadow: none; font-weight: 600; }
        .fund-update {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #fcd34d;
    letter-spacing: 0;
    background: rgba(252,211,77,.10);
    border: 1px solid rgba(252,211,77,.32);
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
  }
  .fund-update #fund-update-date {
      color: #fde047;
      font-variant-numeric: tabular-nums;
      font-weight: 800;
    }
    .ct-recorded {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 12px;
        font-weight: 550;
        color: var(--text-dim);
        letter-spacing: 0;
        margin-left: auto;
        white-space: nowrap;
      }
      .ct-recorded .ct-rec-num {
        font-weight: 800;
        color: #fcd34d;
        font-variant-numeric: tabular-nums;
      }

  .section-title .total-inline .total-label {
    color: var(--text-dim);
    font-weight: 700;
    font-size: 13px;
  }
  .section-title .total-inline .total-value {
    color: var(--cyan);
    font-weight: 700;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
  }
  .section-title .total-inline .total-unit {
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
  }
  .section-title .total-inline .total-pl {
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
  }
  .section-title .total-inline .total-pl.pl-loi {
    color: var(--green);
  }
  .section-title .total-inline .total-pl.pl-lo {
    color: var(--red);
  }

    /* ---------- Khóa toàn trang (trust device) ---------- */
  .lock-toggle { font-size: 15px; }
  .global-lock {
    position: fixed; inset: 0; z-index: 2147483000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(8,9,10,0.92);
  }
  .global-lock.hidden { display: none; }
  /* Label ẩn cho password manager + screen reader (không đổi giao diện) */
  .sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
  .global-lock-card {
    width: min(380px, 92vw);
    padding: 36px 18px 24px;
    background: transparent;
    border: none;
    box-shadow: none;
    text-align: center;
    animation: fadeUp .5s ease both;
  }
  .global-lock-icon { font-size: 48px; margin-bottom: 12px; animation: none; }
  .global-lock-img { width: 74px; height: 74px; border-radius: 20px; object-fit: cover; margin: 0 auto 16px; display: block; box-shadow: 0 10px 32px rgba(0,0,0,.45); }
  .global-lock-title { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: .4px; }
  .global-lock-sub { font-size: 13px; color: var(--text-dim); margin: 8px 0 22px; }
  .global-lock-field { position: relative; margin-bottom: 0; }
  .global-lock-field .gl-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-dim); opacity: .85; pointer-events: none; }
  .global-lock-card input[type="email"],
  .global-lock-card input[type="password"],
  .global-lock-card input[type="text"] {
    width: 100%;
    padding: 16px 12px 16px 40px;
    font-size: 15px;
    background: transparent;
    color: var(--text-main);
    border: none;
    border-bottom: 1px solid rgba(148,163,184,.22);
    border-radius: 0;
    outline: none;
    transition: border-color .2s;
  }
  .global-lock-card input[type="email"]::placeholder,
  .global-lock-card input[type="password"]::placeholder,
  .global-lock-card input[type="text"]::placeholder { color: var(--text-dim); opacity: .7; }
  .global-lock-card input[type="email"]:focus,
  .global-lock-card input[type="password"]:focus,
  .global-lock-card input[type="text"]:focus { border-bottom-color: var(--cyan); }
  .global-lock-q { font-size: 12.5px; color: var(--text-dim); text-align: left; margin: 10px 0 2px; line-height: 1.5; }
  .global-lock-q b { color: var(--cyan); font-weight: 650; }
  .global-lock-switch { margin-top: 16px; text-align: center; font-size: 13px; color: var(--text-dim); }
  .global-lock-switch button { background: none; border: none; color: var(--cyan); cursor: pointer; font-size: 13px; padding: 4px 6px; }
  .global-lock-switch button:hover { text-decoration: underline; }
  .lock-register-icon { display: inline-flex !important; align-items: center; justify-content: center; padding: 0 !important; transform: rotate(180deg); transition: transform .55s cubic-bezier(.4,0,.2,1); }
  .lock-register-icon img { width: 54px; height: 54px; border-radius: 16px; object-fit: cover; display: block; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
  .lock-register-icon.flip { transform: rotate(0deg); }
  .lock-register-icon:hover { text-decoration: none !important; }
  /* Trang đăng ký: icon trên + dưới xoay thêm 180° */
  #lock-view-register .global-lock-img { transform: rotate(180deg); }
  #lock-view-register .lock-register-icon { transform: rotate(0deg); }
  #lock-view-register .lock-register-icon.flip { transform: rotate(180deg); }
  .global-lock-card .global-lock-btn {
    width: 100%; margin-top: 22px; padding: 12px; font-size: 15px;
    background: transparent; color: var(--text-main);
    border: 1px solid rgba(148,163,184,.3); border-radius: 12px;
    cursor: pointer; transition: border-color .2s, color .2s;
  }
  .global-lock-card .global-lock-btn:hover { border-color: var(--cyan); color: var(--cyan); }
  .global-lock-card .global-lock-btn:disabled { opacity: .5; cursor: default; }
  .global-lock-hint { min-height: 20px; margin-top: 12px; font-size: 12.5px; color: #fb7185; }
  .global-lock-devices { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(148,163,184,.12); font-size: 12px; color: var(--text-dim); display: flex; align-items: center; justify-content: center; gap: 6px; opacity: .9; }
  .global-lock-devices b { color: var(--cyan); font-weight: 700; }
  /* ---------- Quản lý dữ liệu: thiết bị tin cậy ---------- */

/* ---------- Bảng ---------- */
  table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
  .sub-wrap { overflow-x: auto; border-radius: var(--radius-md) var(--radius-md) 0 0; }
  .sub-wrap table { table-layout: fixed; }
  .sub-wrap th, .sub-wrap td { padding-left: 6px; padding-right: 6px; }
  .sub-wrap tbody td { white-space: normal; word-break: break-word; }
  .sub-wrap th:nth-child(1), .sub-wrap td.sub-name { width: 34%; }
  .sub-wrap th:nth-child(2), .sub-wrap td.sub-cat { width: 22%; }
  .sub-wrap th:nth-child(3), .sub-wrap td.sub-amt { width: 22%; }
  .sub-wrap th:nth-child(4), .sub-wrap td.sub-date { width: 22%; }
  .sub-wrap thead th { font-size: 11px; padding: 8px 5px; }
  .sub-wrap td.sub-cat { white-space: normal; }
  .sub-badge { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; font-size: 10.5px; padding: 2px 6px; }
  thead th {
    background: var(--bg-main);
    color: var(--text-main);
    font-weight: 700;
    padding: 10px 12px;
    text-align: center;
    border: 1px solid var(--glass-border);
    white-space: nowrap;
    letter-spacing: .4px;
    position: sticky;
    top: 0;
  }
  tbody td {
    padding: 9px 12px;
    border: 1px solid var(--glass-border);
    background: rgba(10,17,31,0.72);
    white-space: nowrap;
    transition: background .25s, box-shadow .25s;
  }
  tbody tr { animation: rowIn .5s ease both; }
  tbody tr:nth-child(even) td { background: rgba(14,23,41,0.82); }
  tbody tr:hover td {
    background: rgba(30,41,59,0.9);
    box-shadow: none;
  }
  @keyframes rowIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  td.num { text-align: right; font-variant-numeric: tabular-nums; }
  td.center { text-align: center; }
  td.sp { font-weight: 650; color: #dfeaff; }

  /* ---------- Dòng tổng giá trị ---------- */
  .total-row td {
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-top: 1px solid var(--hairline);
    text-align: right;
    animation: none;
  }
  /* Hàng Tổng trong bảng quỹ — cùng ngôn ngữ với các hàng sản phẩm */
  .fund-total-row td {
    border-top: 1px solid var(--hairline);
    font-size: 15px;
    font-weight: 740;
    padding-top: 13px;
    padding-bottom: 13px;
  }
  .fund-total-row .fund-total-tag { background: rgba(255,255,255,.10); color: var(--text-main); font-weight: 870; letter-spacing: .5px; border-radius: 6px; font-size: 12.5px; }
  /* Giá trị tổng (cột Trị giá) — nổi bật bằng màu accent */
  .fund-total-row td[data-val] {
    color: var(--cyan);
    font-weight: 890;
    font-size: 17px;
  }
  .total-label {
    color: var(--text-dim);
    font-weight: 700;
    font-size: 13px;
    margin-right: 10px;
  }
  .total-value {
    color: var(--cyan);
    font-weight: 700;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
  }
  .total-unit {
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 600;
    margin-left: 6px;
  }

  /* ---------- Tag phân loại ---------- */
  .tag {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
    transition: transform .2s, box-shadow .2s;
  }
  .tag:hover { transform: translateY(-1px); }
  .tag.tp {
    background: rgba(249,115,22,0.14);
    color: #fdba74;
    box-shadow: none;
    border: 1px solid rgba(249,115,22,0.35);
  }
  .tag.cb {
    background: rgba(113,112,255,0.14);
    color: var(--cyan);
    box-shadow: none;
    border: 1px solid rgba(113,112,255,0.35);
  }
  .tag.unk {
    background: rgba(203,213,225,0.10);
    color: var(--text-dim);
    border: 1px solid var(--glass-border);
  }
  .tag.cp {
    background: rgba(52,211,153,0.14);
    color: #6ee7b7;
    box-shadow: none;
    border: 1px solid rgba(52,211,153,0.35);
  }
  .tag.mmf {
    background: rgba(167,139,250,0.14);
    color: #c4b5fd;
    box-shadow: none;
    border: 1px solid rgba(167,139,250,0.35);
  }

  .pl.tp { color: var(--red); font-weight: 700; }
  .pl.cb { color: var(--green); font-weight: 700; }
  .pl.cp { color: var(--green); font-weight: 700; }
  .pl.mmf { color: var(--violet); font-weight: 700; }
  .pl.loi { color: var(--green); font-weight: 700; }
  .pl.lo { color: var(--red); font-weight: 700; }
  .pl.unk { color: var(--text-main); font-weight: 700; }
  .ty-trong { color: var(--cyan); font-weight: 700; }

  /* ---------- Chi theo tuần ---------- */
  .ct-week-picker { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--glass-border); border-radius: 12px; margin-bottom: 10px; }
  .ct-week-select { flex: 0 1 auto; min-width: 0; appearance: none; -webkit-appearance: none; background: rgba(15,23,42,0.55); color: var(--text-main); border: 1px solid var(--glass-border); border-radius: 9px; padding: 8px 30px 8px 12px; font-size: 13px; font-weight: 700; font-family: var(--font); cursor: pointer;
    background-image: linear-gradient(45deg, transparent 48%, #a99bff 49%, #a99bff 51%, transparent 52%), linear-gradient(135deg, transparent 48%, #a99bff 49%, #a99bff 51%, transparent 52%);
    background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
  html[data-theme="light"] .ct-week-select { background-color: rgba(255,255,255,0.85); background-image: linear-gradient(45deg, transparent 48%, #7c3aed 49%, #7c3aed 51%, transparent 52%), linear-gradient(135deg, transparent 48%, #7c3aed 49%, #7c3aed 51%, transparent 52%); }
  .ct-week-sum { margin-left: auto; font-size: 14px; color: var(--text-dim); white-space: nowrap; }
  .ct-week-sum b { color: #fbbf24; font-weight: 800; }
  html[data-theme="light"] .ct-week-sum b { color: #b45309; }

  /* ---------- Biểu đồ ---------- */
  #sunburst {
    width: 100%;
    height: 545px;
    background: rgba(8,14,26,0.6);
    border: 1px solid var(--glass-border);
    border-radius: 0 0 16px 16px;
    box-shadow: none;
  }

  /* Treemap "mờ" trước khi mở khóa: chỉ hiện khung + số ô, không lộ tỷ trọng thật */
  #treemapBox { position: relative; }
  #treemapBox.blurred #sunburst {
    filter: blur(7px);
    opacity: .70;
    pointer-events: none;
  }
  #treemapLock {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-dim);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: .5px;
    background: rgba(6,11,20,0.35);
    border-radius: 0 0 16px 16px;
    z-index: 5;
    pointer-events: none;
  }
  #treemapBox.blurred #treemapLock { display: flex; }

  #legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-bottom: none;
    border-radius: 14px 14px 0 0;
    margin-top: 30px;
    font-size: 12.5px;
  }
  #legend .lg-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.035);
    border: 1px solid var(--glass-border);
    transition: transform .2s, box-shadow .2s;
  }
  #legend .lg-item:hover { transform: translateY(-2px); box-shadow: none; }
  #legend .lg-swatch { width: 16px; height: 16px; border-radius: 5px; box-shadow: none; }
  #legend .lg-name { font-weight: 700; }
  #legend .lg-pct { color: var(--text-dim); font-weight: 700; }
  #legend .lg-total {
    margin-left: auto;              /* đẩy sang phải, cùng hàng với các nhóm phân loại */
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 10px;
    background: rgba(113,112,255,0.08);
    border: 1px solid var(--hairline);
    color: var(--text-dim);
    font-weight: 700;
    box-shadow: none;
    white-space: nowrap;
  }
  #legend .lg-total b { color: var(--cyan); }
  #legend .lg-total { transition: transform .2s, box-shadow .2s; }
  #legend .lg-total:hover {
    transform: translateY(-2px);
    box-shadow: none;
  }
  /* Nhãn trở thành nút lọc treemap */
  #legend .lg-item, #legend .lg-total { cursor: pointer; user-select: none; }
  #legend .lg-item.active {
    background: rgba(113,112,255,0.14);
    border-color: var(--cyan);
    box-shadow: none;
  }
  #legend .lg-total.active {
    border-color: var(--green);
    box-shadow: none;
  }
  .table-wrapper {
    overflow-x: auto;
    border-radius: 0 0 14px 14px;
    border: 1px solid var(--glass-border);
    border-top: none;
    background: var(--bg-main); box-shadow: none;
  }

  /* ---------- Ghi chú ---------- */
  .note {
    position: relative;
    z-index: 2;
    max-width: 1216px;
    margin: 22px auto 0;
    font-size: 11.5px;
    color: var(--text-dim);
    line-height: 1.7;
    border: 1px dashed var(--glass-border);
    border-radius: 12px;
    padding: 14px 18px;
    background: var(--bg-card);
  }
  .note b { color: var(--cyan); }

  /* ---------- Hướng dẫn Pass (Vaultwarden) ---------- */
  .pass-help {
    margin-top: 14px;
    font-size: 11.5px;
    color: var(--text-dim);
    line-height: 1.7;
    border: 1px dashed var(--glass-border);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--bg-card);
  }
  .pass-help-title { font-weight: 600; color: var(--cyan); margin-bottom: 6px; font-size: 12px; }
  .pass-help-text { margin-bottom: 8px; }
  .pass-help-text b { color: var(--cyan); }
  .pass-help-row {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 4px 0; border-top: 1px solid var(--glass-border);
  }
  .pass-help-row span { white-space: nowrap; color: var(--text-dim); }
  .pass-help-row code, .pass-help code {
    background: var(--bg-main); color: var(--cyan);
    padding: 2px 6px; border-radius: 6px; font-size: 10.5px;
    word-break: break-all; text-align: right;
  }
  .pass-help-note { font-size: 10.5px; opacity: .8; margin: 4px 0 8px; }
  .pass-help-sub { font-size: 11px; margin: 8px 0 4px; color: var(--text-dim); }
  .pass-copy {
    flex: 0 0 auto;
    background: var(--bg-main);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--cyan);
    font-size: 12px;
    line-height: 1;
    padding: 4px 7px;
    cursor: pointer;
  }
  .pass-copy:hover { background: var(--cyan); color: var(--bg-main); }

  /* ---------- Thanh cuộn ---------- */
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: var(--cyan);
    border-radius: 8px;
    border: 2px solid var(--bg-main);
  }
  ::-webkit-scrollbar-thumb:hover { box-shadow: none; }

  /* ---------- Con trỏ neon ---------- */
  .cursor-glow {
    position: fixed;
    top: 0; left: 0;
    width: 390px; height: 390px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 2147483000;
    background: none;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity .35s ease;
    mix-blend-mode: screen;
    will-change: transform;
  }

  /* ---------- Scroll reveal ---------- */
  .reveal {
    opacity: 0;
    transform: translateY(26px);
    transition: opacity .7s cubic-bezier(.22,.61,.36,1), transform .7s cubic-bezier(.22,.61,.36,1);
  }
  .reveal.in-view { opacity: 1; transform: translateY(0); }

  /* ---------- Giảm chuyển động & thiết bị cảm ứng ---------- */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: .01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: .01ms !important;
    }
    .cursor-glow { display: none; }
    .reveal { opacity: 1; transform: none; }
  }
  @media (hover: none) { .cursor-glow { display: none; } }

  @container (max-width: 820px) {
    body { padding: 14px; font-size: 12px; }
    /* Ẩn các cột phụ khi màn hình hẹp (điện thoại) để bảng dễ đọc */
    .hide-sm { display: none; }
    td.sp { white-space: normal; word-break: break-word; }
    thead th { white-space: normal; }
    .top-info { flex-direction: column; align-items: flex-start; }
  }

  /* ---------- Thanh điều hướng tab ---------- */
  
  /* ---------- Header + KPI tổng quan ---------- */
  .main-tabbar {
      max-width: 1216px;
      margin: 0 auto;
      padding: 26px 30px 6px;
    }
  .main-tab-container {
    border: 1px solid rgba(153,120,255,.4);
    border-radius: 20px;
    background: rgba(255,255,255,.014);
    box-shadow: none;
    overflow: hidden;
  }
  .main-tab-head-row { display: flex; justify-content: center; align-items: stretch; gap: 10px; padding: 20px 0 6px; width: fit-content; margin: 0 auto; }
  .main-tab-head-row .main-tab-head { flex: 0 1 auto; width: auto; }
  .main-tab-head { flex: 1; }
  .header-lock {
    flex: 0 0 auto;
    align-self: center;
    padding: 16px 18px;
    border: 1px solid rgba(198,168,255,.35);
    border-radius: 14px;
    background: rgba(47,30,96,.25);
    font-size: 19px;
    cursor: pointer;
    transition: all .2s ease;
  }
  .header-lock:hover { border-color: rgba(251,113,133,.6); background: rgba(225,29,72,.18); }
  .main-tab-head {
      display: flex;
      align-items: center;
      gap: 14px;
      width: 100%;
      padding: 17px 22px;
      cursor: pointer;
      border-radius: 998px;
      background: rgba(255,255,255,0.04);
      transition: all .2s ease;
      font-family: inherit;
    }
  .main-tab-head:hover { background: rgba(255,255,255,0.07); }
  .main-tab-logo { font-size: 28px; line-height: 1; }
  .main-tab-titles { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
  .main-tab-title { font-family: var(--font-serif); font-size: 22px; font-weight: 700; color: #f8fbff; }
  .main-tab-sub { font-size: 11px; color: var(--text-dim); }
  .main-tab-switch { margin-left: auto; font-size: 13px; font-weight: 600; color: #c4b5fd; background: rgba(33,20,80,.35); border: 1px solid rgba(187,155,255,.35); padding: 7px 15px; border-radius: 999px; transition: all .2s ease; white-space: nowrap; }
  .main-tab-head:hover .main-tab-switch { background: rgba(40,24,92,.45); color: #ddd6fe; }
  .main-tab-body { display: none; }
  .main-tab-body.active { display: block; padding: 8px 24px 26px; border-top: 1px dashed rgba(161,178,205,.26); }
  /* Tab Đời sống: chống tràn ngang (KPI/rail/bảng) */
  #life-body { overflow-x: hidden; max-width: 100%; }
  #life-body > * { max-width: 100%; }

  @container (max-width: 740px) {
    .main-tabbar { padding: 18px 14px 6px; }
    .main-tab-head { padding: 14px 18px; }
    .main-tab-title { font-size: 18px; }
    .main-tab-body { padding: 2px 16px 18px; }
  }
  .app-brand { display: flex; align-items: center; gap: 14px; }
  .app-logo {
    font-size: 30px;
    width: 58px; height: 58px;
    display: grid; place-items: center;
    border-radius: 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(127,166,224,0.22);
    box-shadow: none;
  }
    .app-eyebrow {
    margin: 0 0 2px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--cyan);
  }
.app-title {
    font-family: var(--font-serif);
    font-size: 30px;
    font-weight: 400;
    line-height: 1.1;
    margin: 0;
    letter-spacing: 0.2px;
    color: var(--text-main);
  }
  .app-sub { font-size: 13px; color: var(--text-dim); margin: 5px 0 0; font-family: var(--font-mono); }

  .kpi-row {
    max-width: 1216px;
    margin: 14px auto 6px;
    padding: 0 6px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 13px;
  }
  .kpi-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 18px 20px;
    overflow: hidden;
    transition: transform .2s, border-color .2s;
  }
  .kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--cyan);
    opacity: 0.7;
  }
  .kpi-card::before {
    content: "";
    position: absolute; inset: 0;
    background: none;
    pointer-events: none;
  }
  .kpi-card:hover { transform: translateY(-2px); border-color: rgba(122,164,240,0.35); }
  .kpi-card.kpi-survive {
    background: var(--bg-card);
    border-color: rgba(247,188,54,0.30);
  }
  .kpi-card.kpi-survive .kpi-value { color: #f6c453; }

  /* Card gộp "Tài sản / Dư sống" — 2 dòng trong 1 card, làm nổi 2 giá trị */
  .kpi-card.kpi-combined {
    grid-column: 1 / -1;
    padding: 14px 22px;
  }
  .kpi-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 3px 0;
  }
  .kpi-line .kpi-value {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: 0.3px;
    font-variant-numeric: tabular-nums;
  }
  .kpi-line + .kpi-line {
    border-top: 1px solid rgba(126,166,224,0.14);
    margin-top: 8px;
    padding-top: 10px;
  }
  #kpi-toggle { position: relative; cursor: pointer; }
  #kpi-toggle .kpi-toggle-arrow {
    position: absolute; right: 14px; top: 50%;
    transform: translateY(-50%);
    color: #f6c453; font-size: 28px; font-weight: 700; line-height: 1;
    transition: transform .2s ease; pointer-events: none;
  }
  #kpi-toggle.open .kpi-toggle-arrow { transform: translateY(-50%) rotate(180deg); }
  .kpi-assets-val { color: var(--cyan); }
  .kpi-survive-val { color: #f6c453; }
  .kpi-alive-val { color: #34d399; }
  .kpi-spent-val { color: #fb7185; }

  /* ---------- Phân bổ tài sản ---------- */
.alloc-card {
    max-width: 1216px;
    margin: 16px auto 4px;
    padding: 18px 22px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
  }
  .alloc-head { margin-bottom: 14px; }
  .alloc-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); }
  .alloc-body { display: flex; align-items: center; gap: 26px; }
  .alloc-chart { width: 230px; height: 165px; flex: 0 0 auto; }
  /* Ép biểu đồ không vượt khung (ECharts init khi ẩn đo sai width) */
  .alloc-chart, .alloc-chart svg, .alloc-chart canvas {
    max-width: 344px !important;
    min-width: 0 !important;
  }

  .alloc-list { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
  .alloc-item { display: flex; align-items: center; gap: 10px; font-size: 15px; }
    .alloc-dot { width: 12px; height: 12px; border-radius: 999px; flex: 0 0 auto; }
    .alloc-item-name { color: var(--text-dim); flex: 1; font-size: 15px; }
    .alloc-item-val { font-weight: 650; color: var(--text-main); font-size: 15px; }
    .alloc-item-pct { color: var(--text-dim); font-size: 14px; min-width: 52px; text-align: right; }
  @container (max-width: 680px) {
    .alloc-body { flex-direction: column; }
    .alloc-chart { width: 360px; height: 205px; }
    .alloc-list { grid-template-columns: 1fr; }
  }
  .kpi-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); margin-bottom: 7px; }
  .kpi-value { display: block; font-size: 20px; font-weight: 700; color: var(--text-main); }
  .kpi-value.up { color: var(--green); }
  .kpi-value.down { color: var(--red); }

  @container (max-width: 760px) {
    .kpi-row { grid-template-columns: 1fr; padding: 0 20px; }
    .app-header { padding: 20px 20px 6px; }
  }
.tabnav {
    position: relative;
    z-index: 3;
    max-width: 1216px;
    margin: 0 auto 22px;
    display: flex;
    gap: 6px;
    padding: 6px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: none;
    animation: fadeUp .7s ease both;
  }
  .tab-btn {
    flex: 0 0 auto;
    padding: 11px 16px;
    border: none;
    border-radius: 11px;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 13.5px;
    font-weight: 700;
    letter-spacing: .4px;
    cursor: pointer;
    transition: all .25s;
  }
  .tab-btn:hover { color: var(--text-main); background: rgba(255,255,255,0.045); }

  /* Đồng nhất độ rộng tab trên máy tính (≥960px) */
  @container (min-width: 960px) {
    .tab-btn { flex: 1 1 0; padding: 12px 6px; text-align: center; white-space: nowrap; }
    .lock-toggle { flex: 0 0 auto; padding: 12px 14px; }
  }

  /* Bộ chọn tab cho màn hình hẹp (mobile) */
    .mobile-tabs { display: none; }
    @container (max-width: 808px) {
      .tabnav { display: none; }
      /* Sub-tab Đời sống luôn hiện trên màn hình hẹp, đặt dưới bảng phân bố thời gian */
      .tabnav.lifetab-nav { display: flex; margin: 14px auto 4px; }
      .tabnav.lifetab-nav .tab-btn { flex: 1 1 0; text-align: center; white-space: nowrap; }
    .mobile-tabs {
          display: flex;
          align-items: center;
          gap: 9px;
          max-width: 1320px;
          margin: 10px auto 4px;
          padding: 10px 14px;
          background: var(--bg-card);
          border: 1px solid rgba(139,151,255,0.22);
          border-radius: 14px;
          box-shadow: none;
        }
    .mobile-tabs select {
      flex: 1;
      appearance: none; -webkit-appearance: none; -moz-appearance: none;
      background-color: rgba(14,17,32,0.75);
      background-image:
        
        url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%237170ff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
      background-repeat: no-repeat;
      background-position: right 13px center;
      background-size: 15px;
      color: var(--text-main);
      border: 1px solid rgba(113,112,255,0.35);
      border-radius: 12px;
      padding: 11px 36px 11px 14px;
      font-size: 14px;
      font-weight: 600;
      letter-spacing: 0.2px;
      cursor: pointer;
      box-shadow: none;
      transition: border-color .2s, box-shadow .2s, transform .15s;
    }
    .mobile-tabs select:active { transform: scale(0.99); }
    .mobile-tabs select:focus {
          outline: none;
          border-color: var(--cyan);
          box-shadow: none;
        }
      }
  .tab-btn.active {
    color: #ffffff;
    background: var(--cyan);
    box-shadow: none;
  }
  .tab-panel { position: relative; z-index: 2; max-width: 1216px; margin: 0 auto; width: 100%; }

  /* ===================== BOTTOM-NAV (mobile-first) =====================
   * Fixed bottom, touch target ≥48px, ngón cái chạm dễ.
   * Ẩn trên desktop (≥860px), hiện trên mobile + tablet.
   */
  .bottom-nav {
    display: none;
  }
  @container (max-width: 860px) {
    .bottom-nav {
      display: flex;
      position: fixed;
      bottom: 0; left: 0; right: 0;
      z-index: 60;
      justify-content: space-around;
      align-items: stretch;
      gap: 2px;
      padding: 6px 4px max(6px, env(safe-area-inset-bottom)) 4px;
      background: #101113;
      border-top: 1px solid rgba(148,163,255,0.18);
      box-shadow: none;
    }
    .bottom-nav-spacer { height: 78px; }
    .bn-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 3px;
      flex: 1 1 0;
      min-height: 48px;          /* touch target ≥48px */
      min-width: 44px;
      padding: 6px 2px;
      border: none;
      background: transparent;
      color: var(--text-dim);
      font-family: inherit;
      font-size: 10px;
      font-weight: 600;
      cursor: pointer;
      border-radius: 10px;
      transition: color .15s, background .15s, transform .1s;
    }
    /* Nút Cài đặt trên bottom-nav chỉ hiện khi Đời sống bị ẩn hoàn toàn */
    #bn-settings[hidden] { display: none !important; }
    .bn-item.bn-lock { color: rgba(251,113,133,0.7); }
    .bn-icon { font-size: 20px; line-height: 1; }
    .bn-label { font-size: 9px; line-height: 1.15; letter-spacing: 0.2px; white-space: nowrap; text-transform: uppercase; }
    .bn-item:active { transform: scale(0.94); background: rgba(113,112,255,0.14); }
    .bn-item.active {
      color: #ffffff;
      background: var(--cyan);
      box-shadow: none;
    }
    .bn-item.active .bn-label { font-weight: 700; }

    /* Vạch phân cách giữa các tab — màu nổi, trừ tab cuối (bn-lock) */
    .bn-item:not(:last-child) {
      border-right: 1px solid var(--hairline);
    }
    .bn-item.active:not(:last-child) {
      border-right-color: rgba(255,255,255,0.55);
    }

    /* Ẩn tabnav desktop + mobile-tabs cũ khi có bottom-nav */
        .tabnav#finance-tabnav { display: none; }
        .mobile-tabs { display: none; }

        /* Mobile: ẩn nút tiêu đề (Tài chính/Đời sống cá nhân) + nút khóa — đã có trong bottom-nav */
        #main-toggle, #lock-toggle { display: none; }
        /* Hàng tiêu đề rỗng (nút đã ẩn) → ẩn cả hàng, xóa khoảng trống trên cùng */
        .main-tab-head-row { display: none !important; }

    /* Body padding giảm trên mobile */
    body { padding: 4px 8px 76px !important; font-size: 13px; }
    .main-tabbar { padding: 4px 8px 0; }
    .main-tab-head-row { padding: 10px 0 4px; flex-wrap: wrap; gap: 6px; }
    .main-tab-head { padding: 10px 14px; }
    .main-tab-title { font-size: 18px; }
    .main-tab-logo { font-size: 24px; }
    .main-tab-body { padding: 2px 8px 14px; }
    .main-tab-body.active { padding: 2px 8px 14px; }

    /* KPI: 1 cột trên mobile */
    .kpi-row { flex-direction: column; gap: 10px; padding: 8px; }
    .kpi-card { min-width: 100%; }

    /* Bảng: cuộn ngang, ẩn cột phụ */
    .hide-sm { display: none; }
    table { font-size: 12px; }
    thead th { white-space: normal; }

    /* Form chi tiêu: 1 cột */
    .ct-form { flex-direction: column; gap: 10px; }
    .ct-total-box, .ct-add-box { flex: 1 1 100%; }
    .ct-add-box { flex-direction: column; align-items: stretch; }
    .ct-add-box input, .ct-add-box .ct-dd { width: 100%; }
    .ct-add-fields, .ct-add-side { width: 100%; }
    .ct-add-side { flex-direction: row; flex-wrap: wrap; align-items: flex-start; }
    .ct-save-col { flex-direction: row; }
    .ct-save-col .btn { width: auto; flex: 1 1 0; }
    .ct-quick { flex: 1 1 auto; grid-template-columns: repeat(3, minmax(0,1fr)) auto; }
    .ct-quick-btn { max-width: none; }
    .ct-quick-config { width: 100%; }
    .ct-qc-row { grid-template-columns: 1fr 72px 1fr; }

    /* Biểu đồ chiề cao thấp */
    .section-title { font-size: 13px; }

    /* Bảng: bỏ khung bao quanh, header gạch chân kéo dài toàn bộ chiều rộng */
    .main-tab-container {
      border: none !important;
      border-radius: 0 !important;
      background: transparent !important;
      box-shadow: none !important;
      overflow-x: hidden !important;
    }
    /* Chống tràn ngang tab Đời sống (chart cố định, bảng rộng) */
    #life-body, #finance-body { overflow-x: hidden; max-width: 100%; }
    #life-body > *, #finance-body > * { max-width: 100%; }
    #life-body table, #finance-body table { min-width: 0; }
    .table-wrapper, .stock-table-wrap, .gold-table-wrap, .gold-own-wrap,
    .ct-table-wrap, .ct-cat-wrap, .dm-table-wrap {
      border: none !important;
      border-radius: 0 !important;
      background: transparent !important;
      box-shadow: none !important;
    }

    /* Đồng nhất độ rộng bảng: vàng sở hữu full-width, khớp các bảng khác */
    .gold-card { padding-left: 14px !important; padding-right: 14px !important; min-width: 0 !important; }
    .gold-own-wrap table { width: 100%; }
    .gold-own-wrap th, .gold-own-wrap td { white-space: normal; word-break: break-word; }
    .gold-own-note-cell { max-width: none; white-space: normal; }
    /* Form thêm vàng: xếp dọc để không ép card rộng */
    .gold-own-add { flex-direction: column !important; align-items: stretch !important; }
    .gold-own-add .stock-field, .gold-own-add .gold-own-note { min-width: 0 !important; width: 100% !important; }
    .gold-own-add input { width: 100% !important; box-sizing: border-box !important; }
    .gold-own-add .btn-primary { align-self: stretch !important; }
    .gold-card-head { font-size: 15px !important; flex-wrap: wrap !important; line-height: 1.3; }
    /* Máy tính mua/bán: giá trị dài không tràn ra ngoài card */
    .gold-calc-result { grid-template-columns: 1fr 1fr; }
    .gold-result-card { min-width: 0 !important; padding: 12px 8px !important; }
    .gold-result-val { font-size: clamp(14px, 4.5vw, 20px) !important; overflow-wrap: break-word; word-break: break-word; line-height: 1.25; }
    /* Chi tiêu: tổng chi bỏ dấu "=", giá trị xuống dòng riêng */
    .ct-total-eq { display: none !important; }
    .ct-total-box { flex: 1 1 100% !important; min-width: 0 !important; max-width: 100% !important; }
    .ct-total-val {
      flex-basis: 100% !important;
      text-align: left !important;
      min-width: 0 !important;
      font-size: clamp(18px, 6.5vw, 33px) !important;
      white-space: normal !important;
      overflow-wrap: anywhere;
      word-break: break-all;
      line-height: 1.25;
    }
    .alloc-card { padding-left: 14px; padding-right: 14px; }
    .alloc-chart, #life-alloc-chart { max-width: 344px !important; min-width: 0 !important; }
    .alloc-body { flex-wrap: wrap; }
    thead th, tbody td { border: none !important; }
    thead th {
      border-bottom: 1px solid var(--hairline) !important;
      background: transparent !important;
    }
    tbody td { border-bottom: 1px solid rgba(148,163,184,0.10) !important; }
    tbody tr:last-child td { border-bottom: none !important; }
    .total-row td { border: none !important; border-top: 1px solid var(--hairline) !important; }
  }

  /* ≥861px: desktop → bottom-nav ẩn, tabnav cũ hiện */
  @container (min-width: 861px) {
    .bottom-nav { display: none; }
    .bottom-nav-spacer { display: none; }
  }

  /* ---------- Animation chuyển tab (fade-in + stagger) ---------- */
  @keyframes panelIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes itemIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
  .tab-panel.panel-enter { animation: panelIn 0.35s cubic-bezier(.22,1,.36,1) both; }
  .tab-panel.panel-enter .section-title,
  .tab-panel.panel-enter .card,
  .tab-panel.panel-enter .stat-card,
  .tab-panel.panel-enter .stock-card,
  .tab-panel.panel-enter .gold-card,
  .tab-panel.panel-enter .dep-card,
  .tab-panel.panel-enter .sub-card,
  .tab-panel.panel-enter .ct-card { animation: itemIn 0.42s cubic-bezier(.22,1,.36,1) both; }
  .tab-panel.panel-enter .section-title { animation-delay: 0.04s; }
  .tab-panel.panel-enter .card:nth-child(1) { animation-delay: 0.08s; }
  .tab-panel.panel-enter .card:nth-child(2) { animation-delay: 0.14s; }
  .tab-panel.panel-enter .card:nth-child(3) { animation-delay: 0.20s; }
  .tab-panel.panel-enter .card:nth-child(4) { animation-delay: 0.26s; }
  .tab-panel.panel-enter .card:nth-child(5) { animation-delay: 0.32s; }
  .tab-panel.panel-enter .card:nth-child(6) { animation-delay: 0.38s; }

  .tab-panel.hidden { display: none; }
  .tab-right { margin-left: auto; }

  /* ---------- Toast thông báo ---------- */
  .toast-wrap {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
  }
  .toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    background: var(--bg-main);
    border: 1px solid rgba(148,163,255,0.25);
    box-shadow: 0 12px 32px rgba(0,0,0,.5);
    animation: toastIn .3s ease;
  }
  .toast.success { border-color: rgba(74,222,128,0.45); }
  .toast.success .toast-icon { color: #4ade80; }
  .toast.error { border-color: rgba(255,107,107,0.5); }
  .toast.error .toast-icon { color: #ff6b6b; }
  .toast.info { border-color: rgba(113,112,255,0.45); }
  .toast.info .toast-icon { color: var(--cyan); }
  .toast-icon { font-size: 18px; }
  @keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
  .toast.out { animation: toastOut .3s ease forwards; }
  @keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
  /* ============================================================
   * REDESIGN — token đã hợp nhất vào :root đầu file (2026-08-26)
   * ============================================================ */

  /* Nền tinh tế hơn, bớt neon */
  body {
    background:
      var(--bg-deep);
  }

  /* Typography discipline */
  .section-title { letter-spacing: 0.085em; }
  .kpi-label { letter-spacing: 0.095em; }
  thead th { letter-spacing: 0.062em; text-transform: uppercase; }
  .app-eyebrow { letter-spacing: 0.30em; }
  .ct-total-label { letter-spacing: 0.09em; }

  /* State coverage: loading / error + retry */
  .ct-empty { animation: none; }
  .ct-error { padding: 34px 0; }
  .ct-err-msg { color: var(--red); margin-bottom: 14px; font-size: 13px; }
  .ct-retry { margin: 0 auto; }

  /* Phân tích danh mục — gộp vào card phân bổ, ngăn cách bằng đường kẻ mạnh */
  .ana-sep { border-top: 1px solid var(--ana-divider); margin: 18px 0 0; }
  .ana-grid { display: grid; grid-template-columns: 1fr 1fr; margin-top: 14px; }
  .ana-row { padding: 14px 16px; }
  .ana-row:nth-child(even) { border-left: 1px solid var(--ana-divider); }
  .ana-row:nth-child(n+3) { border-top: 1px solid var(--ana-divider); }
  .ana-label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
  .ana-value { display: block; font-size: 18px; font-weight: 750; color: var(--text-main); font-variant-numeric: tabular-nums; }
  .ana-value.pos { color: var(--green); }
  .ana-value.neg { color: var(--red); }
  .ana-status { font-size: 12px; color: var(--text-faint); margin-top: 8px; }

  /* Buttons — bỏ gradient "trust", dùng solid accent */
  .btn-primary {
    background: var(--cyan);
    color: #ffffff;
    border: none;
    box-shadow: none;
  }
  .btn-primary:hover { background: #828fff; filter: none; }
  .btn-primary:active { transform: translateY(1px); }
  .btn { border-radius: var(--radius-md); }

  /* Tab active — solid accent */
  .tab-btn.active {
    color: #ffffff;
    background: var(--cyan);
    box-shadow: none;
  }
  .tabnav { border-radius: 14px; border-color: var(--hairline); }

  /* Cards — đồng bộ radius + border mượt */
  .kpi-card, .alloc-card, .gold-card, .gold-calc, .ct-total-box, .ct-add-box,
  .table-wrapper, .toolbar, .note, .top-info, .dm-card, .dm-lock-card {
    border-color: var(--hairline);
    border-radius: var(--radius-lg);
    box-shadow: none;
  }
  .kpi-card::before { height: 2px; opacity: 0.45; }

  /* Bảng — header phẳng, phân cách mảnh */
  thead th {
    background: rgba(148,163,184,0.055);
    color: var(--text-dim);
    font-weight: 650;
    font-size: 11px;
    border: none;
    border-bottom: 1px solid var(--hairline);
  }
  tbody td {
    border: none;
    border-bottom: 1px solid rgba(148,163,184,0.08);
    background: transparent;
  }
  tbody tr:nth-child(even) td { background: rgba(148,163,184,0.032); }
  tbody tr:hover td { background: rgba(113,112,255,0.055); box-shadow: none; }
  tbody tr:last-child td { border-bottom: none; }

  /* Inputs — focus rõ ràng */
  input, select, textarea {
    border-radius: 10px;
  }
  input:focus, select:focus, textarea:focus {
    border-color: rgba(113,112,255,0.55) !important;
    box-shadow: none;
    outline: none;
  }

  /* Scrollbar — mượt hơn */
  ::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.35);
    border: 2px solid var(--bg-main);
  }
  ::-webkit-scrollbar-thumb:hover { box-shadow: none; }

  /* Focus-visible cho bàn phím */
  :focus-visible {
    outline: 2px solid rgba(113,112,255,0.7);
    outline-offset: 2px;
  }

  /* Tôn trọng prefers-reduced-motion */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.001s !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.001s !important;
      scroll-behavior: auto !important;
    }
  }

  /* Mobile: giảm bớt hiệu ứng nặng */
  @container (max-width: 860px) {
    .kpi-card { border-radius: var(--radius-md); }
  }

  /* ============================================================
     THEME SÁNG (light) — kích hoạt bằng <html data-theme="light">
     ============================================================ */
  html[data-theme="light"] {
    --bg-deep: #e6dcc3;
    --bg-main: #efe8d2;
    --bg-card: #faf5e6;
    --bg-card-solid: #faf5e6;
    --glass-border: rgba(104,82,44,0.16);
    --hairline: rgba(108,85,46,0.14);
    --ana-divider: rgba(108,85,46,0.18);
    --text-main: #2c2414;
    --text-dim: #5a4c30;
    --text-faint: #786a42;
    --cyan: #8a5f24;
    --cyan-glow: transparent;
    --green: #4f7d3d;
    --green-glow: transparent;
    --red: #b23a2c;
    --red-glow: transparent;
    --violet: #8a5a44;
    --amber: #a16207;
    --shadow-card: none;
    --chart-tip-bg: rgba(250,245,230,0.97);
    --chart-tip-border: rgba(106,84,44,0.16);
    --chart-tip-text: #2c2414;
    --chart-tip-sub: #5a4c30;
    --chart-tip-strong: #2c2414;
    --chart-split: rgba(115,91,50,0.12);
    --chart-axis: #6b5d3f;
    color-scheme: light;
  }
  html[data-theme="light"] body {
    background:
      #eee7cf;
  }
  /* Nền cứng dark → giấy cũ (không còn trắng gắt / xanh lạnh) */
  html[data-theme="light"] .kpi-card,
  html[data-theme="light"] .dm-card {
    background: #f8f2e1;
  }
  html[data-theme="light"] .table-wrapper {
    background: rgba(250,245,230,0.82);
    border-color: rgba(111,88,48,0.14);
    box-shadow: none;
  }
  html[data-theme="light"] .alloc-card {
    background: #f8f2e1;
  }
  html[data-theme="light"] .kpi-card.kpi-survive {
    background: #f3e3b8;
  }
  html[data-theme="light"] .mobile-tabs {
    background: #f5efdb;
    border-color: rgba(111,88,48,0.14);
    box-shadow: none;
  }
  html[data-theme="light"] .bottom-nav {
    background: #f5efdb;
    border-top-color: rgba(111,88,48,0.14);
    box-shadow: none;
  }
  html[data-theme="light"] .bn-item:not(:last-child) {
    border-right-color: rgba(15,23,42,0.14);
  }
  html[data-theme="light"] .bn-item.active:not(:last-child) {
    border-right-color: rgba(15,23,42,0.30);
  }
  html[data-theme="light"] .main-tab-container {
    border-color: rgba(196,168,110,0.55);
    background: rgba(246,239,216,0.6);
    box-shadow: none;
  }
  html[data-theme="light"] .main-tab-head {
    background: #e7ddc0;
  }
  html[data-theme="light"] .main-tab-title { color: #2c2414; }
  html[data-theme="light"] .main-tab-switch {
    color: #7a5418; background: rgba(228,206,160,0.6); border-color: rgba(173,132,62,0.4);
  }
  html[data-theme="light"] .main-tab-head:hover .main-tab-switch { background: rgba(223,198,146,0.7); color: #6b4a12; }
  html[data-theme="light"] .header-lock {
    border-color: rgba(156,163,175,0.4); background: rgba(241,245,249,0.7);
  }
  html[data-theme="light"] .header-lock:hover { border-color: rgba(220,38,38,0.5); background: rgba(254,226,226,0.6); }
  /* Nút chuyển theme — nổi bật nhẹ, phân biệt với nút khóa */
  .header-theme {
    border-color: rgba(125,211,252,0.4);
    background: rgba(113,112,255,0.14);
    color: var(--cyan);
  }
  .header-theme:hover { background: rgba(113,112,255,0.26); transform: translateY(-1px); }
  html[data-theme="light"] .header-theme {
    border-color: rgba(173,132,62,0.45);
    background: rgba(213,180,112,0.22);
    color: #7a5418;
  }
  html[data-theme="light"] .header-theme:hover { background: rgba(209,174,104,0.34); }
  html[data-theme="light"] .app-logo {
    background: #e2d3a8;
    border-color: rgba(173,132,62,0.35);
    box-shadow: none;
  }
  /* Bảng + input — header bảng trong light: nền giấy cũ đặc, ép thắng mọi độ ưu tiên */
  html[data-theme="light"] thead th {
    background: rgba(244,236,216,0.98) !important;
    color: #2c2414 !important;
    border-color: rgba(117,92,50,0.16) !important;
  }
  html[data-theme="light"] tbody td { border-bottom: 1px solid rgba(118,93,50,0.12); }
  html[data-theme="light"] tbody tr:nth-child(even) td { background: rgba(129,101,52,0.04); }
  html[data-theme="light"] tbody tr:hover td { background: rgba(186,140,60,0.10); }
  /* Tiêu đề mỗi phần (vd "PHÂN TÍCH CHI TIÊU") — bỏ nền navy tối, sang nền giấy cũ */
  html[data-theme="light"] .section-title {
    background: #f2ebd3;
    color: #2c2414;
    border-color: rgba(117,92,50,0.14);
  }
  /* Lịch Sổ sách — chuyển chữ/ngày sang tối để đọc được trên nền giấy cũ */
  html[data-theme="light"] .sosach-cal,
  html[data-theme="light"] .sosach-detail {
    background: #f2ebd3;
    border-color: rgba(138,90,68,0.18);
    box-shadow: none;
  }
  html[data-theme="light"] .sosach-nav-btn { color: #7a5418; background: rgba(181,138,64,0.12); border-color: rgba(174,128,56,0.30); }
  html[data-theme="light"] .sosach-nav-btn:hover { background: rgba(183,140,66,0.20); }
  html[data-theme="light"] .sosach-month { color: #6b4a12; }
  html[data-theme="light"] .sosach-today { color: #7a5418; background: rgba(191,146,68,0.14); border-color: rgba(179,134,58,0.34); }
  html[data-theme="light"] .sosach-today:hover { background: rgba(189,144,66,0.22); }
  html[data-theme="light"] .sosach-week span { color: #6b5d3f; }
  html[data-theme="light"] .sosach-week span:last-child { color: #b23a2c; }
  html[data-theme="light"] .sosach-day { background: rgba(250,245,230,0.55); border-color: rgba(117,92,50,0.20); }
  html[data-theme="light"] .sosach-day:hover { background: rgba(187,143,66,0.10); border-color: rgba(181,138,64,0.32); }
  html[data-theme="light"] .sosach-day.out { opacity: .45; background: rgba(250,245,230,0.3); }
  html[data-theme="light"] .sosach-day-num { color: #3a2f1a; }
  html[data-theme="light"] .sosach-day.out .sosach-day-num { color: #94876a; }
  html[data-theme="light"] .sosach-day.today .sosach-day-num { color: #8a5f24; }
  html[data-theme="light"] .sosach-day-hol { color: #b23a2c; }
  html[data-theme="light"] .sosach-day.fast .sosach-day-num { color: #3f6b33; }
  html[data-theme="light"] .sosach-day-fast { background: rgba(79,125,61,0.18); border-color: rgba(63,107,51,0.5); color: #3f6b33; }
  html[data-theme="light"] .sosach-day.today { border: 2px solid #b8860b; background: rgba(210,160,60,0.16); box-shadow: none; }
  html[data-theme="light"] .sosach-day.today .sosach-day-num { color: #7a5418; background: rgba(205,152,52,0.22); border-radius: 8px; width: fit-content; padding: 1px 6px; }
  html[data-theme="light"] .sosach-detail-date { color: #6b4a12; }
  html[data-theme="light"] .sosach-detail-holiday { color: #b23a2c; }
  html[data-theme="light"] .ss-leg { color: #786a42; }
  html[data-theme="light"] .sosach-legend { border-top-color: rgba(138,90,68,0.18); }
  html[data-theme="light"] .sosach-detail-head { border-bottom-color: rgba(138,90,68,0.18); }
  html[data-theme="light"] .sosach-form ::placeholder { color: rgba(90,76,48,0.5); }
  /* Danh sách chi tiết Sổ sách — chữ tối trên nền giấy cũ */
  html[data-theme="light"] .sosach-empty-list { color: #786a42; }
  html[data-theme="light"] .sosach-item { background: rgba(250,245,230,0.55); border-color: rgba(117,92,50,0.20); }
  html[data-theme="light"] .sosach-item:hover { background: rgba(188,144,66,0.10); border-color: rgba(181,138,64,0.32); }
  html[data-theme="light"] .sosach-item-title { color: #3a2f1a; }
  html[data-theme="light"] .sosach-item-time { color: #8a5f24; }
  html[data-theme="light"] .sosach-item-note { color: #5a4c30; }
  html[data-theme="light"] .sosach-item-tag.note { color: #7a5418; background: rgba(193,148,66,0.14); border-color: rgba(183,138,62,0.32); }
  html[data-theme="light"] .sosach-item-tag.event { color: #8a5a44; background: rgba(192,130,100,0.14); border-color: rgba(194,134,104,0.32); }
  html[data-theme="light"] .sosach-item-tag.reminder { color: #a16207; background: rgba(208,158,50,0.16); border-color: rgba(201,148,42,0.36); }
  html[data-theme="light"] .sosach-item-check { border-color: rgba(120,106,66,0.5); }
  html[data-theme="light"] input, html[data-theme="light"] select, html[data-theme="light"] textarea { color-scheme: light; }
  html[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(120,96,50,0.30); border-color: #efe8d2; }
  /* Chart tooltip dùng biến theme */
  html[data-theme="light"] .ct-toolbar select { color-scheme: light; }
  /* Light: bỏ hiệu ứng kính (glass) + ép màu chữ tối để dễ đọc */
  html[data-theme="light"] *, html[data-theme="light"] *::before, html[data-theme="light"] *::after {
  }
  html[data-theme="light"] .dm-lock-title,
  html[data-theme="light"] .dm-title,
  html[data-theme="light"] .dm-device-name,
  html[data-theme="light"] td.sp { color: #0f172a; }
  html[data-theme="light"] .dm-refresh { color: #334155; }
  html[data-theme="light"] .dm-theme-toggle { color: #7a5418; }
  /* Light: badge/tag dùng màu pastel dark → đổi sang màu đậm đọc được trên nền sáng */
  html[data-theme="light"] .tag.tp { background: rgba(234,88,12,0.10); color: #c2410c; border-color: rgba(234,88,12,0.30); box-shadow: none; }
  html[data-theme="light"] .tag.cb { background: rgba(2,132,199,0.10); color: #0369a1; border-color: rgba(2,132,199,0.30); box-shadow: none; }
  html[data-theme="light"] .tag.cp { background: rgba(5,150,105,0.10); color: #047857; border-color: rgba(5,150,105,0.30); box-shadow: none; }
  html[data-theme="light"] .tag.mmf { background: rgba(124,58,237,0.10); color: #6d28d9; border-color: rgba(124,58,237,0.30); box-shadow: none; }
  /* Light: số tiền thuê bao tím nhạt (#c084fc) → tím đậm */
  html[data-theme="light"] .sub-amt { color: #7c3aed; }
  /* Light: badge sàn giao dịch CP */
  html[data-theme="light"] .exch-hose { color: #1d4ed8; border-color: rgba(29,78,216,0.32); }
  html[data-theme="light"] .exch-hnx { color: #047857; border-color: rgba(5,150,105,0.32); }
  html[data-theme="light"] .exch-upcom { color: #7c3aed; border-color: rgba(124,58,237,0.32); }
  /* Light: lời/lỗ xanh lá-neon → đậm */
  html[data-theme="light"] .pos { color: #059669; }
  html[data-theme="light"] .stock-pl.pos { color: #047857; background: rgba(5,150,105,0.10); border-color: rgba(5,150,105,0.30); }
  html[data-theme="light"] .neg { color: #dc2626; }
  html[data-theme="light"] .stock-pl.neg { color: #b91c1c; background: rgba(220,38,38,0.08); border-color: rgba(220,38,38,0.28); }
  /* Light: giá mua/bán vàng neon → đậm */
  html[data-theme="light"] .gold-buy-cell { color: #047857; }
  html[data-theme="light"] .gold-sell-cell { color: #b91c1c; }
  html[data-theme="light"] .sub-overdue { color: #dc2626; }
  html[data-theme="light"] .sub-warn { color: #c2410c; }
  /* Light: nền cột 420px + khung điện thoại theo theme sáng */
  html[data-theme="light"][data-force-mobile] { background: #e6dcc3; }
  html[data-theme="light"][data-force-mobile] body { box-shadow: none; }

/* ============ ÉP GIAO DIỆN MOBILE 414px (bỏ PC) ============ */
html[data-force-mobile] { background: #0b0e1a; }
html[data-force-mobile] body {
  width: 420px;               /* 414 nội dung + 2px padding mỗi bên */
  max-width: 100vw;
  margin: 0 auto;
  padding-top: 4px !important; /* header đã rút gọn — xóa khoảng trống trên cùng */
  box-shadow: none;
}
html[data-theme="light"][data-force-mobile] body { box-shadow: none; }
/* Header rút gọn: tabbar sát mép trên */
html[data-force-mobile] .main-tabbar { padding-top: 2px !important; }
/* Các phần tử fixed bám theo cột mobile thay vì toàn màn hình */
html[data-force-mobile] .bottom-nav,
html[data-force-mobile] .global-lock {
  left: 50%; right: auto;
  width: 420px;
  max-width: 100vw;
  transform: translateX(-50%);
}
html[data-force-mobile] .toast-wrap {
  left: 50%; right: auto;
  transform: translateX(-50%);
  width: min(400px, 84vw);
}

/* ============================================================
   DIALOG TÙY CHỈNH (thay alert/confirm/prompt) — đồng nhất droplist
   ============================================================ */
.ui-dialog-mask {
  position: fixed; inset: 0; z-index: 9500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8,9,10,0.72);   /* overlay che nền — giữ blur nhẹ để dialog nổi bật */
  padding: 20px;
}
/* BẮT BUỘC: hidden phải thắng display:flex của mask/field,
   nếu không dialog (ô nhập + nút OK) hiện vĩnh viễn trên trang */
.ui-dialog-mask[hidden],
.ui-dialog-field[hidden] { display: none !important; }
.ui-dialog {
  width: min(360px, 100%);
  background: var(--bg-card);
  border: 1px solid rgba(126,166,224,0.30);
  border-radius: 16px;
  box-shadow: none;
  padding: 18px 18px 14px;
  animation: uiDialogIn .18s ease;
}
@keyframes uiDialogIn { from { opacity:0; transform: translateY(10px) scale(.97); } to { opacity:1; transform:none; } }
.ui-dialog-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ui-dialog-icon { font-size: 20px; line-height: 1; }
.ui-dialog-title { font-size: 15px; font-weight: 800; color: var(--text-main,#eef4ff); letter-spacing:.3px; }
.ui-dialog-msg { font-size: 13.5px; line-height: 1.55; color: var(--text-dim,#aebad1); white-space: pre-line; word-break: break-word; }
.ui-dialog-field { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.ui-dialog-label { font-size: 11px; font-weight: 700; letter-spacing:.6px; text-transform: uppercase; color: var(--text-faint,#7c8aa6); }
.ui-dialog-input {
  appearance:none; -webkit-appearance:none;
  background: rgba(15,22,38,0.9); color: var(--text-main,#eef4ff);
  border: 1px solid rgba(76,110,160,0.45); border-radius: 10px;
  padding: 11px 13px; font-size: 15px; font-family: var(--font);
  font-variant-numeric: tabular-nums; letter-spacing: .5px;
  transition: border-color .15s, box-shadow .15s;
}
.ui-dialog-input:focus { outline:none; border-color: var(--cyan); box-shadow: none; }
.ui-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.ui-btn {
  appearance:none; -webkit-appearance:none; border:none; cursor:pointer;
  font-family: var(--font); font-size: 13.5px; font-weight: 700; letter-spacing:.3px;
  border-radius: 10px; padding: 10px 18px; transition: transform .1s, box-shadow .15s, background .15s, border-color .15s;
}
.ui-btn:active { transform: translateY(1px); }
.ui-btn-ghost {
  background: rgba(71,85,105,0.22); color: var(--text-dim,#aebad1);
  border: 1px solid rgba(126,166,224,0.22);
}
.ui-btn-ghost:hover { background: rgba(71,85,105,0.34); }
.ui-btn-primary {
  background: var(--cyan); color: #fff;
  box-shadow: none;
}
.ui-btn-primary:hover { box-shadow: none; }
html[data-force-mobile] .ui-dialog-mask { padding: 0; }
html[data-force-mobile] .ui-dialog { width: min(360px, 392px); }

/* Dropdown giờ/phút Sổ sách (đồng nhất ss-type-wrap) */
.ss-time-wrap { display: flex; gap: 8px; }
.ss-time-wrap select {
  appearance:none; -webkit-appearance:none; flex:1; min-width:0;
  background:
    linear-gradient(45deg, transparent 48%, #a99bff 49%, #a99bff 51%, transparent 52%) calc(100% - 16px) 50%/8px 8px no-repeat,
    rgba(33,29,58,.66);
  padding-right: 28px; cursor: pointer; font-weight: 560; letter-spacing:.2px;
  font-variant-numeric: tabular-nums; text-align:center;
}
.ss-time-wrap select:hover { border-color: rgba(178,166,255,.5); }
.ss-time-wrap select option { background:#1a1a24; color: var(--text); }

/* Hàng chi tiết quỹ mở rộng inline (thay popover nổi) */
.fund-detail-row td {
  background: transparent !important;
  border-top: 1px dashed rgba(126,166,224,0.22);
  padding: 10px 14px;
}
#table1-body tr.fund-active td { background: rgba(113,112,255,0.045); }
html[data-theme="light"] .fund-detail-row td { background: transparent !important; }
html[data-theme="light"] #table1-body tr.fund-active td { background: rgba(203,158,72,0.10); }

/* Card bổ sung khi click hàng (cổ phiếu / tiền gửi / thuê bao) — 4 cột chính + chi tiết dưới */
.row-detail td { background: transparent !important; border-top: 1px dashed rgba(126,166,224,0.22); padding: 10px 0; }
tr.row-active td { background: rgba(113,112,255,0.045); }
html[data-theme="light"] .row-detail td { background: transparent !important; }
html[data-theme="light"] tr.row-active td { background: rgba(207,160,74,0.10); }
.detail-card { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }
.detail-card .dc-item { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed rgba(126,166,224,0.14); font-size: 12.5px; }
.detail-card .dc-item:last-child { border-bottom: none; }
.detail-card .dc-label { color: #93a7c4; flex-shrink: 0; }
.detail-card .dc-value { color: var(--text-main); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.detail-card .dc-full { grid-column: 1 / -1; }
.detail-card .dc-actions { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; padding-top: 8px; border-top: 1px solid rgba(126,166,224,0.16); margin-top: 4px; }
/* Chia đôi hàng: nút Thay Đổi / Xóa mỗi nút 50% */
.detail-card .dc-actions button { flex: 1; text-align: center; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--glass-border); background: rgba(255,255,255,0.06); color: var(--text-main); font-size: 12.5px; cursor: pointer; transition: all .18s; }
.detail-card .dc-actions button:hover { border-color: var(--cyan); box-shadow: none; }
.detail-card .dc-actions button.stock-del { color: var(--red); }
.detail-card .dc-actions button.stock-del:hover { border-color: rgba(251,113,133,.5); background: rgba(251,113,133,.08); }
html[data-theme="light"] .detail-card .dc-label { color: #6b5d3f; }
html[data-theme="light"] .detail-card .dc-value { color: #2c2414; }
/* Hàng có nút sửa inline trong card chi tiết */
.detail-card .dc-edit-row { display: flex; align-items: center; gap: 8px; }
.detail-card .dc-edit-row .dc-label { flex-shrink: 0; }
.detail-card .dc-edit-row .dc-value { flex: 1; min-width: 0; text-align: right; word-break: break-word; }
.stock-note-edit { flex-shrink: 0; background: rgba(255,255,255,0.06); border: 1px solid rgba(126,166,224,0.28); border-radius: 8px; padding: 4px 9px; font-size: 13px; cursor: pointer; color: var(--text-main); transition: border-color .18s, box-shadow .18s; }
.stock-note-edit:hover { border-color: var(--cyan); box-shadow: none; }
html[data-theme="light"] .stock-note-edit { background: rgba(15,23,42,0.05); border-color: rgba(15,23,42,0.2); }
/* Input sửa trực tiếp trong dòng dc-item (ẩn viền khi xem, nổi lên khi editing) */
.detail-card .dc-input {
  flex: 1; min-width: 0;
  background: transparent; color: var(--text-main);
  border: none; padding: 0; font-size: inherit; font-weight: 700; font-family: var(--font);
  text-align: right; font-variant-numeric: tabular-nums; outline: none;
}
.detail-card.editing { grid-template-columns: 1fr; }
.detail-card.editing .dc-input {
  background: rgba(255,255,255,0.07); border: 1px solid var(--cyan);
  border-radius: 8px; padding: 5px 9px; box-shadow: none;
}
html[data-theme="light"] .detail-card .dc-input { color: #2c2414; }
html[data-theme="light"] .detail-card.editing .dc-input { background: #faf5e6; border-color: #8a5f24; }
.ss-edit-actions.sub-edit-btns { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; padding-top: 8px; }
/* Bảng chi tuần: sửa trực tiếp trên hàng */
#ct-week-body .dc-input {
  flex: 1; min-width: 0; width: 100%;
  background: transparent; color: var(--text-main);
  border: none; padding: 0; font-size: inherit; font-weight: 600; font-family: var(--font);
  text-align: right; font-variant-numeric: tabular-nums; outline: none;
}
#ct-week-body td:nth-child(2) .dc-input, #ct-week-body td:nth-child(4) .dc-input { text-align: left; }
/* Nội dung trong ô sửa: luôn căn phải (kể cả khi editing) */
#ct-week-body tr.editing .dc-input { text-align: right !important; }
#ct-week-body tr.editing .dc-input {
  background: rgba(255,255,255,0.07); border: 1px solid var(--cyan);
  border-radius: 7px; padding: 5px 8px; box-shadow: none;
}
/* Khi editing: hàng thoát table-layout (JS đặt position:absolute + width full bảng),
   các ô xếp dọc full-width, nút ✏️/🗑 ẩn, Lưu/Cancel dưới cùng */
#ct-week-body tr.editing .cw-btns { display: flex; flex-direction: row; gap: 8px; width: 100%; margin-top: 8px; }
#ct-week-body tr.editing .cw-btns button { flex: 1; padding: 10px; font-size: 13.5px; border-radius: 9px; }
html[data-theme="light"] #ct-week-body .dc-input { color: #2c2414; }
html[data-theme="light"] #ct-week-body tr.editing .dc-input { background: #faf5e6; border-color: #8a5f24; }
#ct-week-body .cw-btns { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
#ct-week-body .cw-btns .ss-btn-save, #ct-week-body .cw-btns .ss-btn-cancel { padding: 6px 12px; font-size: 12px; white-space: nowrap; }
#ct-week-body .cw-date { font-weight: 800; color: var(--cyan); text-align: center; width: 34px; }
html[data-theme="light"] #ct-week-body .cw-date { color: #8a5f24; }
.ss-edit-form input[type="date"] { color-scheme: dark; }
html[data-theme="light"] .ss-edit-form input[type="date"] { color-scheme: light; }
tr.row-active td { background: rgba(113,112,255,0.045); }
html[data-theme="light"] tr.row-active td { background: rgba(8,145,178,0.055); }

/* ============================================================
   FLAT DESIGN SYSTEM — phẳng, tối giản kiểu Linear (2026-08-26)
   Token gốc (:root đầu file) đã flat; lớp này chỉ dọn nốt các
   style cũ nằm ngoài token. Xóa block này KHÔNG quay lại glass.
   ============================================================ */
[class*="card"] {
  background: var(--bg-card-solid) !important;
  background-image: none !important;
  box-shadow: none !important;
}
[class*="card"]::before, [class*="card"]::after { display: none !important; }
[class*="card"]:hover { transform: none !important; }
/* Card chi tiết (tiền gửi/thuê bao/cổ phiếu/quỹ) — nền trong suốt để hòa màu bảng */
.detail-card { background: transparent !important; }
/* Ngoại lệ: label/val/icon bên trong card — nền trong suốt */
[class*="-card-label"], [class*="-card-val"], [class*="-card-icon"],
.gold-card-head { background: transparent !important; }
/* Ô GIÁ MUA/GIÁ BÁN trong bảng vàng — không phải card, nền trong suốt */
.gold-result-card { background: transparent !important; box-shadow: none !important; }
.kpi-line + .kpi-line { border-top: 1px solid var(--hairline) !important; }

/* Nút bấm: accent phẳng duy nhất */
.btn-primary, .sub-add-btn, .dep-add-btn, .ss-btn-save, .ai-send {
  background: var(--cyan) !important;
  background-image: none !important;
  color: #ffffff !important;
  box-shadow: none !important;
}

