/* ============================================
   B2B Management — Stripe / Apple Design System
   ============================================ */

/* --- Reset & Base --- */
.b2b-wrap {
    font-family: inherit;
    color: #1a1a2e;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.b2b-wrap *,
.b2b-wrap *::before,
.b2b-wrap *::after {
    box-sizing: border-box;
}

/* --- Card --- */
.b2b-card {
    background: #fff;
    border-radius: 12px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.03),
        0 2px 8px rgba(0, 0, 0, 0.04),
        0 8px 24px rgba(0, 0, 0, 0.06);
    margin: 0 auto;
}

.b2b-card--narrow {
    max-width: 100%;
}

.b2b-card--wide {
    max-width: 100%;
}

.b2b-card--dashboard {
    max-width: 100%;
}

/* Card Header */
.b2b-card__header {
    padding: 40px 40px 0;
}

.b2b-card__title {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 6px;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.b2b-card__subtitle {
    font-size: 15px;
    color: #8a8f98;
    margin: 0;
    font-weight: 400;
}

.b2b-card__company {
    font-size: 14px;
    font-weight: 600;
    color: #3c4257;
    background: #f7f8fa;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid #f0f2f5;
    white-space: nowrap;
    margin-top: 4px;
}

/* Card Footer */
.b2b-card__footer {
    padding: 24px 40px 36px;
    text-align: center;
    border-top: 1px solid #f0f2f5;
}

.b2b-card__footer p {
    font-size: 14px;
    color: #8a8f98;
    margin: 0;
}

.b2b-card__footer--actions {
    display: flex;
    justify-content: flex-end;
}

/* --- Form --- */
.b2b-form {
    padding: 32px 40px;
}

/* --- Sections --- */
.b2b-section {
    margin-bottom: 32px;
}

.b2b-section:last-of-type {
    margin-bottom: 0;
}

.b2b-section__title {
    font-size: 14px;
    font-weight: 600;
    color: #3c4257;
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f2f5;
    letter-spacing: 0;
    text-transform: none;
}

/* --- Fields --- */
.b2b-field {
    margin-bottom: 20px;
}

.b2b-field:last-child {
    margin-bottom: 0;
}

.b2b-field-group {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.b2b-field-group:last-child {
    margin-bottom: 0;
}

.b2b-field--half {
    flex: 1;
    margin-bottom: 0;
}

.b2b-field--two-thirds {
    flex: 2;
    margin-bottom: 0;
}

.b2b-field--third {
    flex: 1;
    margin-bottom: 0;
}

.b2b-field--row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* --- Labels --- */
.b2b-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #3c4257;
    margin-bottom: 6px;
}

.b2b-required {
    color: #df1b41;
    font-weight: 400;
}

.b2b-hint {
    display: block;
    font-size: 13px;
    color: #8a8f98;
    margin-top: 6px;
}

/* --- Inputs --- */
.b2b-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    font-size: 15px;
    font-family: inherit;
    color: #1a1a2e;
    background: #fff;
    border: 1px solid #e3e8ee;
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    appearance: none;
}

.b2b-input::placeholder {
    color: #a3acb9;
}

.b2b-input:hover {
    border-color: #c4cad4;
}

.b2b-input:focus {
    border-color: #1a1a2e;
    box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.2);
}

.b2b-input[readonly] {
    background: #f7f8fa;
    color: #8a8f98;
    cursor: default;
}

.b2b-input[readonly]:hover,
.b2b-input[readonly]:focus {
    border-color: #e3e8ee;
    box-shadow: none;
}

.b2b-input.b2b-input--error {
    border-color: #df1b41;
    box-shadow: 0 0 0 3px rgba(223, 27, 65, 0.12);
}

/* --- Checkbox --- */
.b2b-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #3c4257;
    cursor: pointer;
}

.b2b-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #1a1a2e;
    border-radius: 4px;
}

/* --- Links --- */
.b2b-link {
    color: #1a1a2e;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s ease;
}

.b2b-link:hover {
    color: #0f0f1a;
}

.b2b-link--bold {
    font-weight: 600;
}

/* --- Buttons --- */
.b2b-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    padding: 0 24px;
    height: 48px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
    text-decoration: none;
    line-height: 1;
}

.b2b-btn--primary {
    width: 100%;
    background: #1a1a2e;
    color: #fff;
    box-shadow:
        0 1px 3px rgba(26, 26, 46, 0.24),
        0 1px 2px rgba(0, 0, 0, 0.08);
}

