/* ==========================================================================
   KCAI MRI Break-Even Calculator — Plugin stylesheet
   PHB design system: navy #0d2b4e, teal #1d9e75, gold #ba7517
   All selectors scoped to #phb-root. Class names prefixed kcai-be- to avoid
   collisions with WordPress themes and other plugins.
   ========================================================================== */

#phb-root {
    font-family: 'Source Sans 3', sans-serif;
    background: #f7f9fb;
    color: #0d2b4e;
    padding: 24px 16px;
    max-width: 1400px;
    margin: 0 auto;
    line-height: 1.5;
    box-sizing: border-box;
}

#phb-root *,
#phb-root *::before,
#phb-root *::after {
    box-sizing: border-box;
}

#phb-root h1,
#phb-root h2,
#phb-root h3 {
    font-family: 'Playfair Display', serif;
    color: #0d2b4e;
    margin: 0 0 8px 0;
    line-height: 1.25;
}

/* ---------- Header band ---------- */
#phb-root .kcai-be-header-band {
    background: #0d2b4e;
    color: #ffffff;
    padding: 28px 28px;
    border-radius: 12px 12px 0 0;
}
#phb-root .kcai-be-brand-line {
    color: #ba7517;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    margin-bottom: 8px;
}
#phb-root .kcai-be-header-band h1 {
    color: #ffffff;
    font-size: 2rem;
    letter-spacing: 0.3px;
}
#phb-root .kcai-be-subtitle {
    color: #bcd4e6;
    font-size: 1rem;
    margin-top: 6px;
}

/* ---------- Container ---------- */
#phb-root .kcai-be-container {
    background: #ffffff;
    padding: 28px;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 14px rgba(13,43,78,0.08);
}

/* ---------- Input grid ---------- */
#phb-root .kcai-be-input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
@media (max-width: 820px) {
    #phb-root .kcai-be-input-grid { grid-template-columns: 1fr; }
}

/* ---------- Cards ---------- */
#phb-root .kcai-be-card {
    background: #ffffff;
    border: 1px solid #e3e8ef;
    border-radius: 10px;
    padding: 22px;
}
#phb-root .kcai-be-card-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    color: #0d2b4e;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #1d9e75;
}

/* ---------- Form fields ---------- */
#phb-root .kcai-be-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}
#phb-root .kcai-be-field-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
}
#phb-root .kcai-be-field-hint {
    font-size: 0.78rem;
    color: #64748b;
    font-style: italic;
}
#phb-root input[type="number"],
#phb-root input[type="text"] {
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    color: #0d2b4e;
    background: #ffffff;
    width: 100%;
    transition: border-color 0.15s;
    box-shadow: none;
}
#phb-root input[type="number"]:focus,
#phb-root input[type="text"]:focus {
    outline: none;
    border-color: #1d9e75;
    box-shadow: 0 0 0 3px rgba(29,158,117,0.15);
}

/* ---------- Toggle buttons ---------- */
#phb-root .kcai-be-toggle-group {
    display: flex;
    gap: 8px;
}
#phb-root .kcai-be-toggle-btn {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #cbd5e1;
    background: #ffffff;
    color: #475569;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.15s;
    line-height: 1.2;
}
#phb-root .kcai-be-toggle-btn.active {
    background: #0d2b4e;
    color: #ffffff;
    border-color: #0d2b4e;
}
#phb-root .kcai-be-toggle-btn:hover:not(.active) {
    border-color: #1d9e75;
    color: #1d9e75;
}

/* ---------- Pill display ---------- */
#phb-root .kcai-be-pill-display {
    background: #0d2b4e;
    background: linear-gradient(135deg, #0d2b4e 0%, #1a3d68 100%);
    color: #ffffff;
    padding: 14px 18px;
    border-radius: 8px;
    margin-top: 10px;
}
#phb-root .kcai-be-pill-display.teal {
    background: #1d9e75;
    background: linear-gradient(135deg, #1d9e75 0%, #167a5b 100%);
}
#phb-root .kcai-be-big-num {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: #ba7517;
    display: block;
    line-height: 1.1;
}
#phb-root .kcai-be-pill-display.teal .kcai-be-big-num {
    color: #ffffff;
}
#phb-root .kcai-be-pill-label {
    font-size: 0.82rem;
    color: #bcd4e6;
    display: block;
    margin-top: 2px;
}
#phb-root .kcai-be-pill-display.teal .kcai-be-pill-label {
    color: #d4f0e4;
}

