:root {
    --primary-color: #475569;
    /* Slate 600 */
    --accent-color: #64748b;
    /* Slate 500 */
    --bg-color: #f1f5f9;
    /* Slate 100 */
    --card-bg: #ffffff;
    --text-main: #334155;
    /* Slate 700 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --border-color: #e2e8f0;
    /* Slate 200 */
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --highlight-bg: #f8fafc;
}

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

body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--accent-color);
    font-size: 1rem;
}

/* Grid Layout */
.main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 992px) {
    .main-grid {
        grid-template-columns: 1fr 1fr;
        /* Side by side on desktop */
        align-items: start;
    }
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

h2,
h3 {
    font-size: 1.25rem;
    color: var(--primary-color);
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--highlight-bg);
}

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

.form-row {
    display: flex;
    gap: 1rem;
}

.form-group.half {
    flex: 1;
}

label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

input[type="number"] {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1.1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--info-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.unit {
    position: absolute;
    right: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.btn-link {
    background: none;
    border: none;
    color: var(--info-color);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    margin-top: 5px;
    padding: 0;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 5px;
}

hr {
    border: none;
    border-top: 1px dashed var(--border-color);
    margin: 1.5rem 0;
}

/* Radio Group */
.radio-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    background: var(--bg-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    font-size: 0.95rem;
}

.radio-label:hover {
    background: #e2e8f0;
}

.radio-label:has(input:checked) {
    background: #e0f2fe;
    /* Light blue */
    border-color: #3b82f6;
    color: #0369a1;
    font-weight: 500;
}

/* Output Section */
.result-card.highlight {
    background: linear-gradient(135deg, #475569 0%, #334155 100%);
    color: white;
    text-align: center;
    border: none;
}

.result-card.highlight h3 {
    color: #e2e8f0;
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.big-number {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 1rem 0;
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
}

.sub-text {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Table */
.result-table {
    width: 100%;
    border-collapse: collapse;
}

.result-table th {
    text-align: left;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.result-table td {
    padding: 12px 0;
    border-bottom: 1px solid var(--highlight-bg);
    font-size: 1rem;
}

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

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

.note {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-left: 10px;
}

/* Colors for table values */
.text-red {
    color: var(--danger-color);
}

.text-green {
    color: var(--success-color);
    font-weight: 600;
}

.text-blue {
    color: var(--info-color);
}

.text-gray {
    color: var(--text-muted);
}

.highlight-row {
    background-color: rgba(34, 197, 94, 0.05);
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Summary Grid for 4 Blocks */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
    /* Replaces margin-top */
}

.summary-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.25rem 1rem;
    text-align: center;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    /* Slightly lifted */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.summary-card h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    font-weight: 600;
}

.summary-value {
    font-size: 1.75rem;
    /* Larger font */
    font-weight: 700;
    margin-bottom: 0.25rem;
    font-feature-settings: "tnum";
}

.summary-pct {
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.8;
    margin-bottom: 0.25rem;
}

.summary-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Colors for specific blocks */
.summary-card.company {
    border-top: 5px solid var(--info-color);
}

.summary-card.company .summary-value {
    color: var(--info-color);
}

.summary-card.mine {
    border-top: 5px solid var(--success-color);
    background-color: #f0fdf4;
    /* Light green tint bg */
    border-color: #bbf7d0;
}

.summary-card.mine .summary-value {
    color: var(--success-color);
}

.summary-card.mine h4 {
    color: #166534;
}

.summary-card.gov {
    border-top: 5px solid var(--danger-color);
}

.summary-card.gov .summary-value {
    color: var(--danger-color);
}

.summary-card.others {
    border-top: 5px solid var(--text-muted);
}

.summary-card.others .summary-value {
    color: var(--text-muted);
}

/* Utilities */
.mb-4 {
    margin-bottom: 1.5rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

/* Mobile optimization */
@media (max-width: 480px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }
}

/* Formula List */
.formula-list {
    list-style: none;
    padding: 0;
}

.formula-list>li {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px dashed var(--border-color);
}

.formula-list>li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.formula-list code {
    background: var(--highlight-bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--primary-color);
    font-family: monospace;
    font-size: 0.9em;
    display: inline-block;
    margin: 2px 0;
}

.formula-list ul {
    list-style: disc;
    margin-left: 1.5rem;
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.formula-trace {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #f8fafc;
    border-left: 3px solid var(--info-color);
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: pre-wrap;
    line-height: 1.5;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 3rem;
    margin-bottom: 2rem;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}