/* ── Overlay & Modal ─────────────────────────────────────── */
.fc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 40, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1060;
    padding: 1rem;
}

.fc-modal {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 32px 64px -12px rgba(91, 78, 234, 0.22), 0 0 0 1px rgba(91,78,234,0.08);
    width: 100%;
    max-width: 720px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Controls strip ──────────────────────────────────────── */
.fc-controls-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    padding: 0.9rem 1.25rem 0.75rem;
    border-bottom: 1px solid #f1f0fb;
    background: #fafafa;
}

.fc-ctrl-group { display: flex; flex-direction: column; gap: 0.3rem; }

.fc-ctrl-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #4c1d95;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fc-weight-wrap {
    display: flex;
    align-items: center;
    border: 1.5px solid #c4b5fd;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    width: 220px;
    box-shadow: 0 1px 4px rgba(91,78,234,0.07);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.fc-weight-wrap:focus-within {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}
.fc-weight-input {
    border: none; outline: none;
    flex: 1; padding: 0.42rem 0.7rem;
    font-size: 0.9rem; font-weight: 600; color: #1e1b4b;
    background: transparent;
    -moz-appearance: textfield;
}
.fc-weight-input::-webkit-outer-spin-button,
.fc-weight-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.fc-weight-unit {
    padding: 0.42rem 0.7rem;
    background: #ede9fe;
    color: #6d28d9;
    font-size: 0.82rem;
    font-weight: 700;
    border-left: 1.5px solid #c4b5fd;
}

