:root {
    --primary-color: #0e2a47;
    /* Navy Blue */
    --secondary-color: #f7931e;
    /* Orange */
    --background-color: #f4f7f9;
    --text-color: #333;
    --border-color: #ddd;
    --white: #fff;
    --spacing: 1.5rem;
}

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

.container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--white);
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.hidden {
    display: none !important;
}

header {
    text-align: center;
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: 30px;
    padding-bottom: 20px;
}

header h1 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.date-display {
    text-align: right;
    font-size: 0.9rem;
    color: #666;
}

.intro-text {
    margin-bottom: 30px;
    font-size: 0.95rem;
}

.form-section {
    margin-bottom: 40px;
}

.form-section h2 {
    background: var(--primary-color);
    color: var(--white);
    padding: 10px 15px;
    font-size: 1.1rem;
    border-radius: 4px;
    margin-bottom: 20px;
}

.form-section h3 {
    font-size: 1rem;
    border-left: 4px solid var(--secondary-color);
    padding-left: 10px;
    margin-top: 20px;
    margin-bottom: 15px;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.9rem;
}

.required {
    color: #e74c3c;
    font-size: 0.8em;
    margin-left: 5px;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    box-sizing: border-box;
}

/* Plan Selector */
.plan-selector {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.plan-card {
    flex: 1;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 280px;
}

.plan-card:hover {
    border-color: var(--secondary-color);
    background-color: #fffaf0;
}

.plan-card input[type="radio"]:checked+.plan-details {
    color: var(--primary-color);
}

.plan-card:has(input:checked) {
    border-color: var(--secondary-color);
    background-color: #fff5e6;
    box-shadow: 0 0 10px rgba(247, 147, 30, 0.2);
}

.plan-details h3 {
    margin: 0 0 10px 0;
    border: none;
    padding: 0;
}

.badge {
    background: #e74c3c;
    color: white;
    font-size: 0.7em;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
}

.price-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}

.note {
    font-size: 0.8rem;
    color: #666;
    margin: 0;
}

/* Option List */
.option-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.option-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.option-content {
    display: flex;
    flex-direction: column;
}

.option-name {
    font-weight: 500;
}

.option-price {
    color: var(--primary-color);
    font-weight: bold;
}

.option-note {
    font-size: 0.8rem;
    color: #777;
    margin-top: 2px;
}

/* Summary Box */
.summary-section {
    background: #eef2f5;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 40px;
    border: 1px solid #dbe2e8;
}

.summary-section h2 {
    margin-top: 0;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.total-display {
    font-size: 1.2rem;
}

.total-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #ddd;
}

.total-row:last-child {
    border-bottom: none;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--secondary-color);
}

/* Terms */
.terms-content {
    height: 150px;
    overflow-y: scroll;
    padding: 15px;
    border: 1px solid var(--border-color);
    background: #fafafa;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 0.85rem;
}

.agreement-check {
    background: #fffbe6;
    padding: 15px;
    border: 1px solid #ffe58f;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
    margin-bottom: 20px;
}

/* --- Preview Step Styles --- */
#previewStep {
    background: #eee;
    padding: 20px;
    margin: -20px;
    /* pull out to edge of container padding */
    border-radius: 8px;
    margin-top: 0;
    text-align: center;
}

.paper-preview {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    padding: 40px;
    text-align: left;
    max-width: 100%;
    margin: 0 auto 30px auto;
    font-size: 0.95rem;
    border-radius: 2px;
}

.preview-header h1 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.preview-intro {
    margin-bottom: 30px;
}

.preview-section {
    margin-bottom: 30px;
}

.preview-section h3 {
    font-size: 1rem;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
    margin-bottom: 10px;
    color: #000;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.preview-table th,
.preview-table td {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.preview-table th {
    width: 30%;
    background: #f9f9f9;
    font-weight: bold;
    text-align: left;
}

.cost-table th {
    background: #eef2f5;
}

.price-cell {
    text-align: right;
    font-weight: bold;
}

.total-highlight th,
.total-highlight td {
    border-top: 2px solid var(--secondary-color);
    font-size: 1.1rem;
    background: #fff5e6;
    color: var(--primary-color);
}

.preview-terms-box {
    border: 1px solid #ccc;
    padding: 10px;
    background: #fafafa;
    font-size: 0.85rem;
}

/* Full terms styling in preview */
.preview-terms-box.full-terms {
    font-size: 0.8rem;
    background: #fff;
    border: 1px solid #eee;
}

.preview-terms-box ul,
.preview-terms-box ol {
    padding-left: 20px;
    margin-top: 5px;
}

.admin-stamp-box {
    margin-top: 40px;
    border: 1px solid #333;
    padding: 10px;
}

.admin-stamp-box p {
    margin: 0 0 10px 0;
    font-weight: bold;
    font-size: 0.9rem;
}

.stamp-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.stamp-box {
    height: 60px;
    border: 1px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #aaa;
}

/* Actions */
.preview-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.payment-section {
    text-align: center;
    margin-top: 40px;
}

button {
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: bold;
    border: none;
    transition: transform 0.2s, background 0.2s;
}

#toPreviewBtn,
#finalSubmitBtn {
    background: var(--secondary-color);
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#toPreviewBtn:hover,
#finalSubmitBtn:hover {
    transform: translateY(-2px);
    background: #e67e22;
}

#toPreviewBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.secondary-btn {
    background: #aaa;
    color: white;
}

.secondary-btn:hover {
    background: #888;
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    .paper-preview {
        padding: 20px;
    }

    .preview-table th,
    .preview-table td {
        display: block;
        width: 100%;
        text-align: left;
    }

    .preview-table th {
        background: transparent;
        color: #666;
        font-size: 0.85rem;
        padding-bottom: 0;
    }

    .preview-table td {
        padding-top: 0;
        border-bottom: 1px solid #eee;
    }

    .total-highlight td {
        text-align: right;
    }
}

/* --- PRINT STYLES --- */
@media print {
    body {
        margin: 0;
        padding: 0;
        background: white;
        color: black;
    }

    .container {
        box-shadow: none;
        max-width: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
        border-radius: 0;
    }

    /* Hide UI Elements */
    header,
    footer,
    #inputStep,
    .preview-actions,
    .hidden {
        display: none !important;
    }

    /* Reset Preview Styles for Print */
    #previewStep {
        background: white;
        padding: 0;
        margin: 0;
        display: block !important;
        /* Ensure it's shown even if validation logic hid it (unlikely but safe) */
    }

    .paper-preview {
        box-shadow: none;
        border: none;
        padding: 0;
        margin: 0;
        max-width: 100%;
    }

    /* Adjust sizing for print readability */
    .preview-header h1 {
        font-size: 18pt;
        color: black;
        /* Save ink */
    }

    .total-highlight th,
    .total-highlight td {
        background: none;
        border-top: 2px solid #000;
        color: black;
    }

    /* Ensure background colors (like stamps/headers) normally don't print, so we use borders/bold */
    .preview-table th {
        border-bottom: 1px solid #000;
        background: none !important;
    }

    .preview-table td {
        border-bottom: 1px solid #ccc;
    }

    .admin-stamp-box,
    .stamp-box,
    .preview-terms-box {
        border-color: #000;
    }

    .preview-section h3 {
        border-bottom-color: #000;
        color: #000;
    }

    /* Force background graphics if user browser supports it? 
       Usually better to design for B&W default. */
}