/*
Media Query Size
----------------------------------
Small display scales - @media (min-width: 576px) and @media (max-width: 575px)
Medium screen scale - (min-width: 768px) and (max-width: 767px)
Large size display dimension - (min-width: 992px) and (max-width: 991px)
And Additional big display sizes - (min-width: 1200px) and (max-width: 1199px)
*/

@charset "utf-8";
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,500;1,600;1,700;1,800;1,900&family=Noto+Sans+KR:wght@100;300;400;500;700;900&family=Noto+Serif+KR:wght@200;300;400;500;600;700;900&display=swap');

:root {
    --font-gothic: 'Lato', 'Noto Sans KR', sans-serif;
    --font-serif: 'Playfair Display', 'Noto Serif KR', serif;

    --red-dark: #cb000e;
    --red-dark-transparent: rgba(203, 0, 14, 0.7);
    --red-light: #ea4836;
    --red-light-transparent: rgb(255, 224, 224);
    --blue-dark: #0063d0; /* rgb(0, 99, 208) */
    --blue-light: #d1effe; /* rgb(209, 239, 254) */
    --blue-light-transparent: rgba(209, 239, 254, 0.3);
    --green-light:  #ebffe7;
    --yellow-dark:  #B9A644;
    --yellow-light: #FFFEBD;

    /* 테마 토큰 — 라이트 기준값. 다크는 [data-bs-theme="dark"] 블록에서 덮어쓴다.
       색을 직접 쓰지 말고 이 토큰을 쓰면 테마 전환이 자동으로 따라온다 */
    --fin-money: #343a40;       /* 금액 기본 글자색 */
    --fin-negative: #dc3545;    /* 지출/감소 */
    --fin-positive: #007bff;    /* 수입/증가 */
    --fin-percent: #28a745;     /* 비율 */
    --fin-faint: #ccc;          /* 값 없음 표기 */
    --fin-root-bg: var(--bs-gray-900);  /* 카테고리 대분류 행 */
    --fin-root-fg: #fff;
    --fin-highlight: #9cff1a;   /* 앵커 이동 하이라이트 */
    --fin-refreshed: #ffe395b6; /* 잔액 갱신 플래시 */
    --fin-goal-bg: #e7f7ed;     /* 목표 도달 행 */

    /* SVG 차트 — 프레젠테이션 속성 대신 CSS로 칠해 테마를 따라가게 한다 */
    --fin-chart-grid: #e9ecef;  /* 수평 격자선 */
    --fin-chart-track: #f1f3f5; /* 도넛 트랙 */
    --fin-chart-axis: #adb5bd;  /* 축 라벨 */
    --fin-chart-zero: #868e96;  /* 0 기준선 */
    --fin-chart-dot: #fff;      /* 포커스 점 테두리 */
}

