* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #fafaf9;
    --bg-secondary: #f5f5f4;
    --bg-card: #ffffff;
    --text-primary: #1c1917;
    --text-secondary: #78716c;
    --text-muted: #a8a29e;
    --accent: #dc2626;
    --accent-light: #fee2e2;
    --border: #e7e5e4;
    --border-light: #f5f5f4;
    --success: #059669;
    --success-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
}

body {
    font-family: 'Space Grotesk', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 4rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
    position: relative;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
    font-weight: 400;
}

@media (max-width: 600px) {
    header { padding-top: 2.75rem; }
}

/* Intro description */
.intro-text {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
    max-width: 960px;
}

.intro-text p { margin-bottom: 0.5rem; }
.intro-text p:last-child { margin-bottom: 0; }

/* In-content ad */
.ad-slot {
    max-width: 960px;
    margin: 3rem auto 0;
    text-align: center;
    overflow: hidden;
}

/* FAQ */
.faq-section {
    margin: 4rem auto 0;
    padding-top: 2.5rem;
    border-top: 1px solid var(--border);
    max-width: 960px;
}
.faq-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    text-align: center;
}
.faq-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    margin-bottom: 0.75rem;
    overflow: hidden;
}
.faq-item[open] {
    border-color: var(--accent);
}
.faq-q {
    list-style: none;
    cursor: pointer;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: color 0.15s;
}
.faq-q::-webkit-details-marker { display: none; }
.faq-q::after {
    content: "+";
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1;
    flex-shrink: 0;
    transition: transform 0.2s, color 0.15s;
}
.faq-item[open] .faq-q::after {
    transform: rotate(45deg);
    color: var(--accent);
}
.faq-q:hover { color: var(--accent); }
.faq-a {
    padding: 0 1.25rem 1.25rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.7;
}
.faq-a p { margin: 0 0 0.5rem; }
.faq-a p:last-child { margin-bottom: 0; }
.faq-a ul {
    padding-left: 1.25rem;
    margin: 0.25rem 0 0.75rem;
}
.faq-a li { margin-bottom: 0.25rem; }
.faq-a li:last-child { margin-bottom: 0; }
.faq-a .mono {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.875em;
}

