/* Head / Info Card */
.head {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 24px;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
}

.card h2 {
    margin: 0 0 16px;
    font-size: 18px;
    color: var(--brand);
}

/* Forms Grid */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.field input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    background: #fbfdff;
    transition: all 0.2s;
    color: var(--text);
}

.field input:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px var(--brand-soft);
    background: #fff;
}

.field small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
}

.field .amount-hint {
    margin-top: 4px;
    color: #475569;
    font-weight: 500;
}

/* Radio Button Group (Style as Segmented Control) */
.radio-group {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.radio-group label {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    font-weight: normal;
    font-size: 14px;
    color: var(--text);
    margin: 0;
}

.radio-group label:hover {
    border-color: #93c5fd;
    background: #fff;
}

.radio-group input[type="radio"] {
    display: none;
}

.radio-group input[type="radio"]:checked+span {
    color: var(--brand);
    font-weight: 600;
}

.radio-group label:has(input[type="radio"]:checked) {
    border-color: var(--brand);
    background: var(--brand-soft);
    box-shadow: 0 0 0 1px var(--brand);
}

.radio-desc {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.radio-group input[type="radio"]:checked~.radio-desc {
    color: var(--brand);
    opacity: 0.8;
}

/* Buttons */
.btn {
    border: 1px solid transparent;
    background: var(--brand);
    color: #fff;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn:hover {
    background: var(--brand-hover);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
    transform: translateY(-1px);
}

.btn.full {
    width: 100%;
}

.btn.secondary {
    background: #f59e0b;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.btn.secondary:hover {
    background: #d97706;
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
}

.error {
    display: none;
    margin-top: 14px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-line;
}

/* Base Summary */
.summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.summary-item {
    border: 1px solid var(--line);
    background: #f8fafc;
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s;
}

.summary-item:hover {
    border-color: #bfdbfe;
    box-shadow: 0 4px 12px rgba(239, 246, 255, 1);
}

.summary-item strong {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 6px;
    font-weight: 500;
}

.summary-item span {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    display: block;
}

/* Feature Picker */
.feature-picker {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.feature-btn {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.feature-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
}

.feature-btn.active {
    border-color: #93c5fd;
    color: var(--brand);
    background: var(--brand-soft);
    box-shadow: 0 0 0 2px #dbeafe;
}

.feature-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.feature-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Results */
.result-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.result-box {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    background: #f8fafc;
}

.result-box h3 {
    margin: 0 0 10px;
    font-size: 15px;
    color: var(--brand);
}

.result-box ul {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
}

.ok {
    color: var(--ok);
    font-weight: 700;
}

.simple-result {
    display: none;
    margin-top: 16px;
    border: 1px solid #bbf7d0;
    border-radius: 12px;
    padding: 16px;
    background: #f0fdf4;
    font-size: 14px;
    line-height: 1.8;
    color: #166534;
}

/* Charts */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.chart-grid .wide {
    grid-column: 1 / -1;
}

.chart-box {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    padding: 16px;
    overflow: hidden;
}

.chart-box p {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--text);
    font-weight: 600;
}

.chart-wrap {
    position: relative;
    height: 280px;
    width: 100%;
    overflow: hidden;
}

.chart-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

details {
    margin-top: 16px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 16px;
    background: #f8fafc;
    transition: all 0.2s;
}

details[open] {
    background: #fff;
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
}

details summary {
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
    font-weight: 600;
    user-select: none;
}

/* Tables */
.table-wrap {
    margin-top: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.table-tip {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    display: none;
}

.period-cell {
    display: inline-flex;
    gap: 6px;
    align-items: baseline;
}

.period-month {
    font-weight: 700;
    color: var(--text);
}

.period-year {
    color: var(--muted);
    font-size: 12px;
}

table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    font-size: 13px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px;
    text-align: right;
    white-space: nowrap;
}

th:first-child,
td:first-child {
    text-align: left;
}

th:first-child,
td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
    border-right: 1px solid var(--line);
}

thead {
    background: #f8fafc;
    color: var(--text);
}

thead tr:first-child th {
    background: #f1f5f9;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid var(--line);
}

thead tr:last-child th {
    background: #f8fafc;
    font-size: 13px;
    font-weight: 600;
}

thead th:first-child {
    text-align: left;
    background: #f1f5f9;
}

@media (max-width: 768px) {

    .grid-2,
    .summary,
    .result-2,
    .chart-grid {
        grid-template-columns: 1fr;
    }

    .chart-grid .wide {
        grid-column: auto;
    }

    .chart-wrap {
        height: 240px;
    }

    .table-tip {
        display: block;
    }

    .period-cell {
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
    }
}
