.ddc-calculator,
.ddc-calculator * {
    box-sizing: border-box;
}

.ddc-calculator {
    --ddc-bg: #f4f6f8;
    --ddc-surface: #ffffff;
    --ddc-surface-soft: #f8fafc;
    --ddc-text: #111827;
    --ddc-muted: #667085;
    --ddc-border: #d8dee6;
    --ddc-border-strong: #1f2937;
    --ddc-primary: #344256;
    --ddc-primary-strong: #1f2a37;
    --ddc-focus: #64748b;
    --ddc-error: #b42318;
    --ddc-success: #167447;
    --ddc-shadow: 0 14px 40px rgba(31, 42, 55, 0.10);
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: clamp(14px, 3vw, 28px);
    color: var(--ddc-text);
    background: var(--ddc-bg);
    border-radius: 24px;
    overflow-wrap: anywhere;
}

.ddc-calculator[data-theme="dark"] {
    --ddc-bg: #111827;
    --ddc-surface: #1f2937;
    --ddc-surface-soft: #273244;
    --ddc-text: #f9fafb;
    --ddc-muted: #c6d0dc;
    --ddc-border: #405166;
    --ddc-border-strong: #e5e7eb;
    --ddc-primary: #e5e7eb;
    --ddc-primary-strong: #ffffff;
    --ddc-focus: #cbd5e1;
    --ddc-error: #fca5a5;
    --ddc-success: #5ee0a2;
    --ddc-shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
}

.ddc-shell {
    width: min(100%, 980px);
    max-width: 100%;
    margin: 0 auto;
}

.ddc-header,
.ddc-form {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    background: var(--ddc-surface);
    border: 1px solid var(--ddc-border);
    border-radius: 22px;
    box-shadow: var(--ddc-shadow);
}

.ddc-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: clamp(18px, 4vw, 30px);
    margin-bottom: 18px;
}

.ddc-header h2,
.ddc-result h3 {
    margin: 0;
    color: var(--ddc-text);
    font-size: clamp(1.45rem, 4.5vw, 2.1rem);
    line-height: 1.2;
}

.ddc-header p,
.ddc-explanation,
.ddc-disclaimer,
.ddc-field small {
    color: var(--ddc-muted);
}

.ddc-header p {
    margin: 10px 0 0;
    font-size: clamp(0.95rem, 2.4vw, 1.05rem);
    line-height: 1.6;
}

.ddc-kicker {
    margin: 0 0 8px;
    color: var(--ddc-muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ddc-theme-toggle,
.ddc-btn {
    min-height: 46px;
    border-radius: 999px;
    border: 1px solid var(--ddc-border);
    cursor: pointer;
    font-weight: 800;
    transition: transform 160ms ease, background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.ddc-theme-toggle {
    align-self: flex-start;
    padding: 10px 16px;
    background: var(--ddc-surface-soft);
    color: var(--ddc-text);
}

.ddc-theme-toggle:hover,
.ddc-btn:hover {
    transform: translateY(-1px);
}

.ddc-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    padding: clamp(18px, 4vw, 30px);
}

.ddc-field {
    min-width: 0;
}

.ddc-field label,
.ddc-check-field label,
.ddc-advanced summary {
    display: block;
    margin-bottom: 8px;
    color: var(--ddc-text);
    font-weight: 800;
}

.ddc-field input,
.ddc-field select,
.ddc-field textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 12px 14px;
    color: var(--ddc-text);
    background: var(--ddc-surface-soft);
    border: 1px solid var(--ddc-border);
    border-radius: 14px;
    font: inherit;
    outline: none;
}

.ddc-field textarea {
    resize: vertical;
    line-height: 1.45;
}

.ddc-field input:focus,
.ddc-field select:focus,
.ddc-field textarea:focus,
.ddc-theme-toggle:focus,
.ddc-btn:focus {
    border-color: var(--ddc-focus);
    box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.22);
}

.ddc-field small {
    display: block;
    margin-top: 7px;
    font-size: 0.85rem;
    line-height: 1.45;
}

