/* static/css/cost_calc.css */

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    background: #f6f8fb;
    color: #111827;
    font-family: 'M PLUS 1p', sans-serif;
}

.page {
    width: 90%;
    max-width: 84rem;
    margin: 0 auto;
    padding: 0.75rem 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cost-header-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 32vw);
    gap: 1rem;
    align-items: start;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.cost-header-left,
.cost-header-right {
    min-width: 0;
}

.cost-header-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-header h1 {
    margin: 0 0 0.5rem;
    font-size: 2.5rem;
    line-height: 1.3;
    color: #111827;
}

.page-header p {
    margin: 0 0 0.5rem;
    color: #1f2a44;
    line-height: 1.6;
    font-size: 1rem;
}

.page-note {
    font-size: 0.85rem;
    color: #666666;
}

.cost-notice-card {
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 0.125rem 0.5rem rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.cost-notice-accordion {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.cost-notice-accordion::after {
    content: "▲";
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #4b5563;
}

.cost-notice-accordion.is-collapsed::after {
    content: "▼";
}

.cost-notice-title {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: #374151;
    border-bottom: 0.0625rem solid #edf2f7;
    background: #fbfdff;
}

.cost-notice-body {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    line-height: 1.8;
    color: #4b5563;
}

.cost-notice-body p {
    margin: 0;
}

.cost-notice-accordion.is-collapsed .cost-notice-body {
    display: none;
}

.cost-notice-accordion.is-collapsed .cost-notice-title {
    border-bottom: none;
}

.cost-ad-slot {
    width: 100%;
    min-height: 6.25rem;
    border: 0.0625rem dashed #cfc7a4;
    border-radius: 0.75rem;
    background: #ffffff;
    padding: 0.75rem;
    box-sizing: border-box;
}

.cost-adsense {
    display: block;
    width: 100%;
    min-height: 5.5rem;
}

.card {
    background: #ffffff;
    border-radius: 1.25rem;
    padding: 1rem;
    box-shadow: 0 0.125rem 0.5rem rgba(15, 23, 42, 0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-header h2 {
    margin: 0 0 0.35rem;
    font-size: 1.1rem;
    color: #222222;
}

.card-header p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #4b5563;
}

.cost-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.split-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr);
    gap: 1rem;
    align-items: start;
}

.split-input {
    min-width: 0;
}

.split-help {
    min-width: 0;
    background: #f8fbff;
    border: 0.0625rem solid #dbe4f0;
    border-radius: 1rem;
    padding: 1rem;
    box-sizing: border-box;
}

.split-help h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: #1f2a44;
}

.split-help p {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    line-height: 1.7;
    color: #4b5563;
}

.split-help p:last-child {
    margin-bottom: 0;
}

.help-note {
    font-weight: 700;
    color: #1d4ed8;
    background: #eef4ff;
    border-radius: 0.625rem;
    padding: 0.625rem;
}

.sales-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.875rem;
}

.input-list {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

#variable-costs > div,
#fixed-costs > div {
    background: #fbfdff;
    border: 0.0625rem solid #dbe4f0;
    border-radius: 1rem;
    padding: 1rem;
    box-sizing: border-box;
    display: grid;
    gap: 0.875rem;
}

#variable-costs > div {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

#fixed-costs > div {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #374151;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    border: 0.0625rem solid #d6deeb;
    border-radius: 0.5rem;
    padding: 0.75rem 0.9375rem;
    background: #ffffff;
    color: #1f2a44;
    font-size: 0.9375rem;
    line-height: 1.4;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        background-color 0.15s ease;
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: #9eb8ef;
    box-shadow: 0 0 0 0.1875rem rgba(47, 106, 230, 0.18);
}

.primary-btn,
.secondary-btn,
.delete-btn,
.btn,
button[type="button"],
button[type="submit"] {
    border-radius: 0.5rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        box-shadow 0.15s ease,
        transform 0.15s ease;
}

.primary-btn,
button[type="submit"]:not(.secondary-btn):not(.btn) {
    width: 100%;
    border: 0.0625rem solid #2f6ae6;
    background: #2f6ae6;
    color: #ffffff;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    box-shadow: 0 0.25rem 0.75rem rgba(47, 106, 230, 0.18);
}

.primary-btn:hover,
button[type="submit"]:not(.secondary-btn):not(.btn):hover {
    background: #2559c7;
    border-color: #2559c7;
    transform: translateY(-0.0625rem);
}

.secondary-btn,
.btn,
button[type="button"] {
    flex: 0 0 auto;
    border: 0.0625rem solid #2f6ae6;
    background: #ffffff;
    color: #2f6ae6;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
}

