* { box-sizing: border-box; }
body {
    font-family: "Inter", "Noto Sans TC", -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
    background: #f5f6fa;
    margin: 0;
    color: #2d3436;
    min-height: 100vh;
}

/* Top nav */
.topnav {
    background: #fff;
    border-bottom: 1px solid #e6e8eb;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
}
.nav-brand { font-weight: 700; font-size: 16px; margin-right: 24px; }
.nav-link {
    color: #636e72;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
}
.nav-link:hover { background: #f1f2f6; color: #2d3436; }
.nav-link.active { background: #e3f2fd; color: #0984e3; }

.container { max-width: 1000px; margin: 0 auto; padding: 32px 16px; }
h1 { margin: 0 0 8px 0; font-size: 24px; }
.subtitle { color: #636e72; margin-bottom: 24px; font-size: 14px; }

.card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.upload-form {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
input[type="file"] {
    flex: 1;
    min-width: 250px;
    padding: 10px;
    border: 1px dashed #b2bec3;
    border-radius: 8px;
    background: #f8f9fa;
}
input[type="text"], input[type="number"] {
    padding: 10px;
    border: 1px solid #dfe4ea;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
}
button, .btn {
    background: #0984e3;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}
button:hover, .btn:hover { background: #0768b3; }
.btn.secondary { background: #f1f2f6; color: #2d3436; border: 1px solid #dfe4ea; }
.btn.secondary:hover { background: #dfe4ea; }
.btn.success { background: #27ae60; }
.btn.success:hover { background: #1e8449; }

.filename { color: #636e72; font-size: 13px; margin-bottom: 12px; }
.row-count { color: #636e72; font-size: 13px; margin-bottom: 12px; }

.totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}
.total-box { padding: 20px; border-radius: 10px; text-align: center; }
.total-box.pretax { background: #e3f2fd; }
.total-box.tax { background: #fff3e0; }
.total-box.aftertax { background: #e8f5e9; }
.total-label { font-size: 13px; color: #636e72; margin-bottom: 8px; }
.total-value {
    font-size: 26px;
    font-weight: 700;
    color: #2d3436;
    font-variant-numeric: tabular-nums;
}

h2 { font-size: 16px; margin: 0 0 12px 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
    padding: 10px 12px;
    text-align: right;
    border-bottom: 1px solid #f1f2f6;
    font-variant-numeric: tabular-nums;
}
th { background: #f8f9fa; color: #636e72; font-weight: 600; }
th:first-child, td:first-child { text-align: left; }
td.text-left { text-align: left; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}
.badge-b { background: #fff3e0; color: #e67e22; }
.badge-c { background: #e3f2fd; color: #2980b9; }
.badge-other { background: #eee; color: #636e72; }

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.row-count-inline { font-size: 13px; color: #636e72; font-weight: 400; }
.toggle-btn {
    background: #f1f2f6;
    color: #2d3436;
    border: 1px solid #dfe4ea;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
}
.preview-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 13px;
    color: #636e72;
}
.preview-controls select {
    padding: 4px 8px;
    border: 1px solid #dfe4ea;
    border-radius: 6px;
    margin: 0 6px;
    font-size: 13px;
}
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.page-btn {
    background: #fff;
    color: #2d3436;
    border: 1px solid #dfe4ea;
    padding: 6px 12px;
    font-size: 13px;
    min-width: 36px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
}
.page-btn:hover:not(:disabled):not(.active) { background: #f1f2f6; }
.page-btn.active { background: #0984e3; color: #fff; border-color: #0984e3; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-ellipsis { padding: 6px 4px; color: #b2bec3; }

.status-banner {
    background: #e3f2fd;
    border-left: 4px solid #0984e3;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #2d3436;
}
.status-banner.empty {
    background: #fff5f5;
    border-left-color: #e74c3c;
}
.status-banner .meta { color: #636e72; font-size: 12px; margin-top: 4px; }

.source-hint {
    background: #f8fbff;
    border-left: 4px solid #0984e3;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
    line-height: 1.7;
}
.source-hint code {
    background: #e3f2fd;
    padding: 2px 6px;
    border-radius: 4px;
}
.source-hint strong { color: #0984e3; }

/* ============ Home glassmorphism ============ */
body.home-page {
    background:
        radial-gradient(1200px 800px at 15% 10%, rgba(120, 180, 255, 0.55), transparent 60%),
        radial-gradient(1000px 700px at 90% 20%, rgba(255, 155, 220, 0.5), transparent 60%),
        radial-gradient(1000px 700px at 50% 100%, rgba(150, 130, 255, 0.55), transparent 60%),
        linear-gradient(135deg, #4c6ef5 0%, #7048e8 50%, #d63384 100%);
    background-attachment: fixed;
    overflow-x: hidden;
    position: relative;
}
body.home-page::before,
body.home-page::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    pointer-events: none;
}
body.home-page::before {
    top: -180px; left: -180px;
    width: 520px; height: 520px;
    background: radial-gradient(circle, rgba(140, 210, 255, 0.55) 0%, transparent 70%);
    animation: floatA 22s ease-in-out infinite;
}
body.home-page::after {
    bottom: -180px; right: -180px;
    width: 520px; height: 520px;
    background: radial-gradient(circle, rgba(255, 190, 240, 0.55) 0%, transparent 70%);
    animation: floatB 18s ease-in-out infinite;
}
@keyframes floatA {
    0%,100% { transform: translate(0,0) scale(1); }
    50% { transform: translate(90px,70px) scale(1.12); }
}
@keyframes floatB {
    0%,100% { transform: translate(0,0) scale(1); }
    50% { transform: translate(-90px,-70px) scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
    body.home-page::before, body.home-page::after { animation: none; }
}
body.home-page .topnav {
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border-bottom: 1px solid rgba(255,255,255,0.35);
}
body.home-page .container { position: relative; z-index: 1; }
body.home-page h1 {
    color: #fff;
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.5px;
    text-shadow: 0 2px 30px rgba(0,0,0,0.18);
    margin-bottom: 10px;
}
body.home-page .subtitle {
    color: rgba(255,255,255,0.94);
    text-shadow: 0 1px 12px rgba(0,0,0,0.12);
    margin-bottom: 28px;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.dash-card {
    background: rgba(255,255,255,0.34);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: 0 8px 28px rgba(31,38,135,0.15), inset 0 1px 0 rgba(255,255,255,0.55);
}
.dash-label { font-size: 12px; color: #364054; font-weight: 600; margin-bottom: 8px; }
.dash-value {
    font-size: 26px; font-weight: 800; color: #171a2c;
    font-variant-numeric: tabular-nums;
}
.dash-value.dim { color: #7b8494; font-weight: 700; font-size: 20px; }
.dash-value.diff-pos { color: #1a5a2a; }
.dash-value.diff-neg { color: #6b3f00; }
.dash-hint { font-size: 11px; color: #5d6a7b; margin-top: 6px; }
.dash-verdict {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
}
.dash-verdict.short-sales {
    background: rgba(255,180,60,0.28); color: #6b3f00;
    border: 1px solid rgba(255,180,60,0.4);
}
.dash-verdict.balanced {
    background: rgba(120,220,140,0.3); color: #1a5a2a;
    border: 1px solid rgba(120,220,140,0.4);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}
.feature-card {
    background: rgba(255,255,255,0.32);
    backdrop-filter: blur(22px) saturate(180%);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 10px 32px rgba(31,38,135,0.18), inset 0 1px 0 rgba(255,255,255,0.55);
    text-decoration: none;
    color: inherit;
    display: block;
    transition: all 0.28s cubic-bezier(0.16,1,0.3,1);
}
.feature-card:hover {
    background: rgba(255,255,255,0.44);
    transform: translateY(-4px);
    box-shadow: 0 16px 44px rgba(31,38,135,0.26);
}
.feature-icon { font-size: 38px; margin-bottom: 14px; }
.feature-card h3 { color: #171a2c; font-size: 17px; font-weight: 700; margin: 0 0 8px 0; }
.feature-card p { color: #2f3a4a; font-size: 13px; line-height: 1.7; margin: 0; }
.feature-status {
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 12px;
    padding: 12px 14px;
    margin-top: 14px;
    font-size: 12px;
    color: #263241;
    line-height: 1.75;
    font-variant-numeric: tabular-nums;
}
.feature-status strong { color: #0d3d61; font-weight: 700; }
.feature-status.missing {
    background: rgba(255,205,205,0.35);
    border-color: rgba(255,155,155,0.5);
    color: #8a1a1a;
}

/* Verdict box for analysis */
.verdict-box {
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    margin-top: 20px;
}
.verdict-box.short-sales { background: #fff8e6; border: 1px solid #f5deb3; }
.verdict-box.balanced { background: #e8f5e9; border: 1px solid #b8dfbc; }
.verdict-tag {
    display: inline-block;
    font-size: 20px;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.verdict-tag.short-sales { background: #f39c12; color: #fff; }
.verdict-tag.balanced { background: #27ae60; color: #fff; }
.verdict-amount { font-size: 32px; font-weight: 800; color: #2d3436; }
.verdict-label { font-size: 14px; color: #636e72; margin-bottom: 8px; }

.calc-formula {
    font-family: "SF Mono", Menlo, monospace;
    font-size: 13px;
    color: #636e72;
    background: #f8f9fa;
    padding: 10px 14px;
    border-radius: 8px;
    margin: 12px 0 20px 0;
    text-align: center;
}
