/* ===== CSS Variables (shadcn/ui style) ===== */
:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 240 5.9% 10%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 240 5.9% 10%;
    --radius: 0.5rem;

    /* Custom colors */
    --success: 142.1 76.2% 36.3%;
    --warning: 38 92% 50%;
    --info: 221.2 83.2% 53.3%;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: hsl(var(--muted));
    color: hsl(var(--foreground));
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== App Layout ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 240px;
    background: hsl(var(--card));
    border-right: 1px solid hsl(var(--border));
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid hsl(var(--border));
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: hsl(var(--foreground));
    font-weight: 600;
    font-size: 1.125rem;
}

.logo svg {
    color: hsl(var(--foreground));
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.nav-item:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.nav-item.active {
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
}

.nav-item svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid hsl(var(--border));
}

.nav-item.logout {
    color: hsl(var(--muted-foreground));
}

.nav-item.logout:hover {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 2rem;
    min-height: 100vh;
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

.container.wide {
    max-width: 100%;
}

/* ===== Page Header ===== */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

.filters-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ===== Period Filters ===== */
.period-filters {
    display: flex;
    gap: 0.25rem;
    background: hsl(var(--muted));
    padding: 0.25rem;
    border-radius: var(--radius);
}

.period-btn {
    padding: 0.5rem 0.875rem;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.period-btn:hover {
    color: hsl(var(--foreground));
}

.period-btn.active {
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* ===== Custom Date Row ===== */
.custom-date-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.custom-date-row input[type="date"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: hsl(var(--background));
}

.custom-date-row input[type="date"]:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.custom-date-row span {
    color: hsl(var(--muted-foreground));
}

/* ===== Filters ===== */
.filters {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.filters select {
    padding: 0.5rem 0.75rem;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    cursor: pointer;
}

.filters select:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

/* ===== Search Box ===== */
.search-box {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-left: auto;
}

.search-box input[type="text"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    min-width: 200px;
}

.search-box input[type="text"]:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.search-box input[type="text"]::placeholder {
    color: hsl(var(--muted-foreground));
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}

.pagination-info {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.pagination-controls {
    display: flex;
    gap: 0.25rem;
}

.pagination-controls .btn {
    min-width: 2rem;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.btn-primary:hover:not(:disabled) {
    background: hsl(var(--primary) / 0.9);
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover:not(:disabled) {
    background: hsl(var(--secondary) / 0.8);
}

.btn-outline {
    background: transparent;
    border: 1px solid hsl(var(--input));
    color: hsl(var(--foreground));
}

.btn-outline:hover:not(:disabled) {
    background: hsl(var(--accent));
}

.btn-ghost {
    background: transparent;
    color: hsl(var(--foreground));
}

.btn-ghost:hover:not(:disabled) {
    background: hsl(var(--accent));
}

.btn-destructive {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.btn-destructive:hover:not(:disabled) {
    background: hsl(var(--destructive) / 0.9);
}

.btn-danger {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.btn-danger:hover:not(:disabled) {
    background: hsl(var(--destructive) / 0.9);
}

.btn-info {
    background: hsl(var(--info));
    color: white;
}

.btn-info:hover:not(:disabled) {
    background: hsl(var(--info) / 0.85);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Action Buttons (수정/삭제) */
.btn-edit {
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--info));
    background: hsl(var(--info) / 0.1);
    color: hsl(var(--info));
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-edit:hover {
    background: hsl(var(--info));
    color: white;
}

.btn-delete {
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--destructive));
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-delete:hover {
    background: hsl(var(--destructive));
    color: white;
}

.btn-delete-small {
    width: 1.25rem;
    height: 1.25rem;
    padding: 0;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 50%;
    border: 1px solid hsl(var(--destructive) / 0.5);
    background: transparent;
    color: hsl(var(--destructive));
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-delete-small:hover {
    background: hsl(var(--destructive));
    border-color: hsl(var(--destructive));
    color: white;
}

.btn-sms {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-sms:hover {
    background: hsl(var(--muted-foreground));
    border-color: hsl(var(--muted-foreground));
    color: white;
}

/* ===== Summary Cards ===== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.25rem;
}

.summary-card.total {
    background: hsl(var(--primary));
    border-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.summary-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.summary-card.total .summary-label {
    color: hsl(var(--primary-foreground) / 0.7);
}

.summary-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    letter-spacing: -0.025em;
}

.summary-card.total .summary-value {
    color: hsl(var(--primary-foreground));
}

.summary-count {
    display: block;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.25rem;
}

.summary-card.total .summary-count {
    color: hsl(var(--primary-foreground) / 0.7);
}

/* ===== Table Container ===== */
.table-container {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    overflow: hidden;
}

/* ===== Transaction Table ===== */
.tx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.tx-table thead {
    background: hsl(var(--muted));
}

.tx-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid hsl(var(--border));
}

.tx-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid hsl(var(--border));
    vertical-align: middle;
}

.tx-table tbody tr:hover {
    background: hsl(var(--muted) / 0.5);
}

.tx-table tbody tr:last-child td {
    border-bottom: none;
}

.col-check {
    width: 40px;
    text-align: center;
}

.col-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: hsl(var(--primary));
}

.col-date {
    white-space: nowrap;
    color: hsl(var(--muted-foreground));
    font-size: 0.8125rem;
}

.col-detail {
    max-width: 280px;
}

.col-detail .detail-main {
    font-weight: 500;
    color: hsl(var(--foreground));
    display: block;
}

.col-detail .detail-sub {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    display: block;
    margin-top: 0.125rem;
}

.col-amount {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.col-amount-header {
    text-align: right;
}

.col-category .category-tag {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    background: hsl(var(--muted));
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
}

.image-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius);
    background: hsl(var(--info) / 0.1);
    color: hsl(var(--info));
    margin-left: 0.25rem;
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.owner-label {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius);
    font-size: 0.6875rem;
    font-weight: 500;
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
    margin-right: 0.25rem;
}

.payment-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.payment-badge.신용카드, .payment-badge.체크카드 {
    background: hsl(221 83% 95%);
    color: hsl(221 83% 40%);
}

.payment-badge.현금 {
    background: hsl(142 76% 95%);
    color: hsl(142 76% 30%);
}

.payment-badge.지역화폐, .payment-badge.포인트 {
    background: hsl(280 60% 95%);
    color: hsl(280 60% 40%);
}

.payment-badge.계좌이체 {
    background: hsl(38 92% 95%);
    color: hsl(38 92% 35%);
}

/* ===== Toggle Button ===== */
.toggle-btn {
    background: none;
    border: none;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.125rem;
    margin-right: 0.25rem;
}

.toggle-btn:hover {
    color: hsl(var(--foreground));
}

/* ===== Child Rows ===== */
.has-children {
    background: hsl(var(--muted) / 0.3);
}

.child-row {
    background: hsl(var(--background));
}

.child-row.hidden,
.grandchild-row.hidden,
.grandchildren-list.hidden {
    display: none;
}

.child-indent {
    padding-left: 1rem;
    color: hsl(var(--muted-foreground));
}

.split-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.0625rem 0.375rem;
    border-radius: var(--radius);
    font-size: 0.625rem;
    font-weight: 500;
    margin-left: 0.25rem;
    background: hsl(var(--info) / 0.15);
    color: hsl(var(--info));
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: hsl(var(--foreground) / 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.modal-wide {
    max-width: 750px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid hsl(var(--border));
}

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    font-weight: 300;
    cursor: pointer;
    color: hsl(var(--muted-foreground));
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    transition: all 0.15s ease;
    line-height: 1;
}

.modal-close:hover {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
}

.modal-content form {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid hsl(var(--border));
    margin-top: 1rem;
}

/* ===== Form ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    color: hsl(var(--foreground));
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    transition: all 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: hsl(var(--muted-foreground));
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ===== Apply Children Row ===== */
.apply-children-row {
    margin: -0.5rem 0 1rem 0;
    text-align: right;
}

/* ===== Link Section ===== */
.link-section {
    border-top: 1px solid hsl(var(--border));
    margin-top: 1rem;
    padding-top: 1rem;
}

.link-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
}

.link-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* ===== Children List (Inline Edit) ===== */
.children-list {
    max-height: 300px;
    overflow-y: auto;
}

.child-item {
    background: hsl(var(--muted));
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    font-size: 0.8125rem;
}

.child-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.child-amount {
    font-weight: 600;
    margin-left: auto;
    font-variant-numeric: tabular-nums;
}

.child-actions {
    display: flex;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.child-detail {
    color: hsl(var(--foreground));
    margin-bottom: 0.125rem;
}

.child-info {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

.child-payment {
    color: hsl(var(--muted-foreground));
}

.child-category {
    color: hsl(var(--muted-foreground));
}

.child-item .badge {
    font-size: 0.625rem;
    padding: 0.0625rem 0.375rem;
}

.child-item .badge.split {
    background: hsl(var(--info) / 0.15);
    color: hsl(var(--info));
}

.child-item .badge.additional {
    background: hsl(var(--success) / 0.15);
    color: hsl(var(--success));
}

.child-item .badge.merged {
    background: hsl(280 60% 95%);
    color: hsl(280 60% 40%);
}

/* ===== Child Edit ===== */
.child-edit {
    padding-top: 0.5rem;
}

.child-edit-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.child-edit-row label {
    width: 55px;
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

.child-edit-row input,
.child-edit-row select {
    flex: 1;
    padding: 0.375rem 0.5rem;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    font-size: 0.8125rem;
    background: hsl(var(--background));
}

.child-edit-row input:focus,
.child-edit-row select:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.child-edit-row .category-selects {
    flex: 1;
    display: flex;
    gap: 0.5rem;
}

.child-edit-row .category-selects select {
    flex: 1;
}

.child-edit-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    padding-top: 0.25rem;
}

/* ===== Split Modal ===== */
.split-summary {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: hsl(var(--muted));
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.split-summary strong {
    font-weight: 600;
}

.split-items {
    max-height: 300px;
    overflow-y: auto;
}

.split-item-wrapper {
    background: hsl(var(--muted) / 0.5);
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.split-item-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.split-item-row:last-child {
    margin-bottom: 0;
}

.split-item-row input,
.split-item-row select {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: hsl(var(--background));
}

.split-item-row input:focus,
.split-item-row select:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

.split-remove-btn {
    padding: 0.5rem;
    background: none;
    border: none;
    color: hsl(var(--destructive));
    cursor: pointer;
    border-radius: var(--radius);
}

.split-remove-btn:hover {
    background: hsl(var(--destructive) / 0.1);
}

.split-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
}

.validation-msg {
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
}

.validation-msg.error {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
}

.validation-msg.success {
    background: hsl(var(--success) / 0.1);
    color: hsl(var(--success));
}

/* ===== Additional Modal ===== */
.modal-medium {
    max-width: 550px;
}

/* ===== SMS List ===== */
.sms-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sms-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1rem;
    transition: all 0.15s ease;
}

.sms-card:hover {
    border-color: hsl(var(--ring));
}

.sms-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid hsl(var(--border));
}

.sender-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.sender-name {
    font-weight: 600;
    color: hsl(var(--foreground));
}

.sender-phone {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

.sms-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.device-id {
    font-size: 0.6875rem;
    color: hsl(var(--info));
    background: hsl(var(--info) / 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius);
}

.received-at {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
}

.sms-content {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    color: hsl(var(--muted-foreground));
}

/* ===== Text Utilities ===== */
.text-muted {
    color: hsl(var(--muted-foreground));
}

.text-right {
    text-align: right;
}

/* ===== Children Table (legacy) ===== */
.children-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    margin-bottom: 0.75rem;
}

.children-table th,
.children-table td {
    padding: 0.5rem;
    border-bottom: 1px solid hsl(var(--border));
    text-align: left;
}

.children-table th {
    background: hsl(var(--muted));
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    font-size: 0.75rem;
}

.children-table .text-right {
    text-align: right;
}

.children-table .btn-sm {
    padding: 0.125rem 0.375rem;
    font-size: 0.6875rem;
    margin-right: 0.25rem;
}

/* ===== Responsive ===== */
/* ===== Mobile Header ===== */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: hsl(var(--card));
    border-bottom: 1px solid hsl(var(--border));
    padding: 0 0.75rem;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.mobile-nav {
    display: flex;
    gap: 0.5rem;
}

.mobile-nav-btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.mobile-nav-btn:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.mobile-nav-btn.active {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.mobile-settings-btn {
    padding: 0.5rem;
    color: hsl(var(--muted-foreground));
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.mobile-settings-btn:hover,
.mobile-settings-btn.active {
    background: hsl(var(--accent));
    color: hsl(var(--foreground));
}

.menu-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    margin: -0.5rem;
    cursor: pointer;
    color: hsl(var(--foreground));
}

.mobile-logo {
    font-weight: 600;
    font-size: 1.125rem;
    color: hsl(var(--foreground));
    text-decoration: none;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 40;
}

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

@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
    .main-content {
        margin-left: 200px;
    }
}

@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        overflow-y: auto;
        width: 100%;
        height: auto;
        min-height: 100%;
    }
    .app-container {
        overflow-x: hidden;
        overflow-y: visible;
        width: 100%;
        min-height: 100vh;
    }
    .mobile-header {
        display: flex;
    }
    .sidebar {
        display: none;
    }
    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: calc(56px + 1rem);
        overflow-x: hidden;
        width: 100%;
        box-sizing: border-box;
    }
    .container {
        width: 100%;
        padding: 0;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .page-header h1 {
        font-size: 1.25rem;
    }
    .filters-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .period-filters {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }
    .period-filters::-webkit-scrollbar {
        display: none;
    }
    .action-buttons {
        justify-content: flex-end;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .card {
        padding: 1rem;
    }
    .table-container {
        margin: 0 -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .data-table {
        min-width: 600px;
    }
    .data-table th,
    .data-table td {
        padding: 0.625rem 0.5rem;
        font-size: 0.8125rem;
    }
    .col-checkbox {
        width: 2rem;
    }
    .col-amount {
        min-width: auto;
    }
    body.sidebar-open {
        overflow: hidden;
    }
    /* 모달 모바일 최적화 */
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    /* 모바일 카드뷰/테이블 전환 */
    .mobile-tx-list {
        display: block !important;
        padding-bottom: 0;
    }
    .desktop-only {
        display: none !important;
    }
    /* 선택 모드일 때 하단 여백 */
    .mobile-tx-list.select-mode {
        padding-bottom: 5rem;
    }
    /* 컨테이너 스크롤 개선 */
    .main-content {
        min-height: auto;
        padding-bottom: 2rem;
    }
    .transactions-page {
        height: auto !important;
        min-height: auto;
    }
    /* 모바일 페이지네이션 */
    .pagination {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }
    .pagination-info {
        font-size: 0.75rem;
    }
    .pagination-controls .btn {
        min-width: 2.25rem;
        padding: 0.5rem;
    }
}

/* ===== Mobile Transaction Cards ===== */
.mobile-tx-list {
    display: none;
}

.tx-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 0.875rem;
    margin-bottom: 0.5rem;
    display: flex;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.tx-card:active {
    background: hsl(var(--accent));
}

.tx-card-checkbox {
    display: none;
    align-items: flex-start;
    padding-top: 0.125rem;
}

.tx-card-checkbox input {
    width: 1.125rem;
    height: 1.125rem;
}

.mobile-tx-list.select-mode .tx-card-checkbox {
    display: flex;
}

.tx-card-content {
    flex: 1;
    min-width: 0;
}

.tx-card-row1 {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.tx-card-date {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

.tx-card-detail {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-card-amount {
    font-size: 0.875rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    flex-shrink: 0;
}

.tx-card-row2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tx-card-label {
    font-size: 0.6875rem;
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    padding: 0.125rem 0.375rem;
    border-radius: calc(var(--radius) - 2px);
}

.tx-card-label.category {
    background: hsl(var(--primary) / 0.1);
    color: hsl(var(--primary));
}

.tx-card-row3 {
    margin-top: 0.375rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* ===== Tags ===== */
.detail-tags {
    margin-top: 0.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.tag-badge {
    font-size: 0.6875rem;
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
    padding: 0.125rem 0.375rem;
    border-radius: calc(var(--radius) - 2px);
}

.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0.5rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--background));
    min-height: 2.5rem;
    cursor: text;
}

.tag-input-container:focus-within {
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 2px hsl(var(--primary) / 0.2);
}

.tag-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    padding: 0.25rem 0.5rem;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.8125rem;
}

.tag-item .tag-remove {
    cursor: pointer;
    opacity: 0.6;
    font-size: 0.875rem;
    line-height: 1;
}

.tag-item .tag-remove:hover {
    opacity: 1;
}

.tag-input {
    flex: 1;
    min-width: 80px;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.875rem;
    padding: 0.25rem 0;
}

/* 하위 항목 태그 */
.child-tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.375rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background: hsl(var(--background));
    min-height: 32px;
    align-items: center;
}

.child-tag-container:focus-within {
    border-color: hsl(var(--primary));
}

.child-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.child-tag-input {
    flex: 1;
    min-width: 60px;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.8125rem;
    padding: 0.125rem 0;
}

.child-tags {
    display: inline-flex;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

.child-tag {
    font-size: 0.75rem;
    color: hsl(var(--primary));
    background: hsl(var(--primary) / 0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
}

.image-badge-small {
    font-size: 0.6875rem;
    color: hsl(var(--muted-foreground));
}

.empty-state-mobile {
    text-align: center;
    padding: 3rem 1rem;
    color: hsl(var(--muted-foreground));
}

/* ===== Settings Page ===== */
.settings-list {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    overflow: hidden;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: hsl(var(--foreground));
    border-bottom: 1px solid hsl(var(--border));
    transition: background 0.15s ease;
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item:hover {
    background: hsl(var(--accent));
}

.settings-item-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--secondary));
    border-radius: var(--radius);
    color: hsl(var(--foreground));
    flex-shrink: 0;
}

.settings-item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.settings-item-title {
    font-weight: 500;
    font-size: 0.9375rem;
}

.settings-item-desc {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
}

.settings-item-arrow {
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

.settings-divider {
    height: 0.5rem;
    background: hsl(var(--muted));
    border-bottom: 1px solid hsl(var(--border));
}

.settings-item-danger {
    color: hsl(var(--destructive));
}

.settings-item-danger .settings-item-icon {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
}

/* 모바일 카드 자식 거래 */
.tx-card-children {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed hsl(var(--border));
}

.tx-card-child {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.75rem;
}

.tx-card-child .child-label {
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

.tx-card-child .child-detail {
    flex: 1;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-card-child .child-amount {
    color: hsl(var(--foreground));
    flex-shrink: 0;
}

/* 모바일 선택 모드 툴바 */
.mobile-select-toolbar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: hsl(var(--card));
    border-top: 1px solid hsl(var(--border));
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    z-index: 100;
}

.mobile-select-toolbar.active {
    display: flex;
}

.mobile-select-toolbar .btn {
    flex: 1;
}

/* ===== Image Upload ===== */
.image-upload-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.image-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.image-gallery .no-images,
.image-gallery .loading-text {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
}

.image-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid hsl(var(--border));
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.image-item img:hover {
    transform: scale(1.05);
}

.image-delete-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    border: none;
    background: hsl(var(--destructive));
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.image-item:hover .image-delete-btn {
    opacity: 1;
}

.image-upload-btn {
    display: flex;
    gap: 0.5rem;
}

/* Image Modal (확대 보기) */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.image-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius);
}

.image-modal-close {
    position: absolute;
    top: -2.5rem;
    right: 0;
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 50%;
    background: white;
    color: hsl(var(--foreground));
    font-size: 1.25rem;
    font-weight: 300;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