/* ---------- Expense toggle ---------- */
#phb-root .kcai-be-expense-toggle {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    width: fit-content;
}
#phb-root .kcai-be-expense-toggle button {
    padding: 8px 18px;
    border: none;
    background: #ffffff;
    color: #475569;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.88rem;
}
#phb-root .kcai-be-expense-toggle button.active {
    background: #1d9e75;
    color: #ffffff;
}

/* ---------- Expense items grid ---------- */
#phb-root .kcai-be-expense-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
@media (max-width: 820px) {
    #phb-root .kcai-be-expense-items { grid-template-columns: 1fr; }
}
#phb-root .kcai-be-expense-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
#phb-root .kcai-be-expense-item label {
    font-size: 0.82rem;
    color: #475569;
    font-weight: 600;
}

#phb-root .kcai-be-expense-total {
    margin-top: 16px;
    padding: 14px 18px;
    background: #f1f5f9;
    border-left: 4px solid #ba7517;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
#phb-root .kcai-be-total-label {
    font-weight: 600;
    color: #334155;
}
#phb-root .kcai-be-total-value {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: #0d2b4e;
}

/* ---------- Metrics grid ---------- */
#phb-root .kcai-be-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
@media (max-width: 900px) {
    #phb-root .kcai-be-metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
    #phb-root .kcai-be-metrics-grid { grid-template-columns: 1fr; }
}

#phb-root .kcai-be-metric-card {
    background: #ffffff;
    border: 1px solid #e3e8ef;
    border-top: 4px solid #1d9e75;
    border-radius: 8px;
    padding: 18px;
    text-align: center;
}
#phb-root .kcai-be-metric-card.accent-gold { border-top-color: #ba7517; }
#phb-root .kcai-be-metric-card.accent-navy { border-top-color: #0d2b4e; }
#phb-root .kcai-be-metric-label {
    font-size: 0.78rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    font-weight: 600;
}
#phb-root .kcai-be-metric-value {
    font-family: 'Playfair Display', serif;
    font-size: 1.9rem;
    font-weight: 700;
    color: #0d2b4e;
    margin-bottom: 4px;
    line-height: 1.1;
}
#phb-root .kcai-be-metric-sub {
    font-size: 0.82rem;
    color: #64748b;
}
#phb-root .kcai-be-metric-card.profit .kcai-be-metric-value { color: #1d9e75; }
#phb-root .kcai-be-metric-card.loss .kcai-be-metric-value { color: #c0392b; }

/* ---------- Chart wrapper ---------- */
#phb-root .kcai-be-chart-wrapper {
    background: #ffffff;
    border: 1px solid #e3e8ef;
    border-radius: 10px;
    padding: 22px;
    margin-bottom: 24px;
}
#phb-root .kcai-be-chart-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    color: #0d2b4e;
    margin-bottom: 14px;
}
#phb-root .kcai-be-chart-container {
    position: relative;
    height: 400px;
}
@media (max-width: 600px) {
    #phb-root .kcai-be-chart-container { height: 300px; }
}

/* ---------- Scenario table ---------- */
#phb-root .kcai-be-scenario-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border: 1px solid #e3e8ef;
    border-radius: 8px;
    overflow: hidden;
}
#phb-root .kcai-be-scenario-table th {
    background: #0d2b4e;
    color: #ffffff;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.88rem;
}
#phb-root .kcai-be-scenario-table td {
    padding: 12px 14px;
    border-top: 1px solid #e3e8ef;
    font-size: 0.92rem;
    color: #0d2b4e;
}
#phb-root .kcai-be-scenario-table tr.current-scenario {
    background: #fef9ed;
}
#phb-root .kcai-be-scenario-table tr.current-scenario td:first-child {
    font-weight: 700;
    color: #ba7517;
}

/* ---------- Section heads and misc ---------- */
#phb-root .kcai-be-section-heading {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    color: #0d2b4e;
    margin: 32px 0 8px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e3e8ef;
}
#phb-root .kcai-be-section-intro {
    color: #64748b;
    font-size: 0.92rem;
    margin-bottom: 16px;
}
#phb-root .kcai-be-info-box {
    background: #f0faf7;
    border-left: 4px solid #1d9e75;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 0.92rem;
    color: #0d2b4e;
    margin: 12px 0 0 0;
}
#phb-root .kcai-be-info-box.warn {
    background: #fef6f0;
    border-left-color: #c0392b;
    color: #7a2317;
}
#phb-root .kcai-be-footnote {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e3e8ef;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.6;
}
#phb-root .kcai-be-footnote strong {
    color: #0d2b4e;
}