.b2b-btn--primary:hover {
    background: #0f0f1a;
    box-shadow:
        0 2px 6px rgba(26, 26, 46, 0.32),
        0 2px 4px rgba(0, 0, 0, 0.1);
}

.b2b-btn--primary:active {
    transform: translateY(1px);
    box-shadow:
        0 1px 2px rgba(26, 26, 46, 0.2),
        0 0 1px rgba(0, 0, 0, 0.06);
}

.b2b-btn--primary:disabled {
    background: #6b6b7b;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.b2b-btn--secondary {
    background: #fff;
    color: #3c4257;
    border: 1px solid #e3e8ee;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.b2b-btn--secondary:hover {
    background: #f7f8fa;
    border-color: #c4cad4;
}

.b2b-btn--secondary:active {
    transform: translateY(1px);
}

/* --- Notices --- */
.b2b-notice {
    margin: 0 40px 4px;
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

.b2b-notice:first-child {
    margin-top: 24px;
}

.b2b-notice + .b2b-notice {
    margin-top: 8px;
}

.b2b-notice p {
    margin: 0 0 4px;
}

.b2b-notice p:last-child {
    margin: 0;
}

.b2b-notice--success {
    background: #ecfdf3;
    color: #087443;
}

.b2b-notice--error {
    background: #fef0f4;
    color: #b42650;
}

.b2b-notice--info {
    background: #f0f0ff;
    color: #3d3b8e;
}

/* --- Dashboard Details --- */
.b2b-details {
    background: #f7f8fa;
    border-radius: 8px;
    border: 1px solid #f0f2f5;
}

.b2b-details__row {
    display: flex;
    padding: 14px 20px;
    border-bottom: 1px solid #f0f2f5;
}

.b2b-details__row:last-child {
    border-bottom: none;
}

.b2b-details__label {
    flex: 0 0 160px;
    font-size: 13px;
    color: #8a8f98;
    font-weight: 500;
}

.b2b-details__value {
    flex: 1;
    font-size: 14px;
    color: #1a1a2e;
    font-weight: 500;
}

/* --- Tabs --- */
.b2b-tabs {
    display: flex !important;
    border-bottom: 1px solid #e3e8ee !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    background: none !important;
}

.b2b-tab-btn {
    flex: 1 !important;
    text-align: center !important;
    padding: 18px 24px !important;
    font-family: inherit !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    color: #8a8f98 !important;
    background: none !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    cursor: pointer !important;
    transition: color 0.2s ease, border-color 0.2s ease !important;
    margin: 0 0 -1px 0 !important;
    outline: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1.4 !important;
}

.b2b-tab-btn:hover {
    color: #3c4257 !important;
    background: none !important;
}

.b2b-tab-btn--active {
    color: #1a1a2e !important;
    border-bottom-color: #1a1a2e !important;
    background: none !important;
}

.b2b-tab-panel {
    display: none !important;
}

.b2b-tab-panel--active {
    display: block !important;
}

/* --- Dashboard --- */
.b2b-dashboard-content {
    padding: 32px 40px;
}

.b2b-dashboard-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}

.b2b-stat-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: #f7f8fa;
    border: 1px solid #f0f2f5;
    border-radius: 10px;
}

.b2b-stat-box__number {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.2;
    margin-bottom: 4px;
}

.b2b-stat-box__label {
    font-size: 13px;
    font-weight: 500;
    color: #8a8f98;
}

/* Orders Table */
.b2b-orders-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: #f9fafb;
    border-radius: 8px;
    overflow: hidden;
}

.b2b-orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.b2b-orders-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: #8a8f98;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px 10px;
    border-bottom: 1px solid #eef0f3;
}

.b2b-orders-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #eef0f3;
    color: #3c4257;
    white-space: nowrap;
    background: #fff;
}

.b2b-orders-table td:first-child {
    font-weight: 600;
    color: #1a1a2e;
}

.b2b-orders-table td:last-child {
    text-align: right;
}

.b2b-orders-table th:last-child {
    text-align: right;
}

.b2b-orders-table tbody tr:last-child td {
    border-bottom: none;
}

.b2b-orders-table tbody tr {
    transition: background 0.12s ease;
}

.b2b-orders-table tbody tr:hover td {
    background: #f9fafb;
}

/* Status Badge */
.b2b-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

/* Empty State */
.b2b-empty-state {
    text-align: center;
    padding: 32px 20px;
    color: #8a8f98;
    font-size: 14px;
}

.b2b-empty-state p {
    margin: 0;
}

/* --- View Button --- */
.b2b-btn-view {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 14px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid #e3e8ee;
    background: #fff;
    color: #3c4257;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    line-height: 1;
    white-space: nowrap;
}

