/* Unified & Scoped Styles for all 25 Engineering Calculators & Workspaces */
.calc-wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 12px 32px;
}

/* Unified Breadcrumb & Tool Header Banner (Compact) */
.tool-hero-bar {
    background: linear-gradient(135deg, #1363C6 0%, #1e3a8a 100%);
    color: #fff;
    border-radius: 12px;
    padding: 10px 18px;
    margin-bottom: 12px;
    box-shadow: 0 4px 14px rgba(19, 99, 198, 0.14);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.tool-hero-bar .breadcrumb-mini {
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 2px;
}

.tool-hero-bar .breadcrumb-mini a {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
}

.tool-hero-bar .breadcrumb-mini a:hover {
    text-decoration: underline;
}

.tool-hero-bar h1 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: #fff;
}

.tool-hero-bar .tool-subtitle {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 2px;
}

.tool-hero-bar .btn-light {
    background: #ffffff !important;
    border-color: #ffffff !important;
    color: #1363C6 !important;
}

.tool-hero-bar .btn-light:hover {
    background: #eff6ff !important;
    border-color: #eff6ff !important;
    color: #1e3a8a !important;
}

.tool-hero-bar .btn-outline-light {
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.45) !important;
    color: #ffffff !important;
}

.tool-hero-bar .btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.24) !important;
    border-color: #ffffff !important;
    color: #ffffff !important;
}

/* Scoped Cards */
.calc-wrap .card {
    background: var(--card, #ffffff);
    border: 1px solid var(--line, #e6e9f5);
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(2, 6, 23, 0.04);
    padding: 20px;
    margin-bottom: 18px;
}

.calc-wrap .card h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
    color: var(--brand, #1e3a8a);
}

.calc-wrap .section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line, #e6e9f5);
}

.calc-wrap .section-title .bar {
    width: 6px;
    height: 18px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--brand-2, #2563eb), var(--accent, #0ea5e9));
    flex-shrink: 0;
}

/* Scoped Grids & Form Controls */
.calc-wrap .grid {
    display: grid;
    gap: 14px;
}

.calc-wrap .grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.calc-wrap .grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 900px) {
    .calc-wrap .grid.cols-2,
    .calc-wrap .grid.cols-3 {
        grid-template-columns: 1fr;
    }
}

.calc-wrap label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted, #58627a);
    margin-bottom: 5px;
}