.fc-ctrl-hint { font-size: 0.68rem; color: #9ca3af; }

/* Segment toggle (pill buttons) */
.fc-seg-toggle {
    display: flex;
    gap: 0;
    border: 1.5px solid #c4b5fd;
    border-radius: 8px;
    overflow: hidden;
    width: fit-content;
}
.fc-seg-opt {
    padding: 0.38rem 1rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #7c3aed;
    background: #fff;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s;
    border: none;
}
.fc-seg-opt + .fc-seg-opt { border-left: 1.5px solid #c4b5fd; }
.fc-seg-opt input { display: none; }
.fc-seg-opt.active {
    background: linear-gradient(135deg, #7c3aed, #5b4eea);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}

/* ── Distribution header strip ───────────────────────────── */
.fc-dist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 1.25rem 0.5rem;
    background: linear-gradient(90deg, #f5f3ff 0%, #faf5ff 100%);
    border-bottom: 1px solid #ede9fe;
}

.fc-dist-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #6d28d9;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.fc-dist-icon { font-size: 0.8rem; opacity: 0.7; }

.fc-total-pill {
    font-size: 0.74rem;
    font-weight: 800;
    padding: 0.28rem 0.8rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #fff;
    box-shadow: 0 2px 6px rgba(245,158,11,0.4);
    letter-spacing: 0.3px;
}
.fc-total-pill.done {
    background: linear-gradient(135deg, #34d399, #059669);
    box-shadow: 0 2px 6px rgba(5,150,105,0.35);
}

/* ── Fiber panel (Yes case) ──────────────────────────────── */
.fc-fiber-panel {
    display: grid;
    grid-template-columns: 1fr 1px 1fr;
    gap: 0;
    padding: 0 0 0.5rem;
}

.fc-fiber-col { display: flex; flex-direction: column; }

.fc-fiber-divider { background: #ede9fe; }

.fc-col-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.25rem 0.45rem;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    border-bottom: 2px solid transparent;
}
.cotton-hdr {
    color: #4c1d95;
    background: linear-gradient(90deg, #ede9fe 0%, #f5f3ff 100%);
    border-bottom-color: #c4b5fd;
}
.synth-hdr {
    color: #164e63;
    background: linear-gradient(90deg, #ecfeff 0%, #f0fdff 100%);
    border-bottom-color: #a5f3fc;
}

.fc-col-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    box-shadow: 0 0 6px rgba(124,58,237,0.5);
    flex-shrink: 0;
}
.synth-dot {
    background: linear-gradient(135deg, #67e8f9, #0891b2);
    box-shadow: 0 0 6px rgba(8,145,178,0.4);
}

.fc-fiber-row {
    display: grid;
    grid-template-columns: 1fr 88px 56px;
    align-items: center;
    gap: 0.5rem;
    padding: 0.32rem 1.25rem;
}
.fc-fiber-row.alt { background: #faf9ff; }
.fc-fiber-row label {
    font-size: 0.82rem;
    font-weight: 500;
    color: #374151;
    margin: 0;
}

/* ── Number input wrapper ────────────────────────────────── */
.fc-num-wrap {
    display: flex;
    align-items: center;
    border: 1.5px solid #e5e7eb;
    border-radius: 7px;
    overflow: hidden;
    background: #fff;
    transition: border-color 0.18s, box-shadow 0.18s;
}
.fc-num-wrap:focus-within {
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167,139,250,0.2);
}
.fc-num-wrap input {
    border: none; outline: none;
    width: 100%; padding: 0.28rem 0.5rem;
    font-size: 0.84rem; font-weight: 600;
    color: #1e1b4b; text-align: right;
    background: transparent;
    -moz-appearance: textfield;
}
.fc-num-wrap input::-webkit-outer-spin-button,
.fc-num-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; }
.fc-num-wrap span {
    padding: 0.28rem 0.45rem;
    font-size: 0.75rem; font-weight: 700;
    color: #7c3aed;
    background: #f5f3ff;
    border-left: 1.5px solid #e5e7eb;
}

/* ── NO case — segment toolbar ───────────────────────────── */
.fc-seg-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem 0.6rem;
    background: #fafafa;
    border-bottom: 1px solid #f1f0fb;
}
.fc-seg-toolbar-title { font-size: 0.85rem; font-weight: 700; color: #1e1b4b; margin: 0; }
.fc-seg-toolbar-hint  { font-size: 0.7rem; color: #9ca3af; margin: 0; }

.fc-seg-total {
    font-size: 0.72rem; font-weight: 800;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
}
.fc-seg-total.done { background: #d1fae5; color: #065f46; }
.fc-seg-total.warn { background: #fee2e2; color: #991b1b; }

.fc-add-seg-btn {
    display: inline-flex; align-items: center;
    padding: 0.35rem 0.85rem;
    font-size: 0.78rem; font-weight: 700;
    color: #5b4eea;
    background: #ede9fe;
    border: 1.5px solid #c4b5fd;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.fc-add-seg-btn:hover { background: #5b4eea; color: #fff; }

.fc-empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #9ca3af;
}
.fc-empty-state i { font-size: 2rem; opacity: 0.3; display: block; margin-bottom: 0.5rem; }
.fc-empty-state p { font-size: 0.82rem; margin: 0; }

/* ── Segment cards ───────────────────────────────────────── */
.fc-segments-stack {
    display: flex; flex-direction: column; gap: 0.5rem;
    padding: 0.75rem 1.25rem;
}
.fc-seg-card {
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.fc-seg-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.8rem;
    background: linear-gradient(90deg, #f9f7ff 0%, #fff 100%);
    cursor: pointer;
    border-bottom: 1px solid transparent;
}
.fc-seg-name-input {
    border: 1.5px solid #e5e7eb; border-radius: 7px;
    padding: 0.3rem 0.65rem;
    font-size: 0.82rem; font-weight: 600;
    color: #1e1b4b; outline: none;
    max-width: 200px;
    transition: border-color 0.18s;
}
.fc-seg-name-input:focus { border-color: #a78bfa; }
.fc-seg-pct-wrap { display: flex; align-items: center; gap: 0.4rem; }
.fc-seg-pct-input {
    width: 58px; padding: 0.3rem 0.4rem; text-align: center;
    border: 1.5px solid #e5e7eb; border-radius: 7px;
    font-size: 0.82rem; font-weight: 600; color: #1e1b4b; outline: none;
    -moz-appearance: textfield;
}
.fc-seg-pct-input::-webkit-outer-spin-button,
.fc-seg-pct-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.fc-seg-pct-label { font-size: 0.68rem; color: #9ca3af; white-space: nowrap; }
.fc-fiber-badge {
    font-size: 0.68rem; font-weight: 800;
    padding: 0.22rem 0.6rem; border-radius: 999px;
}
.fc-fiber-badge.ok   { background: #d1fae5; color: #065f46; }
.fc-fiber-badge.warn { background: #fef3c7; color: #92400e; }
.fc-seg-del {
    border: none; background: transparent; cursor: pointer;
    color: #9ca3af; padding: 0.2rem 0.3rem; border-radius: 5px;
    font-size: 0.82rem; transition: background 0.15s, color 0.15s;
}
.fc-seg-del:hover { background: #fee2e2; color: #dc2626; }
.fc-chev { font-size: 0.8rem; color: #9ca3af; }

.fc-seg-body { padding: 0.75rem 1rem; background: #fafafa; border-top: 1px dashed #e5e7eb; }
.fc-fiber-mini-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 0.45rem;
}
.fc-mini-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.4rem;
}
.fc-mini-row label { font-size: 0.76rem; color: #6b7280; flex: 1; }
.fc-mini-row .fc-num-wrap { width: 80px; flex-shrink: 0; }

/* ── Footer ──────────────────────────────────────────────── */
.fc-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #f0effe;
    background: linear-gradient(180deg, #fff 0%, #f9f7ff 100%);
    flex-shrink: 0;
}

.fc-btn-cancel {
    padding: 0.45rem 1.1rem;
    font-size: 0.82rem; font-weight: 600;
    color: #6b7280;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.fc-btn-cancel:hover { border-color: #9ca3af; color: #374151; background: #f9fafb; }

.fc-btn-calc {
    padding: 0.45rem 1.1rem;
    font-size: 0.82rem; font-weight: 700;
    color: #5b4eea;
    background: #fff;
    border: 1.5px solid #c4b5fd;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.fc-btn-calc:hover { background: #ede9fe; }

.fc-btn-save {
    padding: 0.45rem 1.25rem;
    font-size: 0.82rem; font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed 0%, #5b4eea 60%, #4f46e5 100%);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(91,78,234,0.38), inset 0 1px 0 rgba(255,255,255,0.15);
    transition: opacity 0.15s, box-shadow 0.15s;
}
.fc-btn-save:hover {
    opacity: 0.93;
    box-shadow: 0 6px 18px rgba(91,78,234,0.48), inset 0 1px 0 rgba(255,255,255,0.15);
}

/* ── Add-segment type-picker ────────────────────────────── */
.fc-add-seg-wrap { position: relative; }

.fc-add-type-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    width: 230px;
    background: #fff;
    border: 1.5px solid #ede9fe;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(91,78,234,0.18), 0 0 0 1px rgba(91,78,234,0.06);
    padding: 0.45rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.fc-type-opt {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.55rem;
    border-radius: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.13s;
}
.fc-type-opt:hover:not(:disabled) { background: #f5f3ff; }
.fc-type-opt:disabled { opacity: 0.4; cursor: not-allowed; }

.fc-type-icon {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 0.88rem;
    flex-shrink: 0;
}
.picon { background: linear-gradient(135deg, #7c3aed, #5b4eea); box-shadow: 0 2px 6px rgba(91,78,234,0.35); }
.cicon { background: linear-gradient(135deg, #0891b2, #0ea5e9); box-shadow: 0 2px 6px rgba(8,145,178,0.3); }
.cicon-off { background: #d1d5db !important; box-shadow: none !important; }

.fc-type-text { display: flex; flex-direction: column; gap: 1px; }
.fc-type-name { font-size: 0.78rem; font-weight: 700; color: #1e1b4b; }
.fc-type-desc { font-size: 0.66rem; color: #9ca3af; }

/* ── Parent picker bar ────────────────────────────────────── */
.fc-parent-picker-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 1.25rem;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
}
.fc-pp-label { font-size: 0.74rem; font-weight: 700; color: #92400e; white-space: nowrap; }
.fc-pp-btn {
    padding: 0.22rem 0.65rem;
    font-size: 0.74rem; font-weight: 700;
    border: 1.5px solid #a78bfa;
    border-radius: 999px;
    background: #fff;
    color: #5b4eea;
    cursor: pointer;
    transition: background 0.13s;
}
.fc-pp-btn:hover { background: #ede9fe; }
.fc-pp-cancel {
    border: none; background: transparent; cursor: pointer;
    color: #9ca3af; font-size: 0.82rem; padding: 0.1rem 0.3rem;
    border-radius: 5px; margin-left: auto;
}
.fc-pp-cancel:hover { background: #fee2e2; color: #dc2626; }

/* ── Segment type tags ────────────────────────────────────── */
.fc-seg-type-tag {
    display: inline-flex; align-items: center;
    padding: 0.16rem 0.5rem;
    border-radius: 999px;
    font-size: 0.64rem; font-weight: 800;
    letter-spacing: 0.3px;
    flex-shrink: 0; white-space: nowrap;
}
.ptag { background: #ede9fe; color: #5b4eea; }
.ctag { background: #ecfeff; color: #0891b2; }

/* ── Card header themes ───────────────────────────────────── */
.parent-hdr { background: linear-gradient(90deg, #f5f3ff 0%, #fafafa 100%); }
.child-hdr  { background: linear-gradient(90deg, #f0fdff 0%, #fff 100%); }

/* ── Child indent connector ───────────────────────────────── */
.fc-child-row {
    display: flex;
    align-items: stretch;
    padding-left: 1rem;
    border-top: 1px solid #f1efff;
}
.fc-child-connector-v {
    width: 14px;
    flex-shrink: 0;
    border-left: 2px dashed #c4b5fd;
    border-bottom: 2px dashed #c4b5fd;
    border-bottom-left-radius: 5px;
    margin: 0 0.4rem 0.5rem 0;
    min-height: 26px;
}
.fc-child-card {
    flex: 1;
    border: 1.5px solid #bae6fd;
    border-radius: 8px;
    overflow: hidden;
    margin: 0.3rem 0.6rem 0.3rem 0;
    background: #fff;
    box-shadow: 0 1px 3px rgba(8,145,178,0.08);
}

/* ── Inline add-child button on parent card ───────────────── */
.fc-add-child-inline {
    border: 1.5px solid #a5f3fc;
    background: #ecfeff;
    color: #0891b2;
    border-radius: 6px;
    padding: 0.18rem 0.42rem;
    font-size: 0.76rem;
    cursor: pointer;
    transition: background 0.13s, color 0.13s;
}
.fc-add-child-inline:hover { background: #0891b2; color: #fff; border-color: #0891b2; }

/* ── Exceed warning banner ───────────────────────────────── */
.fc-exceed-bar {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: #fff7ed;
    border: 1.5px solid #fed7aa;
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: #c2410c;
    margin-bottom: 0.5rem;
}
.fc-exceed-bar .bi-exclamation-triangle-fill { color: #ea580c; flex-shrink: 0; }
.fc-exceed-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    color: #c2410c;
    cursor: pointer;
    padding: 0 0.1rem;
    font-size: 0.78rem;
    opacity: 0.7;
    flex-shrink: 0;
}
.fc-exceed-dismiss:hover { opacity: 1; }

/* ── Gram value display ───────────────────────────────────── */
.fc-gm-val {
    font-size: 0.76rem;
    color: #6b7280;
    font-weight: 500;
    text-align: right;
    white-space: nowrap;
}
.fc-mini-row .fc-gm-val { min-width: 40px; flex-shrink: 0; }
.fc-total-pill.gm-pill {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
    font-weight: 600;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 640px) {
    .fc-fiber-panel { grid-template-columns: 1fr 1px 1fr; gap: 0; }
    .fc-fiber-divider { width: 1px; height: auto; }
    .fc-fiber-mini-grid { grid-template-columns: repeat(2, 1fr); }
    .fc-controls-strip { flex-direction: column; }
    .fc-weight-wrap { width: 100%; }
}

/* Collapse to single column only on very small screens */
@media (max-width: 480px) {
    .fc-fiber-panel { grid-template-columns: 1fr; gap: 0; }
    .fc-fiber-divider { height: 1px; width: 100%; }
}