/* Language Toggle */
.lang-toggle {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.lang-btn {
    padding: 0.375rem 0.75rem;
    border: none;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.04em;
    text-decoration: none;
    display: inline-block;
}

.lang-btn:not(:last-child) {
    border-right: 1px solid var(--border);
}

.lang-btn.active {
    background: var(--accent);
    color: white;
}

/* Grid Layout */
.grid {
    display: grid;
    gap: 2rem;
    margin-bottom: 3rem;
}

@media (min-width: 1024px) {
    .grid {
        grid-template-columns: 380px 1fr;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.indicator.success { background: var(--success); }
.indicator.warning { background: var(--warning); }

/* Form Elements */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

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

/* Month Selector */
.month-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.month-btn {
    padding: 0.5rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.month-btn:hover { border-color: var(--accent); color: var(--accent); }
.month-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* Currency Picker */
.currency-picker-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.currency-hot-btns {
    display: flex;
    gap: 0.375rem;
}

.currency-btn {
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'IBM Plex Mono', monospace;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.currency-btn:hover { border-color: var(--accent); color: var(--accent); }
.currency-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.currency-select {
    flex: 1;
    min-width: 110px;
    max-width: 160px;
    padding: 0.35rem 0.6rem;
    height: 2.05rem;
    font-size: 0.8125rem;
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #b91c1c; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

.btn-secondary { background: var(--text-primary); color: white; margin-top: 1rem; }
.btn-secondary:hover { background: #292524; }
.btn-secondary:disabled { opacity: 0.7; cursor: not-allowed; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1.5rem;
}

.stat-box {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Entries List */
.entries-list { min-height: 300px; }

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

.empty-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    stroke: var(--border);
}

.entry-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
    background: var(--bg-card);
    transition: all 0.2s;
}

.entry-item:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.04); }

.entry-info { display: flex; align-items: center; gap: 1rem; }

.entry-date {
    width: 48px;
    height: 48px;
    background: var(--accent-light);
    color: var(--accent);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

.entry-date span { font-size: 1.125rem; }

.entry-details h4 { font-weight: 600; color: var(--text-primary); margin-bottom: 0.25rem; }

.entry-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-family: 'IBM Plex Mono', monospace;
}

.entry-amount { text-align: right; }
.entry-amount .original { font-family: 'IBM Plex Mono', monospace; font-weight: 600; color: var(--text-primary); }
.entry-amount .converted { font-size: 0.875rem; color: var(--success); font-family: 'IBM Plex Mono', monospace; }

.delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    margin-left: 1rem;
    opacity: 0;
    transition: all 0.2s;
}

.entry-item:hover .delete-btn { opacity: 1; }
.delete-btn:hover { color: var(--accent); }

/* Results Section */
.results-section {
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 2px solid var(--border);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--accent);
}

.result-card.success::before { background: var(--success); }
.result-card.warning::before { background: var(--warning); }
.result-card.neutral::before { background: var(--text-secondary); }

.result-label { font-size: 0.875rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.result-value { font-family: 'IBM Plex Mono', monospace; font-size: 2rem; font-weight: 700; color: var(--text-primary); }
.result-card.tax .result-value { color: var(--accent); }

/* Table */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 2rem;
}

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

.table-title { font-size: 1.25rem; font-weight: 600; }

.export-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.export-btn:hover { background: var(--border); }

.export-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
thead { background: var(--bg-secondary); }
th { text-align: left; padding: 1rem 1.5rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.05em; }
td { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-light); }
tr:hover { background: var(--bg-primary); }

.mono { font-family: 'IBM Plex Mono', monospace; }
.text-right { text-align: right; }

.badge { display: inline-block; padding: 0.25rem 0.75rem; background: var(--bg-secondary); border-radius: 9999px; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); }

/* Monthly Breakdown */
.breakdown-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }

.breakdown-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; }

.breakdown-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.breakdown-month { font-weight: 600; color: var(--text-primary); }
.breakdown-count { font-size: 0.75rem; background: var(--accent-light); color: var(--accent); padding: 0.25rem 0.5rem; border-radius: 4px; font-weight: 600; }
.breakdown-amount { font-family: 'IBM Plex Mono', monospace; font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.25rem; }
.breakdown-tax { font-size: 0.875rem; color: var(--text-muted); }