.secondary-btn:hover,
.btn:hover,
button[type="button"]:hover {
    background: #eef4ff;
    transform: translateY(-0.0625rem);
}

.delete-btn {
    width: 100%;
    margin-top: 0.875rem;
    border: 0.0625rem solid #f1c0c0;
    background: #fffafa;
    color: #b42318;
    padding: 0.625rem 0.875rem;
    font-size: 0.8125rem;
}

.delete-btn:hover {
    background: #fff1f1;
    border-color: #e19a9a;
    transform: translateY(-0.0625rem);
}

.form-actions {
    margin-top: 0.25rem;
}

.download-form {
    margin-top: 1rem;
}

.result-card h3 {
    margin: 1.25rem 0 0.75rem;
    font-size: 1rem;
    color: #222222;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.875rem;
    margin-bottom: 1rem;
}

.summary-item {
    background: #f8fbff;
    border: 0.0625rem solid #dbe4f0;
    border-radius: 0.875rem;
    padding: 0.875rem;
}

.summary-item span {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    color: #64748b;
}

.summary-item strong {
    font-size: 1.15rem;
    color: #111827;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    background: #ffffff;
}

.result-table th,
.result-table td {
    border: 0.0625rem solid #d1d5db;
    padding: 0.75rem;
    vertical-align: top;
    box-sizing: border-box;
    font-size: 0.9rem;
}

.result-table th {
    background: #f2f2f2;
    text-align: center;
    font-weight: 700;
    color: #222222;
}

.result-table td {
    color: #1f2937;
}

.total-row {
    font-weight: 700;
    background: #f8fafc;
}

.guide-link {
    margin: 0.5rem 0 0;
    text-align: center;
    color: #4b5563;
}

.guide-link a {
    color: #2f6ae6;
    font-weight: 700;
}

@media (max-width: 48rem) {
    .page {
        width: auto;
        padding: 0.625rem 0.75rem 1rem;
        gap: 0.875rem;
    }

    .cost-header-layout {
        grid-template-columns: 1fr;
        margin-top: 1rem;
    }

    .cost-header-right {
        order: -1;
    }

    .page-header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 0.75rem;
        border-radius: 1rem;
    }

    .card-header {
        flex-direction: column;
        align-items: stretch;
    }

    .secondary-btn,
    .btn,
    button[type="button"] {
        width: 100%;
    }

    .split-layout {
        grid-template-columns: minmax(0, 1.35fr) minmax(8rem, 1fr);
        gap: 0.75rem;
    }

    .split-help {
        padding: 0.75rem;
        border-radius: 0.875rem;
    }

    .split-help h3 {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
    }

    .split-help p {
        font-size: 0.75rem;
        line-height: 1.5;
        margin-bottom: 0.5rem;
    }

    .help-note {
        padding: 0.5rem;
    }

    .sales-grid,
    #variable-costs > div,
    #fixed-costs > div {
        grid-template-columns: 1fr;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .result-table {
        min-width: 36rem;
    }
}

@media (max-width: 36rem) {
    .page-header h1 {
        font-size: 1.75rem;
    }

    .split-layout {
        grid-template-columns: minmax(0, 1.25fr) minmax(7rem, 1fr);
        gap: 0.5rem;
    }

    .split-help {
        padding: 0.625rem;
    }

    .split-help h3 {
        font-size: 0.8rem;
    }

    .split-help p {
        font-size: 0.7rem;
        line-height: 1.45;
    }

    input[type="text"],
    input[type="number"] {
        font-size: 0.875rem;
        padding: 0.625rem 0.75rem;
    }

    .primary-btn,
    .secondary-btn,
    .delete-btn,
    .btn,
    button[type="button"],
    button[type="submit"] {
        font-size: 0.875rem;
    }

    .result-table th,
    .result-table td {
        padding: 0.5rem;
        font-size: 0.8125rem;
    }
}

/* 印刷時は、計算結果部分だけをA4に収まるよう表示する */
@media print {
    nav,
    footer,
    .cost-header-right,
    .cost-notice-card,
    .cost-form,
    .guide-link {
        display: none !important;
    }

    .page {
        width: auto;
        padding: 0;
        gap: 0.5rem;
    }

    .cost-header-layout {
        grid-template-columns: 1fr;
        margin-top: 0;
    }

    .result-card {
        box-shadow: none;
        border: 0.0625rem solid #d1d5db;
    }

    .table-toggle-btn,
    .download-form {
        display: none !important;
    }

    .table-wrap.is-collapsed {
        display: block !important;
    }

    .result-table tr {
        break-inside: avoid;
    }
}