/* ============================================
   Melu Break-Even Simulator — v6
   Graph-Top / Data-Bottom Layout
   Dark screen / White print / A4 landscape 1p
   ============================================ */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: 'Noto Sans JP', 'Inter', system-ui, sans-serif;
    background: #0b0f1a;
    color: #e8ecf4;
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ---- Particles ---- */
.bg-particles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.particle {
    position: absolute; border-radius: 50%; opacity: 0.25;
    animation: floatParticle linear infinite alternate;
}
@keyframes floatParticle {
    0%   { transform: translateY(100vh) scale(1); opacity: 0; }
    10%  { opacity: 0.2; }
    90%  { opacity: 0.2; }
    100% { transform: translateY(-10vh) scale(1.5); opacity: 0; }
}

/* ---- Internal Toolbar ---- */
.internal-toolbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: rgba(30, 20, 60, 0.95);
    border-bottom: 2px solid #f59e0b;
    backdrop-filter: blur(12px);
    padding: 8px 20px;
}
.toolbar-inner {
    max-width: 1200px; margin: 0 auto;
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.toolbar-label { font-size: 13px; color: #f59e0b; font-weight: 600; white-space: nowrap; }
.plan-select {
    flex: 1; max-width: 340px; min-width: 200px;
    background: #1a1e32; color: #e8ecf4;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px; padding: 8px 12px;
    font-size: 14px; font-family: inherit; cursor: pointer;
}
.plan-select:focus { outline: none; border-color: #f59e0b; }
.print-btn {
    background: linear-gradient(135deg, #10b981, #06b6d4);
    color: #fff; border: none; border-radius: 8px;
    padding: 8px 20px; font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}
.print-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(16,185,129,0.3); }
.pdf-btn {
    background: linear-gradient(135deg, #818cf8, #6366f1);
    color: #fff; border: none; border-radius: 8px;
    padding: 8px 20px; font-size: 14px; font-weight: 600;
    cursor: pointer; font-family: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}
.pdf-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(129,140,248,0.3); }
.pdf-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ---- Print Slide (screen view) ---- */
.print-slide {
    position: relative; z-index: 1;
    max-width: 1200px; margin: 80px auto 40px;
    padding: 32px 40px;
}

/* ---- Salon Name Input Row ---- */
.salon-name-input-row {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px; padding: 10px 16px;
    background: rgba(245,158,11,0.06);
    border: 1px dashed rgba(245,158,11,0.25);
    border-radius: 10px;
}
.salon-input-label { font-size: 13px; color: #f59e0b; font-weight: 500; white-space: nowrap; }
.salon-name-input {
    flex: 1; max-width: 320px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px; padding: 8px 14px; color: #fff;
    font-size: 16px; font-family: inherit; font-weight: 600;
}
.salon-name-input:focus { outline: none; border-color: #f59e0b; }
.salon-name-input::placeholder { color: rgba(255,255,255,0.25); font-weight: 400; }

/* ---- Slide Header ---- */
.slide-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.slide-logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 24px; }
.logo-text { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.logo-accent { color: #10b981; }
.salon-name-display { font-size: 14px; color: #7a8599; transition: all 0.3s; }
.salon-name-display.personalized {
    font-size: 16px; color: #f59e0b; font-weight: 700;
    background: rgba(245,158,11,0.08);
    padding: 4px 16px; border-radius: 8px;
    border: 1px solid rgba(245,158,11,0.2);
}

/* ===== TOP SECTION: Chart + Break-even ===== */
.slide-top { margin-bottom: 8px; }

.plan-header-row {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.plan-name-badge { font-size: 16px; font-weight: 800; color: #10b981; }
.plan-cost-row { font-size: 12px; color: #7a8599; }
.plan-tag {
    display: inline-block; font-size: 10px; font-weight: 600;
    background: rgba(16,185,129,0.15); color: #10b981;
    padding: 2px 8px; border-radius: 6px; margin-left: 8px;
    vertical-align: middle;
}

.chart-and-be {
    display: grid; grid-template-columns: 1fr 200px; gap: 16px;
    align-items: stretch;
}

.chart-container {
    height: 300px; position: relative;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px; padding: 8px;
}

/* Break-even overlay (right side of chart) */
.be-overlay {
    display: flex; flex-direction: column; gap: 8px;
    justify-content: center; align-items: center;
    text-align: center;
}
.be-label { font-size: 12px; color: #7a8599; font-weight: 500; }
.be-big {
    font-size: 52px; font-weight: 900; line-height: 1.1;
    font-family: 'Inter', sans-serif; color: #10b981;
}
.be-unit { font-size: 22px; font-weight: 600; }
.be-desc { font-size: 11px; color: #6a7586; margin-top: 2px; }

.profit-12m-box {
    width: 100%; text-align: center; padding: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px; margin-top: 4px;
}
.profit-12m-label { font-size: 11px; color: #7a8599; }
.profit-12m-value { font-size: 22px; font-weight: 800; font-family: 'Inter', sans-serif; }

/* ===== BOTTOM SECTION: Data grid ===== */
.slide-bottom {
    display: grid; grid-template-columns: 200px 1fr 280px; gap: 16px;
    margin-bottom: 8px;
}
.col-title { font-size: 13px; font-weight: 700; color: #e8ecf4; margin-bottom: 8px; }

/* -- Col 1: Salon Info -- */
.input-grid-3 { display: flex; flex-direction: column; gap: 6px; }
.input-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px; padding: 6px 12px;
}
.input-label { font-size: 11px; color: #7a8599; font-weight: 500; display: block; margin-bottom: 2px; }
.input-wrapper { display: flex; align-items: center; gap: 6px; }
.input-wrapper input {
    flex: 1; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px; padding: 6px 8px; color: #fff; font-size: 16px;
    font-family: 'Inter', sans-serif; font-weight: 700; width: 100%;
}
.input-wrapper input:focus { outline: none; border-color: #10b981; }
.input-unit { font-size: 12px; color: #7a8599; white-space: nowrap; }

/* -- Print-only static values -- */
.print-only { display: none; }
.input-static-values { display: none; flex-direction: column; gap: 4px; }
.static-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 5px 0; border-bottom: 1px solid rgba(0,0,0,0.08);
}
.static-label { font-size: 12px; color: #555; font-weight: 500; }
.static-val { font-size: 15px; font-weight: 700; color: #1a1e32; }

/* -- Col 2: Before / After -- */
.slide-ba-cards { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ba-card {
    flex: 1; background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px; padding: 8px 12px;
}
.ba-card.ba-after { border-color: rgba(16,185,129,0.3); }
.ba-badge {
    display: inline-block; font-size: 10px; font-weight: 600;
    padding: 2px 8px; border-radius: 99px; margin-bottom: 3px;
}
.ba-badge.current { background: rgba(130,140,170,0.2); color: #9aa5b8; }
.ba-badge.after { background: rgba(16,185,129,0.15); color: #10b981; }
.ba-value { font-size: 20px; font-weight: 800; font-family: 'Inter', sans-serif; line-height: 1.2; }
.ba-value.positive { color: #10b981; }
.ba-detail { font-size: 11px; color: #7a8599; margin-top: 2px; }
.ba-arrow { color: #5a6478; font-size: 16px; flex-shrink: 0; }

/* -- Improvement row -- */
.improvement-row {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
    margin-bottom: 8px;
}
.improvement-item {
    text-align: center; padding: 8px 6px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
}
.improvement-label { font-size: 11px; color: #7a8599; margin-bottom: 3px; font-weight: 600; }
.improvement-values { font-size: 13px; }
.improvement-values .before { color: #7a8599; }
.improvement-values .arrow { color: #5a6478; margin: 0 3px; }
.improvement-values .after { color: #10b981; font-weight: 700; }
.improvement-values .pct { color: #10b981; font-size: 12px; margin-left: 3px; font-weight: 700; }

/* -- Revenue banner -- */
.revenue-increase-mini {
    background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(6,182,212,0.12));
    border: 1px solid rgba(16,185,129,0.3);
    border-radius: 10px; padding: 10px 16px;
    text-align: center; font-size: 16px; font-weight: 700;
}
.banner-icon { margin-right: 4px; }

/* -- Col 3: Table + Annual Impact -- */
.summary-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}

.mini-table-wrap {
    overflow-y: auto; max-height: 180px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 8px;
}
.mini-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.mini-table thead th {
    position: sticky; top: 0;
    background: rgba(15,20,36,0.95); color: #7a8599;
    padding: 4px 8px; text-align: left; font-weight: 500;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.mini-table tbody tr { border-bottom: 1px solid rgba(255,255,255,0.03); }
.mini-table tbody td { padding: 3px 8px; }
.mini-table .positive { color: #10b981; font-weight: 600; }
.mini-table .negative { color: #ef4444; }
.breakeven-row { background: rgba(16,185,129,0.08); }
.breakeven-marker {
    display: inline-block; background: #10b981; color: #fff;
    font-size: 9px; padding: 1px 6px; border-radius: 4px;
    margin-left: 4px; font-weight: 700;
}

/* Annual impact compact */
.annual-impact-compact {
    display: flex; flex-direction: column; gap: 6px;
    justify-content: center;
}
.annual-big-number { display: flex; flex-direction: column; }
.annual-label { font-size: 10px; color: #7a8599; }
.annual-value {
    font-size: 28px; font-weight: 900; font-family: 'Inter', sans-serif;
    color: #10b981; letter-spacing: -0.02em; line-height: 1.1;
}
.annual-cost-justify {
    font-size: 11px; color: #a8b3c5;
    padding: 5px 10px; border-radius: 6px;
    background: rgba(255,255,255,0.03);
}
.annual-cost-justify strong { color: #10b981; font-size: 14px; }

.annual-sub-stats { display: flex; flex-direction: column; gap: 4px; }
.annual-stat {
    display: flex; flex-direction: column;
    padding: 5px 10px; border-radius: 8px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
}
.stat-num { font-size: 16px; font-weight: 800; color: #06b6d4; font-family: 'Inter', sans-serif; }
.stat-desc { font-size: 9px; color: #7a8599; }

/* ---- Slide Footer ---- */
.slide-footer {
    margin-top: 6px; padding-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.06);
    text-align: center; font-size: 10px; color: #5a6478;
}


/* ===================================================
   ===== PRINT STYLES — A4 Landscape (white) =====
   =================================================== */
@media print {
    @page {
        size: A4 landscape;
        margin: 5mm 7mm;
    }

    /* Hide non-print elements */
    .no-print,
    .internal-toolbar,
    .bg-particles,
    .salon-name-input-row { display: none !important; }
    .print-only { display: flex !important; }

    /* Hide extra table rows (keep first 6) */
    .print-hide-row { display: none !important; }

    /* ---- White base ---- */
    html { font-size: 9px; }
    body {
        background: #fff !important;
        color: #1a1e32 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        line-height: 1.35;
    }

    /* Slide container — use grid for balanced proportions */
    .print-slide {
        max-width: 100%; margin: 0; padding: 0;
        width: 100%; height: 100vh;
        display: grid;
        grid-template-rows: auto 40% 1fr auto;
        page-break-inside: avoid;
        overflow: hidden;
    }

    /* ---- Header ---- */
    .slide-header {
        border-bottom: 2px solid #ddd; margin-bottom: 4px; padding-bottom: 3px;
    }
    .logo-icon { font-size: 18px; }
    .logo-text { color: #1a1e32; font-size: 16px; }
    .logo-accent { color: #10b981; }
    .salon-name-display { color: #666; font-size: 11px; }
    .salon-name-display.personalized {
        color: #d97706; background: rgba(245,158,11,0.08);
        border: 1px solid rgba(245,158,11,0.25);
        font-size: 12px; padding: 2px 12px;
    }

    /* ===== TOP: Chart area (47% of page) ===== */
    .slide-top {
        display: flex; flex-direction: column;
        min-height: 0; margin-bottom: 4px;
    }

    .plan-header-row { margin-bottom: 3px; }
    .plan-name-badge { color: #10b981; font-size: 13px; }
    .plan-cost-row { color: #666; font-size: 10px; }
    .plan-tag { font-size: 9px; padding: 1px 6px; }

    .chart-and-be {
        flex: 1; min-height: 0;
        gap: 10px; grid-template-columns: 1fr 140px;
    }
    .chart-container {
        background: #fff; border: 1px solid #ddd;
        height: 100% !important; min-height: 0; padding: 4px;
        border-radius: 8px;
    }

    .be-overlay { gap: 6px; }
    .be-label { color: #555; font-size: 10px; font-weight: 600; }
    .be-big { color: #10b981; font-size: 38px; }
    .be-unit { font-size: 16px; }
    .be-desc { color: #888; font-size: 9px; }

    .profit-12m-box {
        background: #f8f9fa; border: 1px solid #ddd;
        padding: 6px; border-radius: 8px; margin-top: 4px;
    }
    .profit-12m-label { color: #666; font-size: 9px; }
    .profit-12m-value { font-size: 16px; }

    /* ===== BOTTOM: Data sections — stretch to fill ===== */
    .slide-bottom {
        grid-template-columns: 160px 1fr 280px;
        gap: 12px; margin-bottom: 0;
        align-items: stretch;
    }
    .bottom-col {
        display: flex; flex-direction: column;
    }

    .col-title {
        color: #1a1e32; font-size: 11px; margin-bottom: 6px;
        font-weight: 700; padding-bottom: 4px;
        border-bottom: 2px solid #10b981;
    }

    /* Col 1: Salon Info — fill height with spaced items */
    .input-grid-3 { display: none !important; }
    .input-static-values {
        display: flex !important; flex-direction: column;
        gap: 0; flex: 1; justify-content: space-evenly;
    }
    .static-item {
        padding: 8px 6px; border-bottom: 1px solid #e8e8e8;
        display: flex; flex-direction: column; gap: 2px;
    }
    .static-item:last-child { border-bottom: none; }
    .static-label { font-size: 10px; color: #888; font-weight: 500; }
    .static-val { font-size: 18px; color: #1a1e32; font-weight: 800; font-family: 'Inter', sans-serif; }

    /* Col 2: BA + improvements — fill height */
    .col-ba { justify-content: space-between; }
    .ba-card {
        background: #f8f9fa; border: 1px solid #ddd;
        padding: 8px 12px; border-radius: 8px;
    }
    .ba-card.ba-after { border-color: #10b981; border-width: 2px; }
    .ba-badge { font-size: 9px; padding: 2px 8px; margin-bottom: 2px; }
    .ba-badge.current { background: #e9ecef; color: #666; }
    .ba-badge.after { background: rgba(16,185,129,0.12); color: #10b981; }
    .ba-value { color: #1a1e32; font-size: 18px; }
    .ba-value.positive { color: #10b981; }
    .ba-detail { color: #666; font-size: 9px; margin-top: 2px; }
    .ba-arrow { color: #999; font-size: 14px; }
    .slide-ba-cards { gap: 6px; margin-bottom: 6px; }

    .improvement-row { gap: 8px; margin-bottom: 8px; }
    .improvement-item {
        background: #f8f9fa; border: 1px solid #ddd;
        padding: 8px 8px; border-radius: 8px;
    }
    .improvement-label { color: #555; font-size: 12px; margin-bottom: 3px; font-weight: 700; }
    .improvement-values { font-size: 13px; font-weight: 600; }
    .improvement-values .before { color: #888; }
    .improvement-values .after { color: #1a1e32; font-weight: 800; }
    .improvement-values .arrow { color: #999; margin: 0 3px; }
    .improvement-values .pct { font-size: 12px; color: #10b981; font-weight: 800; }

    .revenue-increase-mini {
        background: rgba(16,185,129,0.08); border: 2px solid rgba(16,185,129,0.4);
        color: #1a1e32; padding: 10px 14px; font-size: 16px; border-radius: 8px;
        font-weight: 800;
    }

    /* Col 3: Table + Annual — fill height */
    .col-summary { justify-content: stretch; }
    .summary-grid {
        gap: 8px; grid-template-columns: 1fr 1fr;
        flex: 1; align-items: stretch;
    }

    .mini-table-wrap {
        background: #fff; border: 1px solid #ddd;
        max-height: none; overflow: hidden; border-radius: 8px;
    }
    .mini-table { height: 100%; }
    .mini-table thead th {
        background: #f0f0f0; color: #333;
        border-bottom: 2px solid #ddd; font-size: 9px; padding: 4px 6px;
        font-weight: 600;
    }
    .mini-table tbody tr { border-bottom: 1px solid #eee; }
    .mini-table tbody td { color: #333; padding: 4px 6px; font-size: 11px; }
    .mini-table .positive { color: #10b981; font-weight: 700; }
    .mini-table .negative { color: #ef4444; font-weight: 600; }
    .breakeven-row { background: rgba(16,185,129,0.1); }
    .breakeven-marker { font-size: 8px; padding: 1px 5px; }

    .annual-impact-compact {
        gap: 6px; justify-content: space-evenly;
        display: flex; flex-direction: column; flex: 1;
    }
    .annual-value { font-size: 28px; color: #10b981; line-height: 1; }
    .annual-label { color: #666; font-size: 9px; }
    .annual-cost-justify {
        color: #444; background: #f8f9fa;
        font-size: 11px; padding: 6px 8px; border-radius: 6px;
        border: 1px solid #e8e8e8;
    }
    .annual-cost-justify strong { color: #10b981; font-size: 15px; }
    .annual-sub-stats { gap: 5px; }
    .annual-stat {
        background: #f8f9fa; border: 1px solid #ddd;
        padding: 6px 10px; border-radius: 6px;
    }
    .stat-num { color: #0891b2; font-size: 15px; }
    .stat-desc { color: #666; font-size: 9px; }

    /* Footer */
    .slide-footer {
        border-top: 2px solid #ddd; color: #888;
        padding-top: 4px; font-size: 8px;
        align-self: end;
    }
}

/* ---- Responsive (Screen) ---- */
@media screen and (max-width: 900px) {
    .slide-bottom { grid-template-columns: 1fr; }
    .chart-and-be { grid-template-columns: 1fr; }
    .slide-ba-cards { flex-direction: column; }
    .improvement-row { grid-template-columns: repeat(2, 1fr); }
    .summary-grid { grid-template-columns: 1fr; }
    .print-slide { margin: 70px 16px 30px; padding: 20px; }
    .toolbar-inner { gap: 8px; }
    .plan-select { max-width: 100%; }
    .salon-name-input-row { flex-direction: column; align-items: stretch; }
}