.calc-wrap input,
.calc-wrap select,
.calc-wrap textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid var(--line, #dce3f3);
    background: #fff;
    color: var(--text, #0f172a);
    font-size: 14px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.calc-wrap input[type="checkbox"],
.calc-wrap input[type="radio"] {
    width: auto;
    padding: 0;
}

.calc-wrap input:focus,
.calc-wrap select:focus,
.calc-wrap textarea:focus {
    outline: none;
    border-color: var(--brand-2, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.calc-wrap textarea {
    min-height: 80px;
}

.calc-wrap .muted,
.calc-wrap .input-hint {
    color: var(--muted, #58627a);
    font-size: 12.5px;
}

.calc-wrap .pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--brand-2, #2563eb);
    font-size: 11px;
    font-weight: 600;
}

/* Status Badges */
.calc-wrap .badge-pass,
.calc-wrap .badge-good {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: #dcfce7;
    color: #166534;
    font-size: 12px;
    font-weight: 600;
}

.calc-wrap .badge-warn {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    font-size: 12px;
    font-weight: 600;
}

.calc-wrap .badge-fail {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 12px;
    font-weight: 600;
}

/* Scoped Action Row & Buttons */
.calc-wrap .row,
.calc-wrap .row.no-print,
.calc-wrap .calc-actions,
.calc-wrap .table-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 10px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    --bs-gutter-x: 0;
}

.calc-wrap .row > *,
.calc-wrap .calc-actions > *,
.calc-wrap .table-actions > * {
    width: auto !important;
    max-width: none !important;
    flex: 0 0 auto !important;
}

.calc-wrap h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 14px 0 8px;
    color: var(--brand, #1e3a8a);
}

.calc-wrap .btn {
    padding: 8px 16px;
    border-radius: 10px;
    border: 1px solid var(--brand-2, #2563eb);
    background: var(--brand-2, #2563eb);
    color: #fff;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}

.calc-wrap .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.calc-wrap .btn.ghost {
    background: #fff;
    color: var(--brand-2, #2563eb);
    border-color: #cbd5e1;
}

.calc-wrap .btn.ghost:hover {
    background: #f8fafc;
    border-color: var(--brand-2, #2563eb);
}

.calc-wrap .btn.gray {
    background: #64748b;
    border-color: #64748b;
    color: #fff;
}

.calc-wrap .btn.warn {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}

/* Scoped Tables */
.calc-wrap .table-wrap,
.calc-wrap .table-responsive {
    width: 100%;
    overflow-x: auto;
}

.calc-wrap table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.calc-wrap th,
.calc-wrap td {
    padding: 9px 11px;
    border-bottom: 1px solid var(--line, #e6e9f5);
    text-align: left;
    font-size: 13.5px;
}

.calc-wrap th {
    background: rgba(37, 99, 235, 0.06);
    color: var(--brand, #1e3a8a);
    font-weight: 700;
}

/* Tool-Specific Helpers (racklabelgen, screenload, ascii diagrams) */
.calc-wrap .ascii {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    white-space: pre;
    overflow-x: auto;
    font-size: 12px;
}

.calc-wrap .tag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.calc-wrap .tag-item {
    border: 1px dashed #94a3b8;
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff;
    text-align: center;
}

.calc-wrap .tag-item .port-id {
    font-weight: 700;
    color: var(--brand, #1e3a8a);
    font-size: 12px;
}

.calc-wrap .tag-item .label-text {
    font-size: 13px;
    color: var(--text, #0f172a);
}

.calc-wrap .monitor-block,
.calc-wrap .config-item {
    border: 1px solid var(--line, #e6e9f5);
    border-radius: 12px;
    padding: 12px;
    background: #f8fafc;
    margin-bottom: 10px;
}

/* Highlighted Results Card */
.calc-wrap #results {
    border-left: 4px solid var(--brand-2, #2563eb);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.calc-wrap #results .grid > div {
    background: #fff;
    border: 1px solid #e6ecf8;
    border-radius: 12px;
    padding: 12px 14px;
}

/* Workspace Full-Height Shell (Room Planner & Rack Studio) */
body.workspace-mode {
    overflow: hidden !important;
    height: 100vh !important;
}

body.workspace-mode .workspace-shell {
    flex: 1;
    height: calc(100vh - 122px) !important;
    min-height: 520px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.workspace-mode .workspace-shell #app {
    flex: 1;
    height: 100% !important;
    min-height: 0;
}

/* Unified Print Header & Footer (screen preview inside report + print) */
.fb-legacy-print-hide {
    display: none !important;
}
.fb-print-footer,
#tagSheet {
    display: none;
}
.fb-print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #1363C6;
    padding-bottom: 10px;
    margin-bottom: 14px;
}
.fb-print-header .fb-ph-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.fb-print-header .fb-ph-brand img {
    height: 38px;
    width: auto;
}
.fb-print-header .fb-ph-title {
    font-size: 13pt;
    font-weight: 700;
    color: #1e3a8a;
    margin: 0;
}
.fb-print-header .fb-ph-sub {
    font-size: 9.5pt;
    font-weight: 600;
    color: #1363C6;
}
.fb-print-header .fb-ph-meta {
    text-align: right;
    font-size: 8.5pt;
    color: #475569;
    line-height: 1.4;
}
.fb-print-meta-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 12px;
    font-size: 8.5pt;
}

/* Print Rules */
@page { size: A4; margin: 10mm; }
@media print {
    .fb-legacy-print-hide { display: none !important; }
    body.print-tags-mode #summaryReport,
    body.print-tags-mode #results { display: none !important; }
    body.print-tags-mode #tagSheet { display: block !important; }
    body { background: #fff !important; color: #0f172a !important; font-size: 10pt; }
    #siteNav,
    .tool-hero-bar,
    .fb-workflow,
    .no-print,
    .calc-wrap .card:not(#summaryReport):not(#results) {
        display: none !important;
    }
    .tool-page-main { padding: 0 !important; margin: 0 !important; }
    .calc-wrap { max-width: none !important; padding: 0 !important; margin: 0 !important; }
    body.fb-has-summary-report .calc-wrap #results,
    .calc-wrap:has(#summaryReport) #results {
        display: none !important;
    }
    .calc-wrap #summaryReport,
    .calc-wrap #results {
        display: block !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        background: #fff !important;
    }
    .fb-print-header {
        display: flex !important;
        justify-content: space-between;
        align-items: flex-start;
        border-bottom: 2px solid #1363C6;
        padding-bottom: 10px;
        margin-bottom: 14px;
    }
    .fb-print-header .fb-ph-brand {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .fb-print-header .fb-ph-brand img {
        height: 38px;
        width: auto;
    }
    .fb-print-header .fb-ph-title {
        font-size: 13pt;
        font-weight: 700;
        color: #1e3a8a;
        margin: 0;
    }
    .fb-print-header .fb-ph-sub {
        font-size: 9.5pt;
        font-weight: 600;
        color: #1363C6;
    }
    .fb-print-header .fb-ph-meta {
        text-align: right;
        font-size: 8.5pt;
        color: #475569;
        line-height: 1.4;
    }
    .fb-print-meta-bar {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        background: #f8fafc !important;
        border: 1px solid #cbd5e1;
        border-radius: 6px;
        padding: 8px 10px;
        margin-bottom: 12px;
        font-size: 8.5pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .fb-print-footer {
        display: block !important;
        margin-top: 18px;
        padding-top: 10px;
        border-top: 1px solid #cbd5e1;
        break-inside: avoid;
    }
    .fb-print-signoff {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        text-align: center;
        margin-top: 16px;
        font-size: 8.5pt;
        color: #475569;
    }
    .fb-print-signoff > div {
        border-top: 1px solid #94a3b8;
        padding-top: 4px;
    }
    .fb-print-disclaimer {
        margin-top: 10px;
        font-size: 7.5pt;
        color: #64748b;
        text-align: center;
    }
    .calc-wrap table {
        font-size: 8.5pt !important;
        border-collapse: collapse !important;
    }
    .calc-wrap th,
    .calc-wrap td {
        border: 1px solid #cbd5e1 !important;
        padding: 5px 7px !important;
    }
    .calc-wrap th {
        background: #eff6ff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    tr, .grid > div { break-inside: avoid; }
}