.ddc-check-field {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    background: var(--ddc-surface-soft);
    border: 1px solid var(--ddc-border);
    border-radius: 14px;
}

.ddc-check-field input {
    flex: 0 0 auto;
    width: 18px;
    min-height: 18px;
    margin-top: 3px;
}

.ddc-check-field label {
    margin: 0;
}

.ddc-advanced {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 14px;
    background: var(--ddc-surface-soft);
    border: 1px solid var(--ddc-border);
    border-radius: 16px;
}

.ddc-advanced summary {
    margin: 0;
    cursor: pointer;
}

.ddc-advanced-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 16px;
}

.ddc-errors {
    display: none;
    padding: 12px 14px;
    color: var(--ddc-error);
    background: rgba(180, 35, 24, 0.08);
    border: 1px solid rgba(180, 35, 24, 0.25);
    border-radius: 14px;
    font-weight: 800;
    line-height: 1.5;
}

.ddc-errors.is-visible {
    display: block;
}

.ddc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.ddc-btn {
    flex: 1 1 150px;
    padding: 12px 16px;
    font-size: 0.94rem;
}

.ddc-btn-primary {
    color: var(--ddc-surface);
    background: var(--ddc-primary);
    border-color: var(--ddc-primary);
}

.ddc-btn-primary:hover {
    background: var(--ddc-primary-strong);
    border-color: var(--ddc-primary-strong);
}

.ddc-btn-secondary {
    color: var(--ddc-text);
    background: var(--ddc-surface-soft);
}

/* Flat, full-width report output: no enclosing result box and no sidebar. */
.ddc-result {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: 24px;
    padding: clamp(14px, 3vw, 24px) 0 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.ddc-result-header {
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--ddc-border);
}

.ddc-flat-report {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.ddc-report-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-top: 26px;
    padding-top: 16px;
    border-top: 4px solid var(--ddc-border-strong);
}

.ddc-report-section-first {
    margin-top: 0;
}

.ddc-report-section h4 {
    margin: 0 0 14px;
    color: var(--ddc-text);
    font-size: clamp(1.25rem, 4.5vw, 1.65rem);
    line-height: 1.2;
    font-weight: 900;
}

.ddc-output-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(92px, max-content);
    align-items: start;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 14px 0;
    border-bottom: 1px solid var(--ddc-border);
}

.ddc-output-row span {
    min-width: 0;
    color: var(--ddc-muted);
    font-size: clamp(1rem, 3.8vw, 1.15rem);
    font-weight: 800;
    line-height: 1.3;
}

.ddc-output-row strong {
    min-width: 0;
    max-width: min(58vw, 360px);
    color: var(--ddc-text);
    font-size: clamp(1rem, 3.8vw, 1.16rem);
    font-weight: 900;
    line-height: 1.3;
    text-align: right;
    overflow-wrap: anywhere;
}

.ddc-main-row strong {
    color: var(--ddc-success);
    font-size: clamp(1.28rem, 5.5vw, 1.9rem);
    line-height: 1.15;
}

.ddc-explanation {
    margin: 22px 0 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    line-height: 1.6;
}

.ddc-disclaimer {
    margin: 18px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--ddc-border);
    font-size: 0.9rem;
    line-height: 1.6;
}

@media (max-width: 380px) {
    .ddc-output-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
    }

    .ddc-output-row strong {
        max-width: 100%;
        text-align: left;
    }
}

@media (min-width: 720px) {
    .ddc-header {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }

    .ddc-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ddc-advanced,
    .ddc-errors,
    .ddc-actions {
        grid-column: 1 / -1;
    }

    .ddc-advanced-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ddc-full-field {
        grid-column: 1 / -1;
    }
}

@media print {
    body * {
        visibility: hidden !important;
    }

    .ddc-calculator,
    .ddc-calculator * {
        visibility: visible !important;
    }

    .ddc-calculator {
        padding: 0;
        background: #ffffff !important;
        color: #000000 !important;
    }

    .ddc-header,
    .ddc-form,
    .ddc-actions,
    .ddc-theme-toggle {
        display: none !important;
    }

    .ddc-result {
        margin: 0;
    }
}