.b2b-btn-view:hover {
    background: #f7f8fa;
    border-color: #c4cad4;
}

/* --- Modal --- */
.b2b-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.45);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    padding: 20px;
}

.b2b-modal-overlay--active {
    opacity: 1;
    visibility: visible;
}

.b2b-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.03),
        0 24px 48px rgba(0, 0, 0, 0.12);
    max-width: 520px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(8px);
    transition: transform 0.2s ease;
}

.b2b-modal-overlay--active .b2b-modal {
    transform: translateY(0);
}

.b2b-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px 28px 20px;
    border-bottom: 1px solid #f0f2f5;
}

.b2b-modal__title {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 2px;
    line-height: 1.3;
}

.b2b-modal__date {
    font-size: 13px;
    color: #8a8f98;
}

.b2b-modal__close {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 8px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #8a8f98;
    transition: background 0.15s ease, color 0.15s ease;
    margin: -4px -4px 0 12px;
}

.b2b-modal__close:hover {
    background: #f0f2f5;
    color: #3c4257;
}

.b2b-modal__body {
    padding: 24px 28px 28px;
}

/* Order Meta */
.b2b-order-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.b2b-order-payment {
    font-size: 13px;
    color: #8a8f98;
    font-weight: 500;
}

/* Order Items Table (Modal) */
.b2b-order-items {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    background: #f9fafb;
    border-radius: 8px;
    overflow: hidden;
}

.b2b-order-items th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: #8a8f98;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px 10px;
    border-bottom: 1px solid #eef0f3;
}

.b2b-order-items td {
    padding: 12px 16px;
    border-bottom: 1px solid #eef0f3;
    font-size: 14px;
    color: #3c4257;
    background: #fff;
}

.b2b-order-items td:first-child {
    font-weight: 500;
    color: #1a1a2e;
}

.b2b-order-items tbody tr:last-child td {
    border-bottom: none;
}

.b2b-order-items tbody tr {
    transition: background 0.12s ease;
}

.b2b-order-items tbody tr:hover td {
    background: #f9fafb;
}

/* Order Totals */
.b2b-order-totals {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e3e8ee;
}

.b2b-order-totals__row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 14px;
    color: #8a8f98;
}

.b2b-order-totals__row span:last-child {
    color: #3c4257;
    font-weight: 500;
}

.b2b-order-totals__row--total {
    padding-top: 12px;
    margin-top: 8px;
    border-top: 1px solid #f0f2f5;
    color: #1a1a2e;
    font-weight: 700;
    font-size: 15px;
}

.b2b-order-totals__row--total span:last-child {
    color: #1a1a2e;
    font-weight: 700;
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .b2b-card {
        margin: 16px;
        border-radius: 12px;
    }

    .b2b-card__header {
        padding: 28px 24px 0;
    }

    .b2b-card__title {
        font-size: 24px;
    }

    .b2b-form {
        padding: 24px;
    }

    .b2b-notice {
        margin-left: 24px;
        margin-right: 24px;
    }

    .b2b-card__footer {
        padding: 20px 24px 28px;
    }

    .b2b-field-group {
        flex-direction: column;
        gap: 0;
    }

    .b2b-field--half,
    .b2b-field--two-thirds,
    .b2b-field--third {
        flex: none;
        margin-bottom: 20px;
    }

    .b2b-field-group:last-child .b2b-field--half:last-child,
    .b2b-field-group:last-child .b2b-field--two-thirds:last-child,
    .b2b-field-group:last-child .b2b-field--third:last-child {
        margin-bottom: 0;
    }

    .b2b-details__row {
        flex-direction: column;
        gap: 2px;
    }

    .b2b-details__label {
        flex: none;
    }

    .b2b-tab-btn {
        padding: 14px 16px !important;
        font-size: 14px !important;
    }

    .b2b-section {
        margin-bottom: 28px;
    }

    .b2b-btn {
        height: 44px;
        font-size: 14px;
    }

    .b2b-dashboard-content {
        padding: 24px;
    }

    .b2b-dashboard-stats {
        flex-direction: column;
        gap: 12px;
    }

    .b2b-stat-box__number {
        font-size: 20px;
    }

    .b2b-orders-table th,
    .b2b-orders-table td {
        padding: 10px 8px;
        font-size: 13px;
    }

    .b2b-modal {
        max-width: none;
        border-radius: 12px;
    }

    .b2b-modal__header {
        padding: 20px 20px 16px;
    }

    .b2b-modal__body {
        padding: 20px;
    }
}