html { font-family: var(--font-gothic); position: relative; width: 100%; height: 100%; margin: 0; padding: 0; }
body { font-family: var(--font-gothic); font-weight: 400; font-size: 0.75rem; line-height: 1.5; -webkit-tap-highlight-color: #ced4da; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; position: relative; width: 100%; height: 100%; margin: 0; padding: 0; }
a:link, a:visited { transition: all .5s linear; text-decoration: none; }
a:hover { transition: all .5s linear; } 
h1 { font-family: var(--font-serif); }
h2, h3, h4, h5, h6, input, select, button { font-family: var(--font-gothic); } 
b, strong { font-weight: 700; } 
code { font-family: var(--bs-font-monospace); }

/* layout */
body > nav { padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; }
body > main { padding: 1rem 2rem; }
body.new-window > main, body.new-window > main.container { padding: 1.5rem; max-width: 100%; }

main.login { display: flex; align-items: center; justify-content: center; height: 100vh; }

h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { text-decoration: none; color: var(--bs-emphasis-color); }
h1 { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2rem; font-weight: 900; }

/*  account */
span.account { font-family: var(--font-gothic); font-weight: bold; padding: 3px 0px; width: 70px; font-size: 8pt; line-height: 1; color: #fff; background-color: var(--bs-gray-600); margin: 0; display: block; text-align: center; border-radius: 10px; border: solid 1px transparent; background-clip: padding-box; }
table td span.account { margin: 0 auto; }

.ALLIANT { background-color: #9ecd43 !important; color: #063673 !important }
.AMAZON { background-color: #231f20 !important; color: #fdb813 !important }
.AMEX { background-color: #057bbb !important }
.APPLE { background-color: #fff !important; box-shadow: inset 0 0 0 1px var(--bs-gray-700) !important; color: #000 !important; }
.BARCLAY { background-color: #c1bfbf !important; color: #5d5e5e !important}
.CASH { background-color: #DAF861 !important; color: #99A902 !important }
.CHASE { background-color: #365777 !important; color: #cee8f3 !important }
.CHASESP { background-color: #015c93 !important; color: #fff !important; }
.DISCOVER { background-color: #513321 !important;color: #b0afae !important }
.PAYPAL { background-color: #003087 !important; color: #009cde !important }
.TXCU { background-color: #093a7f !important }
.WFACVISA { background-color: #bb0826; background-image: linear-gradient(to right, #959695 , #bb0826); background-clip: padding-box; }
.WFCD { background-color: #dddddd; color: #000 !important; }
.WFCK { background-color: #bb0826 !important; color: #ffb610 !important; }
.WFVISA { background-color: #31b311 !important; }
.ENCORE { background-color: #d6d6d6 !important; color: #333 !important; }

ul.history { list-style: none; margin: 0; padding: 0; display: none; }
ul.history li { padding: 0.25rem 0; border-top: solid 1px var(--bs-gray-200); line-height: 1; display: flex; justify-content: space-between; }

/*  money, percent, date base format */
.money { font-family: var(--bs-font-monospace); font-size: 0.7rem; color: var(--fin-money); }
.money .dec { font-size: 0.8em; vertical-align: baseline; font-family: var(--bs-font-monospace); margin-left: 1px; line-height: 1em }
.Negative { color: var(--fin-negative) }
.Positive { color: var(--fin-positive) }
.none { font-size: xx-small; color: var(--fin-faint) }

.percent { font-family: var(--bs-font-monospace); color: var(--fin-percent) }

.date { font-family: var(--bs-font-monospace); font-size: 0.7rem; color: var(--bs-gray-600); white-space: nowrap; }

.category .group { color: var(--bs-gray-700); }
.category .cat { font-weight: 700; white-space: nowrap; }

/* form */
.form-group { margin: 1rem 0; display: flex; align-items: center; }
.form-label { font-weight: 600; margin: 0; padding: 0; padding: 0.375rem 0; flex: 0 0 10%; max-width: 33.333333%; display: flex; align-items: center; }
.form-label .btn-circle { border-radius: 1rem; margin-left: 0.5rem; border: none; background-color: var(--bs-gray-200); transition: all 0.3s linear; }
.form-label .btn-circle:hover { background-color: var(--bs-gray-300); transition: all 0.3s linear; }
.form-control, .form-select, .input-group-text, .btn { font-size: 0.75rem; font-weight: 600;}
.form-control, .form-select, .input-group .form-control { color: var(--bs-blue); width: auto; }
.input-group .form-control { flex: 0 1 auto; }
.editable .input-group .form-control { flex: 0 1 100%; }

.form-checks label { margin-right: 1rem;}
.form-checks input { margin-right: 0.25rem; }

input[type="number"] { width: 7rem; text-align: right; }

.keywords-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.keywords-wrap .form-control { width: 12rem; }

.grid-2 { display: grid; grid-gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; grid-gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; grid-gap: 1rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { display: grid; grid-gap: 1rem; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-6 { display: grid; grid-gap: 1rem; grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* 화면이 좁아지면 한 칸씩 세로로 쌓는다 — 칸이 좁아져 표가 뭉개지는 것보다 낫다 */
@media (max-width: 991px) {
    .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 { grid-template-columns: 1fr; }
}

/* Search Form */
.search { background: var(--bs-gray-200); padding: 1rem; margin-bottom: 2rem; border-radius: var(--bs-border-radius); display: flex; justify-content: space-between; gap: 1rem; }
.search .search-fields { flex: 1; display: flex; flex-wrap: wrap; grid-gap: 0.25rem; }
.search .form-group { display: block; margin: 0;  }
.search .form-label { display: block; margin: 0; font-size: 0.8em; line-height: 1; padding: 0 0 2px 0.75rem; max-width: 100%; }

.search .form-checks { display: flex; flex-wrap: wrap; align-items: center; padding: 0.375rem var(--bs-border-radius); }
.search .form-checks .form-check { display: flex; flex-wrap: nowrap; align-items: center; padding: 0; min-height: auto; }

/* table */
table td { vertical-align: middle; padding: 0.375rem;}
.table>:not(caption)>*>* { padding: 0.375rem;}

.table-bordered thead th, .table-bordered thead tr { border: none; }
.table thead th { line-height: 1.2; border-bottom: solid 1px var(--bs-gray-900); background-color: transparent; }
.table thead a { text-decoration: none; color: var(--red-dark); }
.table thead a:hover { color: var(--bs-gray-900); }
.table thead th.month { text-align: center; font-weight: 900; }

.table tfoot tr { border: none; }
.table tfoot td { border: none; border-top: solid 2px var(--bs-gray-900); padding: 0.5rem 0.25rem; font-weight: 700; background-color: transparent; }

.table tr.category-root td { background-color: var(--fin-root-bg); color: var(--fin-root-fg); font-weight: 900; padding: 0.5rem 0.25rem; }
.table tr.category-root a { text-decoration: none; color: var(--fin-root-fg);}
.table tr.category-root a:hover { color: var(--bs-gray-700); }

.table tr.hidden { opacity: 0.3; }
.table tr.ignored td { background-color: var(--blue-light); opacity: 0.3; transition: all .5s; }
.table tr.ignored:hover td { opacity: 1; transition: all .5s; }
.table tr.pending td { background-color: var(--bs-gray-300); }
.table tr.opened td { background-color: var(--yellow-light); }
.table tr.is-splitted td { background-color: var(--bs-warning); }
.table td.editable:hover { outline: solid 1px var(--blue-dark); }
.table td.editable .input-group { flex-wrap: nowrap;}

.table th.amount, .table td.amount { text-align: right; white-space: nowrap; min-width: 90px; }
.table td.category-type { white-space: nowrap;}
.table td.category-type button { font-size: 9px; }

.table tr:hover td { background-color: var(--blue-light-transparent); }
.table tr.selected td { background-color: var(--blue-light); }
.table tr.highlight td { background-color: var(--fin-highlight) !important; transition: background-color 0.5s ease;}

.status .bi-x-lg { color: var(--bs-gray-500); }

.split ul { list-style: none; padding: 0; margin: 0; }
.split ul li { display: flex; align-items: center; padding: 0.5rem; border-bottom: solid 1px var(--bs-gray-200); }
.split ul li label { width: 100px;}
.split ul li .money { min-width: 60px;}

/* select2 */
.select2-container .select2-selection.select2-selection--single { padding: 0.1rem 2.25rem 0.1rem 0.25rem; height: 32px; border: solid 1px var(--bs-border-color); font-weight: 600; border-radius: var(--bs-border-radius); }
.select2-container .select2-selection.select2-selection--single .select2-selection__rendered { color: var(--bs-blue); }
.input-group .select2-container .select2-selection.select2-selection--single { border-radius: var(--bs-border-radius) 0 0 var(--bs-border-radius); }

/* import */
.import-layout { display: grid; grid-gap: 1rem; grid-template-columns: 300px 2fr; align-items: start; margin-top: 4rem; }
.import-layout table .form-control { width: 100%;}
.import-layout table input[name^="amount"] { width: 100px; }
.import-layout table input[name^="check_number"] { width: 50px; }
.import-layout .statement { border-left: dashed 1px var(--bs-gray-500); padding-left: 3rem; }

/* installment */
.installment-table td.null { background-color: var(--bs-gray-200); }
.installment-table td.not-paid { text-align: center; font-size: small; color: var(--bs-gray-400); }

/* monthly-table */
section.monthly { margin-bottom: 3rem;}
.monthly-table thead th.month { text-align: right; }
.monthly-table td.title { text-align: left; width: 150px; }
.monthly-table thead th:first-child { color: var(--bs-gray-600); font-size: 0.9rem; font-family: var(--font-serif); }
.monthly-table tr.group td { background-color: var(--bs-table-striped-bg); }
.monthly-table tr.category td.cat { text-align: right; }
.monthly-table tr.normalize-adj td { font-size: 0.85rem; opacity: 0.7; }
.monthly-table tr.normalize-adj td.title a { color: inherit; text-decoration: none; }

/*  tip */
.tip { position: relative;}
.tip::before { width: 2px; height: 2px; background-color: var(--bs-yellow); border-radius: 50%; position: absolute; content: ''; top: -2px; right: 0; transition: all .5s; }
.tip:hover::before { width: 5px; height: 5px; background-color: var(--bs-orange); transition: all .5s; }

/* investment */
.investment-wrap { display: flex; flex-wrap: wrap; gap: 1rem; }
.investment-wrap .table a.edit { margin-right: 0.5rem; }
.investment-wrap .table a:hover { color: var(--bs-gray-900);}

/* summary */
/*
   summary 대시보드 — 섹션을 세로로 쌓는다.
   전에는 flex-wrap row였는데, 그러면 섹션이 화면 폭에 따라 되는 대로 옆에 붙어
   읽는 순서가 매번 달라졌다. 항목이 늘어나면서 그게 산만함의 주된 원인이었다.
   대시보드는 훑는 순서가 정해져 있어야 하므로 흐름을 고정한다.
*/
/* 대시보드 폭을 잡아준다 — 넓은 모니터에서 요소가 양 끝으로 흩어지지 않게.
   1280px는 8열 표(Current Balance)가 여유롭게 들어가고 시선이 훑기 좋은 한계 */
.summary { padding-bottom: 4rem; }
.summary section { margin: 0 0 3.25rem; }
.summary > *:last-child, .summary section:last-child { margin-bottom: 0; }
/* 2단 행 — 칸 사이 간격은 grid-gap이 맡고, 행 전체가 섹션 하나만큼의 아래 여백을 갖는다 */
.summary > .summary-row { margin: 0 0 3.25rem; row-gap: 2.5rem; }
.summary > .summary-row > section { margin-bottom: 0; }
/* 넓은 표는 페이지가 아니라 칸 안에서 가로 스크롤 */
.summary .grid-2 > * { min-width: 0; overflow-x: auto; }
.summary .next-income { font-size: 1rem; color: var(--bs-gray-600); font-weight: 400; font-family: var(--font-gothic); }

/* 섹션 제목 — 부제는 제목 옆에 딱 붙는다. 전역 h1의 space-between를 여기서 되돌린다
   (그대로 두면 넓은 화면에서 제목과 부제가 양 끝으로 벌어져 대시보드 느낌이 깨진다) */
.summary section > h1 {
    /* font-size: 1.45rem; */
    margin-bottom: 1.1rem;
    padding-bottom: 0.45rem;
    border-bottom: solid 1px var(--bs-gray-200);
    justify-content: flex-start;
    gap: 0.75rem;
    align-items: baseline;
    flex-wrap: wrap;
}
.summary section > h1 small { font-size: 0.72rem; font-weight: 400; }

/* 표는 내용만큼만 — 스프레드시트처럼 조밀하게 둔다 */
.summary .table { width: auto; }
.summary .table td { padding: 0.5rem; }

/*  simple-balance */
.simple-balance { display: inline-flex; flex-wrap: wrap; align-items: center; list-style: none; margin: 0 0 2rem 0; padding: 0; transition: all .3s; }
.simple-balance li { flex: 1; margin: 0 1rem 0 0; display: inline-flex; align-items: center; }
.simple-balance li .amount { font-size: small; }
.simple-balance li span.account { margin-right: .2rem}
.simple-balance li span.amount { font-size: small;}
.simple-balance.refreshed { background-color: var(--fin-refreshed); transition: all .3s; padding: 0 1rem; }


#summary-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start
}

#summary-wrapper section {
    flex: 0;
    padding: 0;
    padding-right: 1rem
}

#summary-wrapper section.fit {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#summary-wrapper .table-responsive {
    overflow-x: hidden
}

#summary-wrapper .table-responsive table {
    width: auto
}

/* loading-spinner */
.loading-spinner-wrapper {position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.4); z-index: 2000; display: none; color: white; }
.loading-spinner {position: absolute; left: 47%; top: 42%; font-weight: 500; text-align: center; }
.loader {transform: translate(-50%, -50%); width: 3.5rem; height: 3.5rem; border: 8px solid #414141; border-bottom-color: #ffffff; border-radius: 50%; display: inline-block; box-sizing: border-box; animation: rotation 1s linear infinite; margin-bottom: 0.5rem; -webkit-animation: rotation 1s linear infinite; }

@keyframes rotation {
    0% {transform: rotate(0deg); -webkit-transform: rotate(0deg); -moz-transform: rotate(0deg); -ms-transform: rotate(0deg); -o-transform: rotate(0deg); }
    100% {transform: rotate(360deg); -webkit-transform: rotate(360deg); -moz-transform: rotate(360deg); -ms-transform: rotate(360deg); -o-transform: rotate(360deg); }
}

.form-select.selected { color: var(--red-dark); background-color: var(--red-light-transparent); }

/* nav actions */
.nav-actions { display: flex; gap: 0.5rem; align-items: center; }

#notes-toggle { position: relative; }
.notes-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--red-dark);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 8px;
    padding: 0 4px;
}

/* Notes Panel */
.notes-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--bs-body-bg);
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    z-index: 2100;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.notes-panel.open { right: 0; }

.notes-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.3);
    z-index: 2050;
    display: none;
}

.notes-overlay.open { display: block; }

.notes-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--bs-gray-200);
    background: var(--bs-gray-100);
}

.notes-panel-header h5 { margin: 0; font-weight: 700; }
.notes-panel-actions { display: flex; gap: 0.5rem; }

.notes-panel-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.notes-list { flex: 1; overflow-y: auto; }

.notes-empty {
    padding: 2rem;
    text-align: center;
    color: var(--bs-gray-500);
}

.note-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bs-gray-200);
    cursor: pointer;
    transition: background 0.2s;
}

.note-item:hover { background: var(--bs-gray-100); }

.note-item-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-item-preview {
    font-size: 0.7rem;
    color: var(--bs-gray-600);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-item-date {
    font-size: 0.65rem;
    color: var(--bs-gray-400);
    margin-top: 0.25rem;
}

.note-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.75rem;
}

.note-editor #note-title {
    font-weight: 600;
}

.note-editor #note-content {
    flex: 1;
    resize: none;
    min-height: 300px;
    font-size: 0.8rem;
    line-height: 1.6;
}

.note-editor-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.note-editor-actions > div { display: flex; gap: 0.5rem; }
.table-responsive { padding-right: 1px; }

/* stock */
.stock h1 .actions .btn, .stock-detail h1 .actions .btn { margin-left: 0.5rem; vertical-align: middle; }
.stock h1 .title, .stock-detail h1 .title { display: inline-flex; align-items: baseline; gap: 0.5rem; }
.stock h1 .actions, .stock-detail h1 .actions { white-space: nowrap; }
.stock .symbol, .stock-detail .symbol { font-size: 0.7rem; color: var(--bs-gray-600); font-family: var(--bs-font-monospace); }
.stock-detail h1 .symbol { font-size: 0.9rem; }

.stock-summary { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-bottom: 1.5rem; padding: 0.75rem 1rem; background-color: var(--bs-gray-100); border-radius: 0.25rem; }
.stock-stat { display: flex; flex-direction: column; min-width: 80px; }
.stock-stat .label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--bs-gray-600); }
.stock-stat .value { font-size: 0.9rem; }
.stock-stat .value .money { font-size: 0.85rem; }
.stock-stat .value.date { font-size: 0.7rem; font-family: var(--bs-font-monospace); }

.stock-tables { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem 2rem; }
/* 표는 내용만큼만 — 스프레드시트처럼 조밀하게 나란히 놓는다 */
.stock-tables section { flex: 0 1 auto; max-width: 100%; }
.stock-tables .table { width: auto; }
.stock-tables .table td, .stock-tables .table th { padding: 0.4rem 0.6rem; }
.stock-tables h3, .stock-trend h3, .stock-manual h3 { font-size: 0.95rem; margin-bottom: 0.5rem; }
.stock-tables h3 small, .stock-trend h3 small, .stock-manual h3 small { font-size: 0.7rem; font-weight: normal; }
.stock-tables .table { margin-bottom: 0.5rem; }
.stock-tables .table th { font-size: 0.75rem; white-space: nowrap; }
.stock-tables .table tfoot td.total { font-weight: 600; }
.stock-tables .table td.actions a { margin-right: 0.4rem; color: var(--bs-gray-600); }
.stock-tables .table td.actions a:hover { color: var(--bs-gray-900); }
.stock-tables .table tr.target-reached td { background-color: var(--fin-goal-bg); }
/* 현재가 — 글자 크기/색은 다른 금액과 동일하게 두고 배경색으로만 강조한다.
   줄무늬(rgba)와 hover 음영은 이 위에 겹쳐지므로 톤만 살짝 어두워질 뿐 그대로 동작한다 */
.stock-tables .table td.current-price { font-weight: 700; padding-left: 0.75rem; padding-right: 0.75rem;
    background-color: var(--blue-light-transparent); }

.stock-trend, .stock-manual { margin-bottom: 1.5rem; }
.stock-charts { display: flex; flex-wrap: wrap; gap: 1rem 2rem; margin-bottom: 1rem; }
.stock-charts > section { flex: 1 1 420px; min-width: 0; }
.stock-chart { width: 100%; height: auto; max-width: 100%; display: block; }
.stock-chart.compact { margin: 0.25rem 0 0.5rem; }
/* 표 합계 바로 아래 붙는 스파크라인 — tfoot의 굵은 윗선/여백을 물려받지 않게 한다 */
.table tfoot tr.trend-row td { border-top: none; padding: 0 0.25rem 0.25rem; }
.table tfoot tr.trend-row .stock-chart { margin: 0; }

/* 차트 기간 토글 */
.chart-span { float: right; font-size: 0.68rem; font-weight: normal; }
.chart-span a { color: var(--bs-gray-600); padding: 0 0.35rem; }
.chart-span a + a { border-left: solid 1px var(--bs-gray-300); }
.chart-span a.active { color: var(--red-dark); font-weight: 700; }

/* 차트 hover — 십자선 + 툴팁 */
.chart-wrap { position: relative; }
.chart-wrap { cursor: crosshair; }
.chart-crosshair { stroke: var(--bs-gray-500); stroke-width: 1; stroke-dasharray: 3 2; }
.chart-tooltip { position: absolute; z-index: 5; pointer-events: none; background: rgba(33, 37, 41, 0.94);
    color: #fff; border-radius: 3px; padding: 0.35rem 0.5rem; font-size: 0.68rem; line-height: 1.5; white-space: nowrap; }
.chart-tooltip-date { font-family: var(--bs-font-monospace); font-size: 0.62rem; color: var(--bs-gray-400); margin-bottom: 0.15rem; }
.chart-tooltip-row { display: flex; align-items: center; gap: 0.35rem; }
.chart-tooltip-row i { width: 8px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.chart-tooltip-row .k { flex: 1; }
.chart-tooltip-row .v { font-family: var(--bs-font-monospace); text-align: right; }
.chart-tooltip-row .v.Positive { color: #6cb2ff; }
.chart-tooltip-row .v.Negative { color: #ff8b95; }
/* 보조 표기(정규화 전 원본 값 — 주가 등). 주값보다 한 단계 죽인다 */
.chart-tooltip-row .alt { font-family: var(--bs-font-monospace); color: var(--bs-gray-500); text-align: right; }

.chart-legend-items { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-top: 0.35rem; font-size: 0.7rem; }
.chart-legend-items .legend-item { display: inline-flex; align-items: center; gap: 0.3rem; color: inherit; }
.chart-legend-items .legend-item i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-legend-items .legend-item .alt { font-family: var(--bs-font-monospace); font-size: 0.7rem; color: var(--bs-gray-600); }
/* 클릭해서 하나만 보기 */
.chart-legend-items a.legend-item { cursor: pointer; border-bottom: solid 1px transparent; }
.chart-legend-items a.legend-item:hover { border-bottom-color: var(--bs-gray-400); }
.chart-legend-items .legend-item.dimmed { opacity: 0.4; }
.chart-legend-items .legend-item.active { font-weight: 700; }
.chart-legend-items .legend-item.reset { color: var(--red-dark); font-weight: 700; }

/* summary 대시보드 위젯 — Accounts / Stocks 두 칸을 같은 구조로 */
/* 칸을 같은 높이로 늘려 두 그래프가 같은 줄에 오게 한다 (표 행 수가 달라도) */
.overview-grid { align-items: stretch; }
.overview-head { display: flex; align-items: baseline; gap: 0.5rem; margin: 0.25rem 0; }
.overview-head a { font-weight: 700; color: var(--red-dark); }
.overview-card .table { margin: 0; }
/* 합계 아래 보조 행(Return 등)은 구분선 없이 붙인다 */
.overview-card .table tfoot tr.sub td { border-top: none; padding-top: 0; font-weight: 400; }
.overview-card .table tfoot tr.sub .category { color: var(--bs-gray-600); }
/* 그래프는 두 칸 모두 아래쪽에 붙여 같은 높이에 오도록 */
.overview-card .chart-wrap { margin-top: auto; padding-top: 0.5rem; }

/* 수정폼 하단 — Close / Delete 등 되돌리기 어렵거나 파급이 큰 동작 */
.danger-zone { border: solid 1px var(--bs-gray-300); border-radius: 0.25rem; }
.danger-zone .danger-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1rem; }
.danger-zone .danger-item + .danger-item { border-top: solid 1px var(--bs-gray-200); }
.danger-zone h5 { font-size: 0.85rem; font-weight: 700; margin: 0 0 0.15rem; }
.danger-zone h5 small { font-weight: normal; font-size: 0.75rem; }
.danger-zone p { margin: 0; font-size: 0.72rem; color: var(--bs-gray-700); max-width: 60ch; }
.danger-zone p code { font-size: 0.72rem; color: var(--bs-gray-900); }
.danger-zone .btn { white-space: nowrap; }
.danger-zone #close-form { padding: 0 1rem 0.75rem; }
.stock-price-history .chart-legend { font-size: 0.7rem; margin: 0.25rem 0 1rem; }
.stock-price-history .badge { font-size: 0.6rem; font-weight: normal; }
.stock-detail .stock-tables section:first-child { flex: 0 1 320px; }
.stock-detail .stock-tables section:first-child th { width: 40%; }

/* ---------------------------------------------------------
   Analysis — 지출 구성 / 추세 / 절감 후보
   --------------------------------------------------------- */
/* summary와 같은 폭으로 잡아 넓은 화면에서 차트가 늘어지지 않게 한다.
   대시보드 세로 흐름을 유지하되 좌우 여백은 layout의 body>main과 이어지도록 */
main.analysis { padding: 0 1rem 3rem; max-width: 1280px; margin: 0 auto; }
main.analysis section { margin-bottom: 2.75rem; }
/* 섹션 제목은 summary h1과 같은 밑선 구획을 써서 훑는 순서를 만든다 —
   전에는 h2 크기가 너무 작아 컨트롤 줄(chart-span 등)과 무게가 겹쳤다 */
main.analysis h2 {
    display: flex;
    justify-content: flex-start;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.9rem;
    padding-bottom: 0.4rem;
    border-bottom: solid 1px var(--bs-gray-300);
}
main.analysis h2 .text-muted { font-size: 0.72rem; font-weight: normal; }
main.analysis h2 .chart-span { margin-left: auto; }

/* 머리말 — 탭 + 기간 필터 */
.analysis-head { margin-bottom: 1.75rem; }
.analysis-tabs { margin-bottom: 0.9rem; gap: 0.25rem; }
.analysis-tabs .nav-link { font-size: 0.8rem; padding: 0.3rem 0.85rem; color: var(--bs-gray-700); }
.analysis-tabs .nav-link.active { background: var(--bs-gray-800); }
.analysis-basis { margin-bottom: 0.75rem; }
.summary-basis { margin: 0.5rem 0 1rem; }
.summary-basis .btn { font-size: 0.72rem; }
.analysis-basis .btn { font-size: 0.72rem; }
.analysis-period { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.analysis-period .btn { font-size: 0.72rem; }
.analysis-custom { display: flex; align-items: center; gap: 0.3rem; }
.analysis-custom input[type="date"] { width: 9.5rem; font-size: 0.72rem; }
.analysis-custom span { color: var(--bs-gray-500); font-size: 0.72rem; }
.analysis-range { margin-top: 0.6rem; font-size: 0.75rem; }
.analysis-range strong { margin-right: 0.5rem; }
.analysis-range .badge { font-size: 0.6rem; font-weight: normal; margin-left: 0.4rem; }

/* 지표 카드 */
.analysis-kpis { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.analysis-kpis .kpi {
    flex: 1 1 180px; min-width: 0;
    border: solid 1px var(--bs-gray-300); border-radius: 0.35rem;
    padding: 0.6rem 0.8rem;
}
.analysis-kpis .kpi .k { font-size: 0.66rem; color: var(--bs-gray-600); }
.analysis-kpis .kpi .v { font-size: 1.05rem; font-weight: 700; margin: 0.15rem 0; }
.analysis-kpis .kpi .v .money { font-size: 1.05rem; }
.analysis-kpis .kpi .v .sub { font-size: 0.7rem; font-weight: normal; color: var(--bs-gray-600); margin-left: 0.2rem; }
.analysis-kpis .kpi .v .sub .money { font-size: 0.7rem; }

/* 차트 두 칸 나란히 */
.analysis-charts { display: flex; flex-wrap: wrap; gap: 1rem 2rem; }
.analysis-charts .chart-card { flex: 1 1 380px; min-width: 0; }
.chart-note { font-size: 0.68rem; color: var(--bs-gray-600); margin: 0.5rem 0 0; max-width: 78ch; line-height: 1.5; }
.drill-reset { font-size: 0.7rem; font-weight: normal; margin-left: 0.4rem; color: var(--red-dark); }

/* 도넛 */
.donut-chart { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem; }
.donut-chart svg { flex: 0 0 auto; max-width: 100%; height: auto; }
.donut-legend { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; font-size: 0.72rem; }
.donut-legend .legend-item { display: flex; align-items: center; gap: 0.4rem; color: inherit; text-decoration: none; }
.donut-legend .legend-item i { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.donut-legend .legend-item .k { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend .legend-item .p { font-family: var(--bs-font-monospace); font-size: 0.68rem; color: var(--bs-gray-600); }
.donut-legend a.legend-item:hover .k { text-decoration: underline; }

/* 스택 바 */
.stack-bar-wrap { margin-bottom: 1.1rem; }
.stack-bar-caption { font-size: 0.68rem; color: var(--bs-gray-600); margin-bottom: 0.25rem; }
.stack-bar { display: flex; height: 22px; border-radius: 3px; overflow: hidden; background: var(--bs-gray-200); }
.stack-bar .stack-seg { display: flex; align-items: center; justify-content: center; min-width: 0; }
.stack-bar .stack-seg span { font-size: 0.62rem; color: #fff; font-family: var(--bs-font-monospace); text-shadow: 0 0 2px rgba(0,0,0,0.35); }
.stack-bar-wrap .chart-legend-items .p { font-family: var(--bs-font-monospace); color: var(--bs-gray-600); }

/* 표 */
.analysis-table { width: auto; }
.analysis-table thead th { font-size: 0.7rem; white-space: nowrap; }
.analysis-table thead th:first-child { color: var(--bs-gray-600); font-family: var(--font-serif); }
.analysis-table td.title { font-weight: 700; }
.analysis-table tr.group td { background-color: var(--bs-table-striped-bg); font-weight: 700; cursor: pointer; }
.analysis-table tr.group td.cat i { font-size: 0.6rem; color: var(--bs-gray-500); }
.analysis-table tr.group td.cat .count { font-weight: normal; font-size: 0.65rem; color: var(--bs-gray-600); }
.analysis-table tr.category td.cat { padding-left: 1.6rem; }
.analysis-table .merchant { font-family: var(--bs-font-monospace); font-size: 0.7rem; }

/*
   비중을 숫자 뒤에 옅은 막대로 겹쳐 눈으로 순서가 잡히게.

   막대는 셀(td)에 건다. span은 inline-block이라 폭이 글자 수에 따라 달라지고,
   그러면 width:var(--w)가 '글자 폭의 백분율'이 되어 자릿수가 다른 행끼리
   막대 길이가 실제 비율과 어긋난다 (5.1% : 100.0% 가 1:26.8로 그려졌다. 참값은 1:19.6).
   td는 한 열 안에서 폭이 같으니 행끼리 그대로 견줄 수 있다.
*/
.analysis-table td.ratio-cell { position: relative; z-index: 0; }
.analysis-table td.ratio-cell::before {
    content: ''; position: absolute; right: 0; top: 2px; bottom: 2px;
    width: var(--w, 0); background: rgba(31, 119, 180, 0.16); border-radius: 2px; z-index: -1;
}
.ratio-bar { font-family: var(--bs-font-monospace); font-size: 0.7rem; }

/* 카테고리 성격 태그 */
.type-tag { display: inline-block; font-size: 0.58rem; padding: 0.05rem 0.3rem; border-radius: 2px; white-space: nowrap; }
.type-tag.t-FIXED { background: #495057; color: #fff; }
.type-tag.t-REQUIRED { background: #1f77b4; color: #fff; }
.type-tag.t-NotREQUIRED { background: #ff7f0e; color: #fff; }
.type-tag.t-UNCLASSIFIED { background: var(--bs-gray-200); color: var(--bs-gray-700); }
.type-tag.t-REDUCIBLE { background: #d62728; color: #fff; }

/* 추세 계열 선택 */
.trend-picker { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem 1rem; margin-bottom: 0.9rem; }
.trend-picker select { flex: 1 1 320px; max-width: 480px; font-size: 0.72rem; }
.trend-picker-actions { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.68rem; }

/* 지출 증감 — moneyFormat과 색 규칙이 반대다 (증가 = 나쁜 소식) */
.delta { font-family: var(--bs-font-monospace); font-size: 0.7rem; white-space: nowrap; }
.delta .v { font-family: var(--bs-font-monospace); }
.delta.up { color: var(--fin-negative); }
.delta.down { color: var(--fin-positive); }
.delta.flat { color: var(--bs-gray-400); }
.analysis-kpis .kpi .v .delta { font-size: 1.05rem; }
.analysis-kpis .kpi .v .sub .delta { font-size: 0.7rem; }
.analysis-kpis .kpi .k .delta { font-size: 0.66rem; }

/* Budget — 예산 편성 / 소진 추적 */
.budget-month { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.budget-month .btn { font-size: 0.7rem; }
.budget-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; margin-bottom: 0.75rem; font-size: 0.68rem; }
.budget-table input.budget-input { width: 7rem; margin-left: auto; text-align: right; font-family: var(--bs-font-monospace); font-size: 0.72rem; }
.budget-table tr.group td { cursor: default; }
.analysis-table tr.budget-over td { background-color: rgba(220, 53, 69, 0.06); }

/* 소진율과 날짜 진행률을 한 트랙에 겹쳐 어느 쪽이 앞서는지 보이게 */
.pace-gauge { max-width: 720px; }
.pace-caption { font-size: 0.72rem; margin-bottom: 0.3rem; }
.pace-caption .text-muted { font-size: 0.68rem; }
.pace-track { position: relative; height: 20px; background: var(--bs-gray-200); border-radius: 3px; overflow: visible; }
.pace-fill { height: 100%; border-radius: 3px; background: #1f77b4; transition: width 0.2s; }
.pace-fill.fast, .pace-fill.risk { background: #ff7f0e; }
.pace-fill.over { background: #dc3545; }
.pace-marker { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: dashed 1.5px var(--bs-gray-700); }
.pace-marker span { position: absolute; left: 0.25rem; top: -0.15rem; font-size: 0.6rem; color: var(--bs-gray-700); white-space: nowrap; }
.pace-scale { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.35rem; font-size: 0.68rem; }
.pace-scale .badge { font-size: 0.6rem; font-weight: normal; }

/* Summary 상단 예산 위젯 — 표 두 개(KPI / 경고)와 게이지 한 줄로 정리.
   전에는 KPI·게이지·알림이 한 flex-wrap 안에 있어 폭에 따라 재배열됐다. 대시보드 위계가
   흔들리는 문제가 있어 세로 흐름(KPI → 게이지 → 경고)으로 고정한다 */
.budget-widget .budget-kpi { width: 100%; max-width: 640px; margin-bottom: 0.75rem; }
.budget-widget .budget-kpi th { font-size: 0.66rem; color: var(--bs-gray-600); font-weight: 400; text-align: right; }
.budget-widget .budget-kpi td.amount { font-size: 0.95rem; font-weight: 700; }
.budget-widget .pace-gauge { max-width: 640px; margin-bottom: 1rem; }
.budget-widget .budget-alerts { width: 100%; max-width: 640px; font-size: 0.72rem; }
.budget-widget .budget-alerts thead th { font-size: 0.72rem; font-weight: 700; color: var(--bs-gray-800); }
.budget-widget .budget-alerts thead th small { font-weight: 400; margin-left: 0.4rem; }
.budget-widget .budget-alerts td.usage { font-family: var(--bs-font-monospace); color: var(--bs-gray-700); width: 4rem; }
.budget-widget .budget-alerts td.amount { width: 7rem; }
.budget-widget .budget-alerts .more { font-size: 0.68rem; color: var(--red-dark); }

/* Plan — 저축률 / 시뮬레이터 / 목표 */
.sim-basis { font-size: 0.72rem; color: var(--bs-gray-700); margin-bottom: 0.75rem; }
.sim-results { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 0.75rem; }
.sim-results .kpi {
    flex: 1 1 150px; min-width: 0;
    border: solid 1px var(--bs-gray-300); border-radius: 0.35rem; padding: 0.6rem 0.8rem;
}
.sim-results .kpi .k { font-size: 0.66rem; color: var(--bs-gray-600); }
.sim-results .kpi .v { font-size: 1.05rem; font-weight: 700; font-family: var(--bs-font-monospace); margin: 0.15rem 0; }
.sim-results .kpi .v .unit { font-size: 0.75rem; }
.sim-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; margin-bottom: 0.5rem; font-size: 0.68rem; }
.sim-presets .btn { font-size: 0.66rem; padding: 0.1rem 0.4rem; }

.sim-table td, .sim-table th { vertical-align: middle; }
.sim-table .sim-slider-col { width: 190px; white-space: nowrap; }
.sim-table .sim-slider { width: 130px; vertical-align: middle; margin-right: 0.35rem; }
.sim-table .sim-cut { font-family: var(--bs-font-monospace); font-size: 0.68rem; color: var(--bs-gray-700); }

/* 절감 후 월 금액 직접 입력 — 슬라이더로는 못 맞추는 값을 위해 */
.sim-table .sim-after-input { width: 6.5rem; margin-left: auto; text-align: right; font-family: var(--bs-font-monospace); font-size: 0.7rem; }
.sim-table .sim-after, .sim-table .sim-save, .sim-table .sim-save-annual,
.sim-table tfoot td.amount { font-family: var(--bs-font-monospace); font-size: 0.7rem; }
.sim-table tr.sim-active { background-color: rgba(31, 119, 180, 0.06); }

/* 절감률 저장 — 프리셋 버튼 줄 오른쪽에 붙인다 */
.sim-save-action { margin-left: auto; display: inline-flex; align-items: center; gap: 0.5rem; }
.sim-save-action .text-muted { font-size: 0.68rem; }

/* 예산 제안값이 기준선에서 얼마나 깎인 건지 밝히는 꼬리표 */
.suggestion-basis { display: block; font-size: 0.62rem; color: var(--bs-gray-600); font-family: var(--bs-font-monospace); white-space: nowrap; }

/* Summary Reducibles — 절감률 목표 */
.goal-hint { font-size: 0.72rem; margin-bottom: 0.5rem; }
.sim-table tr.sim-active .sim-save, .sim-table tr.sim-active .sim-save-annual { color: var(--fin-positive); font-weight: 700; }

/* 저축 목표 */
.pace-basis { font-size: 0.75rem; margin-bottom: 0.75rem; }
.pace-basis .text-muted { font-size: 0.68rem; }
.analysis-table tr.goal-achieved td { background-color: rgba(25, 135, 84, 0.06); }
.analysis-table tr.goal-overdue td { background-color: rgba(220, 53, 69, 0.06); }
.goal-note { font-size: 0.66rem; color: var(--bs-gray-600); }
.goal-actions { white-space: nowrap; }
.goal-actions form { display: inline-block; margin: 0; }
.goal-actions .btn { padding: 0.1rem 0.35rem; font-size: 0.66rem; }

.goal-form { border: solid 1px var(--bs-gray-300); border-radius: 0.35rem; padding: 0.9rem 1rem; margin-top: 1rem; max-width: 900px; }
.goal-form h3 { font-size: 0.8rem; font-weight: 700; margin: 0 0 0.75rem; }
.goal-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.6rem 1rem; }
.goal-form-grid label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.7rem; }
.goal-form-grid label > span { color: var(--bs-gray-700); }
.goal-form-grid label small { font-size: 0.62rem; }
.goal-form-actions { display: flex; gap: 0.4rem; margin-top: 0.75rem; }
.goal-form-error { font-size: 0.68rem; color: var(--red-dark); margin-top: 0.4rem; }
.sim-basis .num { font-family: var(--bs-font-monospace); color: var(--fin-money); }
.sim-basis .num.Negative, .sim-results .kpi .v.Negative, .sim-results .kpi .v .Negative { color: var(--fin-negative); }
.sim-results .kpi.sim-deficit { border-color: rgba(220, 53, 69, 0.5); background: rgba(220, 53, 69, 0.04); }
.sim-results .kpi.sim-deficit .v { color: var(--fin-negative); }
/* 목표 이름 옆 계좌 배지 — span.account는 display:block이라 그냥 두면 줄바꿈된다 */
.analysis-table .goal-account { display: inline-block; width: auto; padding: 1px 8px; margin-left: 0.3rem; vertical-align: 1px; }
/* 예산 승계 안내 — 직접 편성 없이 이전 달 금액을 쓰고 있을 때 */
.budget-inherited { border: solid 1px var(--bs-gray-300); border-left: solid 3px #1f77b4; border-radius: 0.25rem;
    padding: 0.5rem 0.75rem; font-size: 0.75rem; max-width: 90ch; line-height: 1.55; }
.budget-inherited .text-muted { font-size: 0.7rem; }
.budget-inherited em { font-style: normal; font-weight: 700; }
.analysis-kpis .kpi .k .badge { font-size: 0.55rem; font-weight: normal; margin-left: 0.2rem; }
/* '평소 이맘때' 진척도 — 패턴을 못 배운 카테고리는 흐리게 (달력 진행률로 대체됨) */
.expected-pct { font-family: var(--bs-font-monospace); font-size: 0.7rem; }
.expected-pct.fallback { color: var(--bs-gray-500); }


/* ---------------------------------------------------------
   Dark theme
   Bootstrap 5.3의 data-bs-theme="dark"가 body/table/form/버튼 등
   기본 컴포넌트를 처리하고, 아래에서 이 프로젝트 고유 색만 맞춘다.

   핵심: Bootstrap은 --bs-gray-* 스케일을 다크에서 재정의하지 않는다.
   이 프로젝트 CSS는 gray 스케일을 "100=배경에 가깝고 900=대비가 가장 센 색"
   이라는 의미로 쓰므로, 스케일을 뒤집어 두면 기존 규칙 대부분이
   손대지 않고 그대로 맞는다.
   --------------------------------------------------------- */
[data-bs-theme="dark"] {
    /* Bootstrap 기본 다크 배경(#212529)보다 한 단 더 낮춰 대비를 세운다.
       gray-100(#2b3035)이 카드/표 바탕처럼 한 단계 위로 떠 보인다 */
    --bs-body-bg: #14171a;

    --bs-gray-100: #2b3035;
    --bs-gray-200: #343a40;
    --bs-gray-300: #444c54;
    --bs-gray-400: #6c757d;
    --bs-gray-500: #8b949e;
    --bs-gray-600: #a7b0b8;
    --bs-gray-700: #c2c9d0;
    --bs-gray-800: #d6dce1;
    --bs-gray-900: #e9ecef;

    /* 강조색 — 어두운 배경에서 읽히도록 밝게 올린다 */
    --red-dark: #ff6b6b;
    --red-dark-transparent: rgba(255, 107, 107, 0.7);
    --red-light: #ff8b95;
    --red-light-transparent: #4a1f21;
    --blue-dark: #4d9fff;
    --blue-light: #10344a;
    --blue-light-transparent: rgba(110, 190, 240, 0.12);
    --green-light: #16351a;
    --yellow-dark: #d9c85f;
    --yellow-light: #423f14;

    --fin-money: #dee2e6;
    --fin-negative: #ff6b6b;
    --fin-positive: #6cb2ff;
    --fin-percent: #4ec97a;
    --fin-faint: #565c63;
    --fin-root-bg: #495057;
    --fin-root-fg: #f8f9fa;
    --fin-highlight: #4d6b00;
    --fin-refreshed: #4a3a12;
    --fin-goal-bg: #15361f;

    --fin-chart-grid: #343a40;
    --fin-chart-track: #2b3035;
    --fin-chart-axis: #8b949e;
    --fin-chart-zero: #6c757d;
    --fin-chart-dot: #212529;
}

/* gray 반전으로 배경이 밝아지면서 흰 글자와 겹치는 곳만 따로 맞춘다 */
[data-bs-theme="dark"] .analysis-tabs .nav-link.active { background: var(--bs-gray-700); color: #212529; }

/* 어두운 툴팁이 어두운 배경 위에 놓이므로 경계를 세워준다 */
[data-bs-theme="dark"] .chart-tooltip { background: rgba(12, 14, 16, 0.96); border: solid 1px var(--bs-gray-300); }

/* rgba 음영은 밝은 배경 기준으로 잡혀 있어 어두운 배경에선 거의 안 보인다 */
[data-bs-theme="dark"] .analysis-table tr.budget-over td { background-color: rgba(220, 53, 69, 0.16); }
[data-bs-theme="dark"] .analysis-table tr.goal-achieved td { background-color: rgba(25, 135, 84, 0.18); }
[data-bs-theme="dark"] .analysis-table tr.goal-overdue td { background-color: rgba(220, 53, 69, 0.16); }
[data-bs-theme="dark"] .sim-table tr.sim-active { background-color: rgba(77, 159, 255, 0.14); }
[data-bs-theme="dark"] .sim-results .kpi.sim-deficit { background: rgba(220, 53, 69, 0.12); }
[data-bs-theme="dark"] .analysis-table td.ratio-cell::before { background: rgba(110, 190, 240, 0.22); }

/* 붙박이 빨강 배지 — 밝게 올린 --red-dark 위에 흰 글자는 대비가 부족하다 */
[data-bs-theme="dark"] .notes-badge { background: #c9252d; }

/* Bootstrap의 outline-dark는 다크에서 뒤집히지 않아 테두리가 배경에 묻는다 */
[data-bs-theme="dark"] .btn-outline-dark {
    --bs-btn-color: #dee2e6;
    --bs-btn-border-color: #6c757d;
    --bs-btn-hover-color: #212529;
    --bs-btn-hover-bg: #dee2e6;
    --bs-btn-hover-border-color: #dee2e6;
    --bs-btn-active-color: #212529;
    --bs-btn-active-bg: #dee2e6;
    --bs-btn-active-border-color: #dee2e6;
    --bs-btn-disabled-color: #6c757d;
    --bs-btn-disabled-border-color: #6c757d;
}

/* 계좌 배지는 카드사 브랜드색이라 테마와 무관하게 유지한다.
   단 흰 배경 배지만 어두운 화면에서 과하게 튀므로 톤을 낮춘다 */
[data-bs-theme="dark"] .APPLE { background-color: #d6dce1 !important; box-shadow: none !important; }

/* SVG 차트 — 블레이드의 stroke/fill 속성을 CSS로 덮어쓴다 */
.chart-grid-line { stroke: var(--fin-chart-grid); }
.chart-axis-label { fill: var(--fin-chart-axis); }
.chart-zero-line { stroke: var(--fin-chart-zero); }
.chart-zero-label { fill: var(--fin-chart-zero); }
.chart-focus-dot { stroke: var(--fin-chart-dot); }
.donut-track { stroke: var(--fin-chart-track); }

/* 도넛 조각 클릭 — 라벨과 같은 드릴다운.
   stroke-width를 살짝 키워 어느 조각을 겨누고 있는지 보이게 한다
   (opacity만 쓰면 색이 옅은 조각에서 변화가 안 읽힌다) */
.donut-slice { transition: stroke-width 0.12s ease; }
.donut-slice.is-link { cursor: pointer; }
.donut-chart a:hover .donut-slice.is-link,
.donut-chart a:focus-visible .donut-slice.is-link {
    stroke-width: calc(var(--donut-sw, 30) * 1.12);
}

.donut-total { fill: var(--bs-emphasis-color); }
.donut-caption { fill: var(--fin-chart-axis); }

/* 테마 토글 */
#theme-toggle .bi-sun-fill { display: none; }
[data-bs-theme="dark"] #theme-toggle .bi-sun-fill { display: inline-block; }
[data-bs-theme="dark"] #theme-toggle .bi-moon-stars-fill { display: none; }

/* 입력값 파랑(--bs-blue #0d6efd)은 어두운 입력 배경에서 대비가 모자란다 */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group .form-control,
[data-bs-theme="dark"] .select2-container .select2-selection.select2-selection--single .select2-selection__rendered {
    color: #6cb2ff;
}

/* 표의 굵은 구분선 — 반전된 gray-900(#e9ecef)은 선으로 쓰면 너무 튄다 */
[data-bs-theme="dark"] .table thead th { border-bottom-color: var(--bs-gray-500); }
[data-bs-theme="dark"] .table tfoot td { border-top-color: var(--bs-gray-500); }

/* ---------------------------------------------------------
   서드파티 위젯 — data-bs-theme를 따르지 않아 직접 맞춘다.
   두 라이브러리 CSS 모두 app.css보다 나중에 들어오므로
   [data-bs-theme] 로 명시도를 한 단계 올려 이긴다.
   --------------------------------------------------------- */

/* SweetAlert2 */
[data-bs-theme="dark"] .swal2-popup {
    background: #2b3035;
    color: #dee2e6;
}
[data-bs-theme="dark"] .swal2-title,
[data-bs-theme="dark"] .swal2-html-container { color: #e9ecef; }
[data-bs-theme="dark"] .swal2-close { color: #adb5bd; }
[data-bs-theme="dark"] .swal2-close:hover { color: #ff6b6b; }
[data-bs-theme="dark"] .swal2-input,
[data-bs-theme="dark"] .swal2-textarea,
[data-bs-theme="dark"] .swal2-select {
    background: #212529;
    color: #dee2e6;
    border-color: #495057;
}
[data-bs-theme="dark"] .swal2-footer { border-top-color: #495057; color: #adb5bd; }

/* select2 */
[data-bs-theme="dark"] .select2-dropdown {
    background-color: #2b3035;
    border-color: #495057;
    color: #dee2e6;
}
[data-bs-theme="dark"] .select2-container--default .select2-results__option { color: #dee2e6; }
[data-bs-theme="dark"] .select2-container--default .select2-results__option--selected { background-color: #343a40; }
[data-bs-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #0063d0;
    color: #fff;
}
[data-bs-theme="dark"] .select2-container--default .select2-search--dropdown .select2-search__field {
    background: #212529;
    color: #dee2e6;
    border-color: #495057;
}
[data-bs-theme="dark"] .select2-container--default .select2-selection--single { background-color: #212529; }
[data-bs-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__placeholder { color: #8b949e; }

/* 분할 표시 행은 --bs-warning(#ffc107) 배경이다. 다크에서는 셀 글자색이
   흰색으로 바뀌어 노란 배경 위에서 읽히지 않으므로 배경을 낮춘다 */
[data-bs-theme="dark"] .table tr.is-splitted td { background-color: #5a4410; }

/* 차트 툴팁은 두 테마 모두 어두운 배경이다.
   gray 스케일 반전을 그대로 받으면 다크에서 글자가 배경으로 가라앉으므로
   툴팁 안쪽 색만 반전에서 빼내 고정한다 */
[data-bs-theme="dark"] .chart-tooltip-date { color: #adb5bd; }
[data-bs-theme="dark"] .chart-tooltip-row .alt { color: #ced4da; }
