/* 기본 화면 설정 */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    background-color: #101114;
    color: #f5f5f5;
    font-family: -apple-system, BlinkMacSystemFont,
                 "Segoe UI", sans-serif;
    color-scheme: dark;
}

[hidden] {
    display: none !important;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

button:focus-visible {
    outline: 2px solid #92949a;
    outline-offset: 3px;
}

/* 공통 앱 레이아웃 */
#main-screen {
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    max-width: 430px;
    overflow-wrap: anywhere;
    margin: 0 auto;
    padding: calc(24px + env(safe-area-inset-top, 0px))
             max(24px, env(safe-area-inset-right, 0px))
             calc(24px + env(safe-area-inset-bottom, 0px))
             max(24px, env(safe-area-inset-left, 0px));
    display: flex;
    flex-direction: column;
}

.icon-library {
    position: absolute;
    overflow: hidden;
    pointer-events: none;
}

.icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.header-row {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
}

#screen-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: clamp(16px, 5vw, 21px);
    font-weight: 500;
    line-height: 1.25;
}

.icon-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #92949a;
    flex-shrink: 0;
}

.icon-button:active {
    background: #202126;
}

.current-date {
    display: block;
    margin: 0;
    flex-shrink: 0;
    white-space: nowrap;
    color: #92949a;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

#main-screen { gap: 12px; }
.icon-button:disabled { opacity: .5; cursor: default; }
/* Bank registration */
.home-menu { display: flex; flex-direction: column; justify-content: flex-start; }
.menu-card { display:flex; align-items:center; gap:12px; width:100%; min-height:64px; padding:16px; border:0; border-radius:12px; background:#24252a; text-align:left; }
.menu-card .arrow { margin-left:auto; color:#92949a; width:18px; }
.amount { flex-shrink:0; max-width:65%; margin-left:auto; font-variant-numeric:tabular-nums; text-align:right; }
.bank-list { display:flex; flex-direction:column; gap:12px; margin-bottom:12px; }
.bank-group { background:#24252a; border-radius:12px; overflow:hidden; }
.bank-heading { display:flex; align-items:center; gap:6px; padding:4px 8px; }
.bank-heading button:first-child { flex:1; min-width:0; text-align:left; }
.bank-name, .account-row { border:0; background:transparent; color:inherit; font:inherit; overflow-wrap:anywhere; }
.bank-name { padding:12px 6px; font-weight:600; }
.account-row { display:flex; align-items:center; justify-content:space-between; gap:8px; width:100%; min-height:48px; padding:12px 14px; border-top:1px solid #35363c; text-align:left; }
.account-row span:first-child { min-width:0; }
.account-row .amount { font-size:14px; }
.outline-button,.save-button,.delete-button { width:100%; min-height:44px; border-radius:8px; padding:10px; }
.outline-button { border:1px solid #45474d; background:transparent; color:#a1a3a9; }
.bank-group .outline-button { border:0; border-top:1px solid #35363c; border-radius:0; font-size:13px; }
:is(#account-form,.account-form) { display:flex; flex-direction:column; gap:10px; }
:is(#account-form,.account-form) label { display:block; font-size:13px; color:#a1a3a9; margin-bottom:6px; }
:is(#account-form,.account-form) input { width:100%; min-width:0; min-height:46px; background:#24252a; border:1px solid #35363c; border-radius:8px; color:inherit; padding:10px; font:inherit; font-size:16px; }
.balance-input { display:flex; align-items:center; gap:8px; }
.balance-input span { white-space:nowrap; color:#a1a3a9; }
.save-button { background:#45474d; color:#f5f5f5; border:0; }
.delete-button { border:0; background:transparent; color:#e49a9a; }
.status { font-size:12px; color:#e49a9a; margin:4px 0; }
.status:empty { display:none; }
.context { color:#a1a3a9; font-size:13px; margin:0; }

#assets-screen { display:flex; flex-direction:column; gap:10px; }
.menu-card .amount + .arrow { margin-left:0; }
.broker-cash { margin:0; padding:0 14px 10px; color:#a1a3a9; font-size:12px; }
.stock-row { padding-left:24px; background:#202126; }
.stock-label { display:flex; flex-direction:column; gap:3px; }
.stock-meta { color:#92949a; font-size:11px; }
.bank-group .stock-add { padding-left:24px; text-align:left; background:#202126; }

.home-menu { gap:10px; }
.recurring-summary { display:flex; align-items:center; justify-content:space-between; gap:10px; color:#a1a3a9; padding:8px 2px 14px; font-size:14px; }
.recurring-summary strong { color:#f5f5f5; font-variant-numeric:tabular-nums; }
.expense-row { border:0; border-radius:10px; background:#24252a; min-height:58px; }
.account-form select { width:100%; min-width:0; min-height:46px; background:#24252a; border:1px solid #35363c; border-radius:8px; color:inherit; padding:10px; font:inherit; font-size:16px; }

#recurring-screen { display:flex; flex-direction:column; gap:10px; }

.card-payment-fields { display:flex; flex-direction:column; gap:10px; }

/* Shared date picker */
.monthly-day-grid {
    display:grid;
    grid-template-columns:repeat(7,minmax(0,1fr));
    gap:4px;
    padding:6px;
    border-radius:12px;
    background:#191a1e;
}
.calendar-weekday { text-align:center; color:#a1a3a9; font-size:11px; }
#date-calendar-month { margin:0; }
.monthly-day-button {
    width:100%;
    min-width:0;
    min-height:44px;
    aspect-ratio:1;
    padding:0;
    border:0;
    border-radius:8px;
    background:#24252a;
    font-size:16px;
    font-variant-numeric:tabular-nums;
}
.monthly-day-button[aria-pressed="true"] { background:#565960; font-weight:600; }
.monthly-day-button:active { background:#45474d; }
.monthly-last-day { grid-column:span 4; aspect-ratio:auto; font-size:14px; }
.day-picker-button { display:flex; align-items:center; gap:10px; width:100%; min-height:46px; padding:10px; background:#24252a; border:1px solid #35363c; border-radius:8px; text-align:left; }
.day-picker-button .arrow { margin-left:auto; color:#92949a; width:18px; }
#date-picker-screen { display:flex; flex-direction:column; gap:12px; }
.picker-label { color:#a1a3a9; font-size:13px; margin:0 0 6px; }
#date-picker-screen > .picker-label { margin:0; }
.date-selection { display:flex; align-items:center; justify-content:space-between; gap:8px; border-top:1px solid #35363c; margin-top:8px; padding-top:12px; font-size:13px; color:#a1a3a9; }
.date-selection strong { color:#f5f5f5; text-align:right; min-width:0; overflow-wrap:anywhere; }

/* Planner schedule */
.planner-month { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:12px; }
.planner-month strong { font-size:16px; font-weight:600; font-variant-numeric:tabular-nums; }
.planner-list { display:flex; flex-direction:column; gap:16px; }
.planner-day { margin:0 0 6px 2px; color:#a1a3a9; font-size:13px; font-weight:500; }
.planner-row:first-child { border-top:0; }
.planner-row .stock-label { flex:1; min-width:0; }
.planner-amount { max-width:100%; }
.planner-empty { color:#92949a; font-size:13px; text-align:center; padding:24px 0; }

.planner-reminder .planner-amount { color:#a1a3a9; }

#transfer-mode-hint { margin-top:6px; line-height:1.5; }

/* Manual list order: only the grip captures pointer gestures. */
.order-row { display:flex; align-items:center; min-width:0; gap:0; position:relative; background:#24252a; }
.order-row > .account-row { flex:1; min-width:0; padding-left:6px; border-top:0; }
.order-row + .order-row, .bank-group > .order-row { border-top:1px solid #35363c; }
.bank-list > .order-row { border-radius:10px; border-top:0; }
.bank-group > .order-row:has(.stock-row) { background:#202126; }
.order-row > .stock-row { padding-left:16px; }
.order-handle { flex-shrink:0; display:grid; place-items:center; width:32px; min-height:44px; background:transparent; border:0; color:#92949a; font-size:23px; line-height:1; cursor:grab; touch-action:none; user-select:none; -webkit-user-select:none; }
.order-handle:active { cursor:grabbing; }
.bank-heading > .order-handle { flex:0 0 32px; text-align:center; }
.bank-heading:has(.order-handle) > .bank-name { flex:1; min-width:0; text-align:left; }
.order-dragging { opacity:.45; }
.order-before { box-shadow:inset 0 2px #92949a; }
.order-after { box-shadow:inset 0 -2px #92949a; }

.planner-bill-button { background:transparent; border:1px solid #45474d; border-radius:7px; padding:7px 8px; color:#f5f5f5; font:inherit; font-size:13px; font-variant-numeric:tabular-nums; }
.planner-bill-button:disabled { opacity:.5; }

/* Restored v0.1 custom views */
.payment-method-row { display:flex; align-items:center; min-width:0; min-height:52px; background:#191a1e; border-bottom:1px solid #303136; touch-action:pan-y; }
.payment-method-name { min-width:0; font-size:12px; line-height:1.4; overflow-wrap:anywhere; }
.payment-method-row .bank-grip { width:32px; height:52px; touch-action:none; }
.payment-method-row .bank-grip .icon { width:16px; height:16px; }
.payment-method-empty { margin:0; padding:12px 8px; font-size:11px; text-align:center; }
.payment-method-drag-source { opacity:.35; }
.payment-method-drag-ghost { position:fixed; z-index:9999; pointer-events:none; border:1px solid #92949a; border-radius:8px; box-shadow:0 6px 18px #0009; }
.payment-method-drop-active { border-color:#a8d5b9; background:#202824; }
.payment-method-drop-before { box-shadow:inset 0 2px #a8d5b9; }
.payment-method-drop-end { box-shadow:inset 0 -2px #a8d5b9; }

.overview-view-tabs { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; margin-bottom:8px; }
.overview-view-tab { min-width:0; min-height:38px; border:1px solid #35363c; border-radius:7px; background:#202126; padding:6px 4px; font-size:13px; overflow-wrap:anywhere; }
.overview-view-tab[aria-pressed="true"] { background:#41454d; border-color:#73757b; }
.overview-total-toolbar { display:flex; align-items:center; gap:7px; min-height:44px; }
.overview-total-toolbar .bank-total-value { margin-left:auto; }
.overview-view-balance + .overview-view-balance { border-top:1px solid #303136; }
.overview-view-balance .bank-labels { font-size:13px; }
.overview-manage-row { display:flex; align-items:center; min-width:0; min-height:38px; background:#202126; border:1px solid #35363c; border-radius:7px; }
.overview-manage-label { flex:1; min-width:0; min-height:36px; padding:5px 2px 5px 6px; border:0; background:transparent; font-size:13px; overflow-wrap:anywhere; }
.overview-manage-row .bank-grip { flex:0 0 25px; width:25px; height:36px; touch-action:none; }
.overview-manage-row .bank-grip .icon { width:15px; height:15px; }
.overview-manage-row.overview-grid-target { border-color:#a8d5b9; background:#303e35; box-shadow:inset 0 0 0 1px #a8d5b9; }
.overview-edit-form { display:flex; flex:1 1 0; min-height:0; flex-direction:column; gap:10px; }
.overview-edit-name-label { display:flex; flex-direction:column; gap:4px; }
.overview-view-input { width:100%; color:inherit; background:#202126; border:1px solid #45474d; border-radius:7px; min-height:40px; padding:8px 10px; font:inherit; min-width:0; }
.overview-edit-form .bank-status { margin:0; }
.overview-delete-view { background:transparent; border:0; color:#e28d8d; min-height:38px; font-size:13px; }


.overview-drop-after { box-shadow:inset 0 -2px #a8d5b9; }

.overview-select-all { align-self:flex-start; color:inherit; background:#292a2f; border:1px solid #45474d; border-radius:6px; padding:7px 12px; min-height:36px; font-size:12px; }
.overview-select-all:disabled { opacity:.35; }
.overview-edit-toolbar { display:flex; justify-content:flex-end; align-items:center; }
.overview-edit-toolbar .text-button { min-height:36px; }

#overview-edit-screen { min-height:calc(100dvh - 116px); }
#overview-edit-form .overview-total-setting { display:flex; align-items:center; justify-content:space-between; margin:0; min-height:44px; }
#overview-edit-form .overview-total-setting input { width:20px; min-height:20px; accent-color:#92949a; }
#overview-edit-form .overview-edit-name-label { margin:0; }
.bank-caption { color:#a1a3a9; font-size:12px; }
.bank-money,.bank-total-value { margin-left:auto; font-variant-numeric:tabular-nums; text-align:right; }
.overview-total-toolbar { font-size:14px; color:#a1a3a9; }
.overview-total-toolbar .bank-total-value { color:#f5f5f5; font-size:18px; font-weight:600; }
.overview-list { gap:0; background:#24252a; border-radius:12px; }
.overview-view-balance { display:flex; align-items:center; gap:8px; padding:12px; min-height:48px; }
.overview-view-balance .bank-labels { flex:1; min-width:0; overflow-wrap:anywhere; }
.overview-view-balance .bank-money { min-width:0; max-width:65%; font-size:13px; }
.overview-empty { padding:12px; text-align:center; margin:0; }
.overview-edit-toolbar .text-button { background:transparent; border:0; color:#a1a3a9; }

.overview-add-tab { font-size:23px; color:#a1a3a9; background:transparent; border-style:dashed; line-height:1; }
.overview-add-tab:disabled { opacity:.4; }
.overview-selection-toolbar { display:flex; justify-content:space-between; align-items:center; gap:8px; }
.overview-checkbox-list { min-height:80px; max-height:48vh; max-height:48dvh; overflow-y:auto; border:1px solid #35363c; border-radius:8px; }
.overview-check-row:last-child { border-bottom:0; }
#overview-edit-form .overview-check-label { display:flex; align-items:center; flex:1; min-width:0; gap:10px; margin:0; padding:8px 10px; min-height:52px; color:#f5f5f5; cursor:pointer; }
#overview-edit-form .overview-account-checkbox { flex:0 0 20px; width:20px; height:20px; min-height:20px; padding:0; margin:0; accent-color:#92949a; }
.overview-check-label .payment-method-name { font-size:14px; }

.daily-menu { display:flex; flex-direction:column; gap:10px; margin-bottom:12px; }
.daily-record .stock-label { flex:1; min-width:0; }
.daily-undo { background:transparent; border:1px solid #45474d; border-radius:6px; color:#a1a3a9; font-size:12px; padding:7px 8px; flex-shrink:0; }

.management-menu { display:flex; flex-direction:column; gap:10px; }
.management-menu[hidden] { display:none; }

.methods-tabs { grid-template-columns:repeat(4,minmax(0,1fr)); }
.methods-toolbar { display:flex; align-items:center; justify-content:space-between; gap:8px; margin:8px 0; }
.methods-toolbar .context { margin:0; }
.methods-row { position:relative; }
.methods-row:last-child { border-bottom:0; }
.methods-check-label { display:flex; align-items:center; flex:1; min-width:0; gap:10px; min-height:52px; padding:8px 10px; cursor:pointer; }
.methods-check-label span { overflow-wrap:anywhere; }
.methods-checkbox { flex:0 0 20px; width:20px; height:20px; margin:0; accent-color:#92949a; }

.transactions-tabs { grid-template-columns:repeat(2,minmax(0,1fr)); }
.transactions-credit { margin-bottom:14px; }
.transactions-credit:empty { display:none; }
.transaction-row { padding:12px 14px; border-bottom:1px solid #35363c; }
.transaction-row:last-child { border-bottom:0; }
.transaction-info { display:flex; align-items:center; gap:8px; justify-content:space-between; }
.transaction-info .stock-label { flex:1; min-width:0; }
.transaction-buttons { display:flex; justify-content:flex-end; gap:8px; margin-top:8px; }
.transactions-confirm { margin-top:10px; }
.transactions-confirm:disabled { opacity:.45; }
#transactions-planner { margin-top:18px; }
.planner-controls { display:flex; flex-direction:column; align-items:flex-end; gap:6px; max-width:65%; flex-shrink:0; }

.settings-card { padding:14px; border-radius:12px; background:#24252a; margin-bottom:12px; }
.settings-menu { display:flex; flex-direction:column; gap:10px; }
#settings-confirm-form .settings-toggle { display:flex; align-items:center; justify-content:space-between; gap:12px; color:inherit; font-size:16px; margin:0; cursor:pointer; }
#settings-confirm-form .settings-toggle input { appearance:none; width:44px; height:26px; min-height:26px; margin:0; padding:3px; background:#505158; border:0; border-radius:20px; flex-shrink:0; cursor:pointer; }
#settings-confirm-form .settings-toggle input::before { content:""; display:block; width:20px; height:20px; border-radius:50%; background:#fff; }
#settings-confirm-form .settings-toggle input:checked { background:#528b65; }
#settings-confirm-form .settings-toggle input:checked::before { transform:translateX(18px); }
.settings-danger { color:#e49a9a; }
.settings-file-summary { overflow-wrap:anywhere; }
#transaction-confirm-panel { margin-top:12px; }
:is(#settings-screen,#export-data-screen,#import-data-screen,#reset-data-screen) button:disabled { opacity:.45; cursor:default; }

#settings-confirm-form { gap:0; }

/* Overview uses explicit grid cells, including intentionally empty positions. */
.overview-empty-slot { min-height:38px; min-width:0; }
.overview-edit-slot { border:1px dashed #45474d; border-radius:7px; }
.overview-edit-slot.overview-grid-target { border-color:#a8d5b9; background:#303e35; box-shadow:inset 0 0 0 1px #a8d5b9; }
.overview-add-tab { grid-column:1 / -1; }
