.branch-order-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.branch-order-modal.is-open {
    display: flex;
}

.branch-order-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(23, 22, 39, 0.55);
    backdrop-filter: blur(2px);
}

.branch-order-modal__panel {
    position: relative;
    width: 100%;
    max-width: 42rem;
    max-height: min(90vh, 720px);
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 24px 48px rgba(23, 22, 39, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: branchOrderModalIn 0.22s ease-out;
}

@keyframes branchOrderModalIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.branch-order-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #f5a800 0%, #e09500 100%);
    color: #171627;
}

.branch-order-modal__header-main {
    min-width: 0;
}

.branch-order-modal__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(23, 22, 39, 0.12);
    color: #171627;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    margin-bottom: 0.45rem;
}

.branch-order-modal__title {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
    margin: 0;
    color: #171627;
}

.branch-order-modal__subtitle {
    margin: 0.35rem 0 0;
    font-size: 0.95rem;
    color: rgba(23, 22, 39, 0.82);
}

.branch-order-modal__close {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.35);
    color: #171627;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.branch-order-modal__close:hover {
    background: rgba(255, 255, 255, 0.55);
}

.branch-order-modal__close:focus-visible {
    outline: 3px solid rgba(23, 22, 39, 0.35);
    outline-offset: 2px;
}

.branch-order-modal__toolbar {
    padding: 1rem 1.25rem;
    background: #f8f9fb;
    border-bottom: 1px solid #e5e7eb;
}

.branch-order-modal__search-row {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

@media (min-width: 640px) {
    .branch-order-modal__search-row {
        flex-direction: row;
        align-items: stretch;
    }
}

.branch-order-modal__search-wrap {
    position: relative;
    flex: 1;
}

.branch-order-modal__search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.branch-order-modal__search {
    width: 100%;
    padding: 0.65rem 0.85rem 0.65rem 2.4rem;
    border: 1px solid #d1d5db;
    border-radius: 0.65rem;
    font-size: 0.95rem;
    min-height: 44px;
    background: #fff;
}

.branch-order-modal__search:focus {
    outline: none;
    border-color: #f5a800;
    box-shadow: 0 0 0 3px rgba(245, 168, 0, 0.25);
}

.branch-order-modal__actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.branch-order-modal__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.55rem 1rem;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 700;
    border: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.branch-order-modal__btn--primary {
    background: #f5a800;
    border-color: #f5a800;
    color: #171627;
}

.branch-order-modal__btn--primary:hover:not(:disabled) {
    background: #e09500;
    border-color: #e09500;
}

.branch-order-modal__btn--ghost {
    background: #fff;
    border-color: #d1d5db;
    color: #374151;
}

.branch-order-modal__btn--ghost:hover:not(:disabled) {
    background: #f3f4f6;
}

.branch-order-modal__btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.branch-order-modal__btn:focus-visible {
    outline: 3px solid rgba(245, 168, 0, 0.4);
    outline-offset: 2px;
}

.branch-order-modal__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.65rem;
}

.branch-order-modal__count {
    font-size: 0.82rem;
    font-weight: 600;
    color: #6b7280;
}

.branch-order-modal__status {
    font-size: 0.82rem;
    color: #374151;
}

.branch-order-modal__status.is-error {
    color: #db0c1f;
}

.branch-order-modal__status.is-success {
    color: #047857;
}

.branch-order-modal__list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    min-height: 8rem;
}

.branch-order-modal__card {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 0.65rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.branch-order-modal__card:last-child {
    margin-bottom: 0;
}

.branch-order-modal__card:hover {
    border-color: #f5a800;
    box-shadow: 0 8px 20px rgba(245, 168, 0, 0.12);
    transform: translateY(-1px);
}

.branch-order-modal__card:focus-visible {
    outline: 3px solid rgba(245, 168, 0, 0.45);
    outline-offset: 2px;
    border-color: #f5a800;
}

.branch-order-modal__card-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.branch-order-modal__card-title {
    font-size: 1rem;
    font-weight: 800;
    color: #171627;
    margin: 0 0 0.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.branch-order-modal__distance {
    font-size: 0.72rem;
    font-weight: 700;
    background: #f5a800;
    color: #171627;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
}

.branch-order-modal__card-line {
    margin: 0.15rem 0;
    font-size: 0.85rem;
    color: #4b5563;
}

.branch-order-modal__card-line--muted {
    font-size: 0.78rem;
    color: #6b7280;
}

.branch-order-modal__card-arrow {
    color: #f5a800;
    margin-top: 0.15rem;
    flex-shrink: 0;
}

.branch-order-modal__empty {
    text-align: center;
    padding: 2rem 1rem;
}

.branch-order-modal__empty-icon {
    font-size: 2.2rem;
    color: #d1d5db;
    margin-bottom: 0.75rem;
}

.branch-order-modal__empty-title {
    font-size: 1rem;
    font-weight: 700;
    color: #374151;
    margin: 0 0 0.35rem;
}

.branch-order-modal__empty-text {
    font-size: 0.88rem;
    color: #6b7280;
    margin: 0;
}

.branch-order-modal__footer {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    display: flex;
    justify-content: flex-end;
}

.branch-order-modal__loading {
    text-align: center;
    padding: 2rem 1rem;
    color: #6b7280;
}

.branch-order-modal__spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #f3f4f6;
    border-top-color: #f5a800;
    border-radius: 50%;
    animation: branchOrderSpin 0.7s linear infinite;
    margin: 0 auto 0.65rem;
}

@keyframes branchOrderSpin {
    to { transform: rotate(360deg); }
}

.branch-order-modal .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.branch-order-modal .hidden {
    display: none !important;
}