/* Utility */
.hidden { display: none; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }
.mb-4 { margin-bottom: 1rem; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Footer */
footer {
    margin-top: 4rem;
    padding: 2rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer-links { display: flex; gap: 1.5rem; }

.footer-link {
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.875rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.15s;
}

.footer-link:hover { color: var(--text-secondary); }

/* Guide trigger banner */
.guide-trigger {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 0.875rem 1.25rem;
    margin-bottom: 1.75rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--accent);
    text-align: left;
    transition: background 0.15s, box-shadow 0.15s;
}
.guide-trigger:hover { background: #fef2f2; box-shadow: 0 2px 8px rgba(220,38,38,0.08); }
.faq-jump { margin-top: -1rem; }
.guide-trigger-icon { font-size: 1.1rem; flex-shrink: 0; }
.guide-trigger-arrow { margin-left: auto; opacity: 0.5; font-size: 0.9rem; }

/* Guide dialog */
.guide-dialog {
    border: none;
    border-radius: 12px;
    padding: 0;
    max-width: 860px;
    width: calc(100% - 2rem);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}
.guide-dialog::backdrop { background: rgba(0,0,0,0.45); }
.guide-dialog-inner { padding: 2rem; }
.guide-dialog h2 {
    font-size: 1.1875rem;
    font-weight: 700;
    margin: 0 0 1.25rem;
    color: var(--text-primary);
    padding-right: 1rem;
}
.guide-dialog ol { padding-left: 1.5rem; margin: 0; }
.guide-dialog li { margin-bottom: 0.75rem; line-height: 1.65; color: var(--text-primary); }
.guide-dialog ul { margin-top: 0.4rem; padding-left: 1.25rem; }
.guide-dialog ul li { margin-bottom: 0.3rem; }
.guide-dialog code {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1em 0.4em;
    font-size: 0.85em;
    font-family: monospace;
}
.guide-dialog a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.guide-step-tip {
    margin: 0.5rem 0 0;
    padding: 0.45rem 0.75rem;
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent);
    border-radius: 0 6px 6px 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.guide-step-img {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0.6rem 0 0.25rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.guide-dialog-footer {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.guide-dialog-footer a { font-size: 0.875rem; color: var(--accent); }
.guide-close-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 1.25rem;
    font-family: inherit;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.15s;
}
.guide-close-btn:hover { background: var(--border); }

/* Clear all button */
.clear-all-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-family: inherit;
    margin-left: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    transition: all 0.15s;
}
.clear-all-btn:hover { color: var(--accent); background: var(--accent-light); }

/* Entries header actions */
.entries-header {
    display: block;
    margin-bottom: 1.25rem;
}

.entries-header-top {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.entries-header-actions {
    margin-top: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: flex-start;
}

#importFileInput { display: none; }

.import-block {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary);
}

.import-template-select {
    width: auto;
    min-width: 185px;
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.import-template-select:focus {
    outline: none;
    box-shadow: none;
    border-color: var(--border);
}

#importBtn.export-btn {
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
}

#entriesCount {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: auto;
    margin-right: 0.5rem;
}

.replace-toggle {
    margin-bottom: 0;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: none;
    border-radius: 0;
    padding: 0.45rem 0.65rem;
    background: transparent;
    cursor: pointer;
    user-select: none;
}

.replace-toggle input[type="checkbox"] {
    width: 0.95rem;
    height: 0.95rem;
    margin: 0;
    accent-color: var(--accent);
}

.import-block:hover {
    background: var(--border);
}

.import-hint {
    flex-basis: 100%;
    margin: 0.4rem 0 0;
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.3rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1.45;
    color: var(--text-muted);
}

.import-hint svg {
    flex-shrink: 0;
    margin-top: 0.12rem;
    opacity: 0.7;
}

.import-hint-site {
    color: var(--text-secondary);
}

.entries-header-actions .export-btn,
.entries-header-top .export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    line-height: 1;
}

.clear-action-btn {
    color: var(--text-secondary);
}

.clear-action-btn:hover {
    color: var(--accent);
    background: var(--accent-light);
    border-color: #fecaca;
}

@media (max-width: 900px) {
    .entries-header-top {
        flex-wrap: wrap;
    }
    #entriesCount {
        margin-left: 0;
        margin-right: 0;
    }
    .entries-header-actions {
        width: 100%;
        margin-top: 0.6rem;
        justify-content: flex-start;
    }
    .import-block {
        max-width: 100%;
    }
    .import-template-select {
        min-width: 150px;
    }
}

/* Confirm dialog */
.confirm-dialog {
    border: none;
    border-radius: 12px;
    padding: 0;
    max-width: 360px;
    width: calc(100% - 2rem);
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}
.confirm-dialog::backdrop { background: rgba(0,0,0,0.45); }
.confirm-dialog-inner { padding: 1.75rem; }
.confirm-dialog h2 { font-size: 1.0625rem; font-weight: 700; margin: 0 0 0.75rem; color: var(--text-primary); }
.confirm-dialog p { color: var(--text-secondary); font-size: 0.9375rem; margin: 0 0 1.5rem; line-height: 1.6; }
.confirm-dialog-footer { display: flex; justify-content: flex-end; gap: 0.75rem; }
