:root {
    --bg-color: #fcfcfd;
    --card-bg: #ffffff;
    --text-main: #212529;
    --text-sub: #495057;
    --text-mute: #adb5bd;
    --accent: #845ef7;
    --accent-light: #f3f0ff;
    --border: #f1f3f5;
    --shadow: rgba(0, 0, 0, 0.03);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Pretendard', -apple-system, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 420px;
    padding: 40px 20px;
}

header {
    margin-bottom: 32px;
}

header h1 {
    font-size: 20px;
    font-weight: 700;
}

/* Dashboard Card */
.dashboard {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 28px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 20px var(--shadow);
    margin-bottom: 40px;
}

.label {
    font-size: 13px;
    color: var(--text-sub);
    font-weight: 600;
    margin-bottom: 6px;
}

.total-value {
    font-size: 34px;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 24px;
}

.total-value .unit {
    font-size: 18px;
    font-weight: 600;
    margin-left: 2px;
}

.weekly-container {
    background: var(--accent-light);
    padding: 14px 20px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.w-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent);
}

.w-value {
    font-size: 16px;
    font-weight: 800;
    color: var(--accent);
}

.split {
    display: flex;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.split-item .s-label {
    font-size: 12px;
    color: var(--text-mute);
    margin-bottom: 4px;
}

.split-item .s-value {
    font-size: 15px;
    font-weight: 700;
}

/* History Grouping Style */
.history-section h2 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
}

.date-group {
    margin-bottom: 12px;
}

.date-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 10;
}

.date-summary:active {
    transform: scale(0.97);
    background: var(--bg-color);
}

.date-info-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.date-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-mute);
}

.daily-total {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-main);
}

.chevron {
    width: 20px;
    height: 20px;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-mute);
}

.date-group.active .chevron {
    transform: rotate(180deg);
}

.date-details {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.5s cubic-bezier(0.33, 1, 0.68, 1), 
                opacity 0.4s ease,
                padding 0.5s cubic-bezier(0.33, 1, 0.68, 1);
    padding: 0 4px;
    opacity: 0;
}

.date-details.active {
    grid-template-rows: 1fr;
    padding: 12px 4px 20px 4px;
    opacity: 1;
}

.date-details-inner {
    overflow: hidden;
}

/* History Item with Swipe-to-Delete */
.history-item-container {
    position: relative;
    margin-bottom: 10px;
    height: 76px;
    border-radius: 18px;
    background: #ff4d4f;
    overflow: hidden;
    transform: translateY(10px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.33, 1, 0.68, 1), 
                opacity 0.3s ease;
}

.history-item-content {
    position: absolute;
    inset: 0;
    background: white;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 2;
    border: 1px solid var(--border);
    border-radius: 18px;
    transition: transform 0.3s cubic-bezier(0.33, 1, 0.68, 1);
    box-sizing: border-box;
}

.delete-btn {
    position: absolute;
    right: 0;
    top: 0;
    width: 80px;
    height: 100%;
    background: #ff4d4f;
    color: white;
    border: none;
    font-weight: 700;
    font-size: 14px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.date-details:not(.active) .history-item-container {
    transition-delay: 0s !important;
    transform: translateY(-5px);
    opacity: 0;
}

.date-details.active .history-item-container {
    transform: translateY(0);
    opacity: 1;
}

.item-info .name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 2px;
}

.item-info .type {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-light);
    padding: 2px 6px;
    border-radius: 5px;
}

.item-amount {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

/* Button & Modal */
.add-btn {
    position: fixed;
    bottom: 32px;
    right: 24px;
    width: 56px;
    height: 56px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 18px;
    font-size: 24px;
    box-shadow: 0 8px 24px rgba(132, 94, 247, 0.3);
    cursor: pointer;
    transition: transform 0.2s;
}

.add-btn:active { transform: scale(0.9); }

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    display: none;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active { display: flex; }

.modal-content {
    width: 100%;
    max-width: 420px;
    background: white;
    border-radius: 32px 32px 0 0;
    padding: 32px 24px;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.type-switch {
    display: flex;
    background: var(--bg-color);
    padding: 4px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.switch-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-mute);
    cursor: pointer;
    border-radius: 8px;
}

.switch-btn.active {
    background: white;
    color: var(--accent);
    box-shadow: 0 2px 8px var(--shadow);
}

.input-field {
    width: 100%;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 16px;
    margin-bottom: 12px;
    outline: none;
}

.input-field:focus { border-color: var(--accent); }

.readonly-field {
    background: var(--bg-color);
    color: var(--accent);
    font-weight: 800;
    cursor: default;
    border: 1px dashed var(--border);
}

.quick-select {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.quick-select.hidden, .hidden {
    display: none;
}

.chip {
    padding: 10px 16px;
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chip:active {
    transform: scale(0.95);
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.sub-type-switch {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.sub-switch-btn {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-mute);
    cursor: pointer;
    transition: all 0.2s;
}

.sub-switch-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.save-btn {
    width: 100%;
    padding: 18px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    margin-top: 8px;
    cursor: pointer;
}

/* Chrome, Safari, Edge, Opera */
.no-spinner::-webkit-outer-spin-button,
.no-spinner::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
.no-spinner {
  -moz-appearance: textfield;
}
