/* Extracted from InvoiceEdit.razor (C5) — global styles, behaviour-identical to the former inline <style>. */

    /* ════════════════════════════════════════
       BASE & PAGE
    ════════════════════════════════════════ */
    .id-page {
        max-width: 1300px;
        margin: 0 auto;
        padding: 2rem 1.5rem 3rem;
        font-family: system-ui, -apple-system, sans-serif;
        animation: idPageIn .42s cubic-bezier(.22,.68,0,1.15) both;
    }

    @keyframes idPageIn {
        from { opacity: 0; transform: translateY(16px) }
        to   { opacity: 1; transform: translateY(0) }
    }

    /* ════════════════════════════════════════
       LOADING
    ════════════════════════════════════════ */
    .id-loading {
        display: flex;
        align-items: center;
        gap: 12px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        padding: 1.75rem 2rem;
        color: #64748b;
        font-size: .9rem;
    }

    /* ════════════════════════════════════════
       ALERTS
    ════════════════════════════════════════ */
    .id-alert {
        display: flex;
        align-items: flex-start;
        gap: 8px;
        padding: 11px 16px;
        border-radius: 10px;
        font-size: .875rem;
        margin-bottom: 1.25rem;
        animation: idFadeDown .22s ease both;
        line-height: 1.5;
    }

    .id-alert svg { flex-shrink: 0; margin-top: 1px; }

    @keyframes idFadeDown {
        from { opacity: 0; transform: translateY(-6px) }
        to   { opacity: 1; transform: translateY(0) }
    }

    .id-alert-ok  { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
    .id-alert-err { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }

    /* ════════════════════════════════════════
       HEADER
    ════════════════════════════════════════ */
    .id-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        margin-bottom: 1.25rem;
        flex-wrap: wrap;
        animation: idFadeDown .3s ease both;
        min-width: 0; /* prevent overflow */
    }

    .id-header-left {
        display: flex;
        align-items: center;
        gap: 12px;
        min-width: 0; /* allow truncation */
        flex: 1;
    }

    .id-header-title-block {
        min-width: 0; /* allow text to truncate */
    }

    .id-header-right {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
    }

    .id-back-btn {
        width: 38px;
        height: 38px;
        min-width: 38px; /* prevent shrinking */
        border-radius: 10px;
        border: 1.5px solid #e2e8f0;
        background: #fff;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #64748b;
        transition: border-color .15s, color .15s;
        flex-shrink: 0;
    }

    .id-back-btn:hover { border-color: #2563b0; color: #2563b0; }

    .id-inv-number {
        font-size: 1.35rem;
        font-weight: 800;
        color: #0f172a;
        letter-spacing: -.4px;
        line-height: 1.1;
        /* allow wrapping on very small screens */
        word-break: break-all;
    }

    .id-inv-sub {
        font-size: .8rem;
        color: #94a3b8;
        margin-top: 3px;
        white-space: nowrap;
    }

    .id-cn-ref {
        font-size: .78rem;
        color: #9a3412;
        margin-top: 3px;
        font-weight: 600;
    }

    .id-cn-badge {
        display: inline-flex;
        align-items: center;
        font-size: .72rem;
        font-weight: 700;
        padding: 4px 10px;
        border-radius: 99px;
        background: #fff7ed;
        color: #9a3412;
        border: 1px solid #fed7aa;
        white-space: nowrap;
    }

    /* ════════════════════════════════════════
       BADGES
    ════════════════════════════════════════ */
    .id-badge {
        display: inline-flex;
        align-items: center;
        gap: 5px;
        font-size: .75rem;
        font-weight: 700;
        padding: 5px 12px;
        border-radius: 20px;
        white-space: nowrap;
    }

    .id-badge-dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .id-badge-draft     { background: #f1f5f9; color: #64748b; }
    .id-badge-draft .id-badge-dot { background: #94a3b8; }

    .id-badge-sent      { background: #eff6ff; color: #2563b0; }
    .id-badge-sent .id-badge-dot { background: #2563b0; animation: idBlink 1.8s ease infinite; }

    .id-badge-paid      { background: #f0fdf4; color: #059669; }
    .id-badge-paid .id-badge-dot { background: #059669; }

    .id-badge-cancelled { background: #fef2f2; color: #dc2626; }
    .id-badge-cancelled .id-badge-dot { background: #dc2626; }

    @keyframes idBlink {
        0%, 100% { opacity: 1; transform: scale(1) }
        50%       { opacity: .35; transform: scale(.6) }
    }

    /* ════════════════════════════════════════
       BODY LAYOUT — DESKTOP
    ════════════════════════════════════════ */
    .id-body {
        display: grid;
        grid-template-columns: 1fr 296px;
        gap: 1.25rem;
        align-items: start;
    }

    .id-main {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
        min-width: 0; /* critical: prevents grid blowout */
    }

    .id-side {
        display: flex;
        flex-direction: column;
        gap: 1rem;
        position: sticky;
        top: 1.5rem;
    }

    /* ════════════════════════════════════════
       CARDS
    ════════════════════════════════════════ */
    .id-card {
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 16px;
        overflow: hidden;
        box-shadow: 0 1px 6px rgba(0,0,0,.04);
        animation: idCardIn .38s ease both;
        animation-delay: var(--cd, 0s);
    }

    .id-card:nth-child(1) { --cd: .05s }
    .id-card:nth-child(2) { --cd: .10s }
    .id-card:nth-child(3) { --cd: .15s }

    @keyframes idCardIn {
        from { opacity: 0; transform: translateY(10px) }
        to   { opacity: 1; transform: translateY(0) }
    }

    .id-card-head {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 13px 18px;
        background: #f8fafc;
        border-bottom: 1px solid #f1f5f9;
        font-size: .8125rem;
        font-weight: 700;
        color: #0f172a;
        /* Fix: prevent overflow when add-line button is present */
        flex-wrap: wrap;
        row-gap: 8px;
    }

    .id-card-head svg { color: #2563b0; flex-shrink: 0; }

    /* ════════════════════════════════════════
       META GRID
    ════════════════════════════════════════ */
    .id-meta-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1px;
        background: #f1f5f9;
    }

    .id-meta-item {
        padding: 14px 18px;
        background: #fff;
        min-width: 0; /* prevent content overflow */
    }

    .id-meta-lbl {
        font-size: .72rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .5px;
        color: #94a3b8;
        margin-bottom: 5px;
    }

    .id-meta-val {
        font-size: .875rem;
        font-weight: 600;
        color: #0f172a;
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap; /* allow wrapping for long values */
        min-width: 0;
    }

    .id-meta-avatar {
        width: 26px;
        height: 26px;
        min-width: 26px;
        border-radius: 50%;
        background: #dde8f5;
        color: #2563b0;
        font-size: .72rem;
        font-weight: 800;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .id-meta-client { font-weight: 700; }

    .id-overdue { color: #b45309 !important; }

    .id-overdue-tag {
        font-size: .63rem;
        font-weight: 700;
        text-transform: uppercase;
        background: #fef3c7;
        color: #b45309;
        border: 1px solid #fde68a;
        padding: 1px 6px;
        border-radius: 4px;
        white-space: nowrap;
        animation: idPulse 2s ease infinite;
    }

    @keyframes idPulse {
        0%, 100% { opacity: 1 }
        50%       { opacity: .55 }
    }

    /* ════════════════════════════════════════
       LINES TABLE
    ════════════════════════════════════════ */
    .id-table-scroll {
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch; /* smooth momentum scroll on iOS */
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 transparent;
    }

    /* Scroll hint shadow on right edge when table overflows */
    .id-lines-wrap {
        position: relative;
    }

    .id-table {
        width: 100%;
        border-collapse: collapse;
        min-width: 1380px;
    }

    .id-th {
        padding: 10px 12px;
        text-align: left;
        font-size: .7rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .5px;
        color: #64748b;
        background: #f8fafc;
        border-bottom: 1.5px solid #e8edf2;
        white-space: nowrap;
    }

    .id-th-r { text-align: right; }

    .id-line {
        border-bottom: 1px solid #f1f5f9;
        transition: background .1s;
        animation: idRowIn .32s ease both;
        animation-delay: var(--li, 0s);
    }

    @keyframes idRowIn {
        from { opacity: 0; transform: translateX(-6px) }
        to   { opacity: 1; transform: translateX(0) }
    }

    .id-line:hover { background: #fafbff; }
    .id-line:last-child { border-bottom: none; }
    .id-line-warn { background: #fffbeb !important; }

    .id-td        { padding: 9px 12px; vertical-align: top; }
    .id-td-total  { text-align: right; vertical-align: middle; }
    .id-td-del    { vertical-align: middle; text-align: center; padding: 8px 6px; }
    .id-td-empty  { padding: 2rem; text-align: center; color: #94a3b8; font-size: .875rem; }

    .id-line-total {
        font-weight: 800;
        color: #0f172a;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .id-cell-text {
        font-size: .875rem;
        color: #334155;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* ════════════════════════════════════════
       CELL INPUTS
    ════════════════════════════════════════ */
    .id-cell-input,
    .id-cell-select {
        width: 100%;
        height: 34px;
        padding: 0 8px;
        background: #f8fafc;
        border: 1.5px solid #e2e8f0;
        border-radius: 7px;
        font-size: .8125rem;
        color: #0f172a;
        outline: none;
        font-family: inherit;
        transition: border-color .15s, background .15s, box-shadow .15s;
        appearance: none;
        -webkit-appearance: none;
        box-sizing: border-box;
    }

    .id-cell-input:focus,
    .id-cell-select:focus {
        border-color: #2563b0;
        background: #fff;
        box-shadow: 0 0 0 2.5px rgba(37,99,176,.12);
    }

    .id-cell-input::placeholder { color: #94a3b8; }

    .id-cell-num { text-align: right; }

    .id-price-wrap {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        width: 100%;
    }

    .id-price-cur {
        font-size: .68rem;
        font-weight: 700;
        color: #94a3b8;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .id-cell-select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 8px center;
        padding-right: 24px;
    }

    .id-del-btn {
        width: 32px;
        height: 32px;
        border-radius: 7px;
        background: none;
        border: 1.5px solid #e2e8f0;
        cursor: pointer;
        color: #94a3b8;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: border-color .15s, color .15s, background .15s;
    }

    .id-del-btn:hover {
        border-color: #fca5a5;
        color: #dc2626;
        background: #fef2f2;
    }

    .id-stock-warn {
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: .68rem;
        color: #d97706;
        margin-top: 3px;
        font-weight: 600;
        white-space: nowrap;
    }

    /* Lines footer */
    .id-lines-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 9px 14px;
        border-top: 1px solid #f1f5f9;
        background: #fafbff;
        gap: 8px;
        flex-wrap: wrap;
    }

    .id-add-ghost {
        background: none;
        border: none;
        cursor: pointer;
        font-size: .8rem;
        font-weight: 700;
        color: #2563b0;
        display: flex;
        align-items: center;
        gap: 5px;
        transition: opacity .15s;
        padding: 4px 0;
        min-height: 44px; /* touch target */
    }

    .id-add-ghost:hover { opacity: .72; }

    .id-line-count {
        font-size: .75rem;
        color: #94a3b8;
    }

    /* Add line button in card head */
    .id-add-line-btn {
        margin-left: auto;
        height: 30px;
        padding: 0 12px;
        background: #2563b0;
        color: #fff;
        border: none;
        border-radius: 7px;
        font-size: .78rem;
        font-weight: 700;
        font-family: inherit;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        gap: 5px;
        box-shadow: 0 2px 8px rgba(37,99,176,.22);
        transition: background .15s, transform .1s;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .id-add-line-btn:hover { background: #1d50a0; transform: translateY(-1px); }

    /* ════════════════════════════════════════
       COMPANY CARD
    ════════════════════════════════════════ */
    .id-company-body { padding: 14px 18px; }

    .id-company-name {
        font-size: .9375rem;
        font-weight: 700;
        color: #0f172a;
        margin-bottom: 4px;
    }

    .id-company-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px 16px;
        font-size: .8rem;
        color: #64748b;
        margin-bottom: 4px;
    }

    .id-company-row span {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    /* ════════════════════════════════════════
       TOTALS CARD
    ════════════════════════════════════════ */
    .id-totals-card {
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        overflow: hidden;
        box-shadow: 0 1px 5px rgba(0,0,0,.04);
        animation: idCardIn .4s .05s ease both;
    }

    .id-totals-head {
        padding: 12px 16px;
        font-size: .8125rem;
        font-weight: 700;
        color: #0f172a;
        background: #f8fafc;
        border-bottom: 1px solid #e2e8f0;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .id-totals-head svg { color: #2563b0; }

    .id-totals-body {
        padding: 14px 16px;
        display: flex;
        flex-direction: column;
        gap: 9px;
    }

    .id-totals-row {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        font-size: .875rem;
        color: #475569;
        gap: 8px;
    }

    .id-totals-row span:last-child {
        font-weight: 600;
        color: #0f172a;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    .id-totals-divider { height: 1px; background: #f1f5f9; margin: 2px 0; }

    .id-totals-grand {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        font-size: 1rem;
        gap: 8px;
    }

    .id-totals-grand span { font-weight: 600; color: #0f172a; }

    .id-totals-grand strong {
        font-size: 1.2rem;
        font-weight: 800;
        color: #2563b0;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    /* ════════════════════════════════════════
       ACTION BUTTONS
    ════════════════════════════════════════ */
    .id-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        animation: idCardIn .4s .10s ease both;
    }

    .id-pdf-options {
        border: 1.5px solid #e2e8f0;
        border-radius: 10px;
        background: #f8fafc;
        padding: 10px 12px;
    }

    .id-stamp-label {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-size: .8rem;
        color: #334155;
        margin: 0;
        cursor: pointer;
    }

    /* Shared button base */
    .id-btn-back,
    .id-btn-draft,
    .id-btn-send,
    .id-btn-paid,
    .id-btn-cancel-inv {
        width: 100%;
        border-radius: 10px;
        font-family: inherit;
        font-weight: 700;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
        transition: background .15s, color .15s, transform .12s, box-shadow .15s, border-color .15s;
        min-height: 42px; /* accessible touch target */
        font-size: .875rem;
        padding: 0 16px;
    }

    .id-btn-back {
        border: 1.5px solid #e2e8f0;
        background: #fff;
        color: #64748b;
    }
    .id-btn-back:hover { background: #f8fafc; color: #0f172a; }

    .id-btn-draft {
        border: 1.5px solid #2563b0;
        background: transparent;
        color: #2563b0;
    }
    .id-btn-draft:hover:not(:disabled) { background: #f0f6ff; }
    .id-btn-draft:disabled { opacity: .4; cursor: not-allowed; }

    .id-btn-send {
        background: #2563b0;
        color: #fff;
        border: none;
        font-size: .9375rem;
        font-weight: 800;
        min-height: 44px;
        box-shadow: 0 4px 14px rgba(37,99,176,.3);
    }
    .id-btn-send:hover:not(:disabled) { background: #1d50a0; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,176,.38); }
    .id-btn-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }

    .id-btn-paid {
        background: #059669;
        color: #fff;
        border: none;
        font-size: .9375rem;
        font-weight: 800;
        min-height: 44px;
        box-shadow: 0 4px 14px rgba(5,150,105,.28);
    }
    .id-btn-paid:hover:not(:disabled) { background: #047857; transform: translateY(-1px); }
    .id-btn-paid:disabled { opacity: .4; cursor: not-allowed; }

    .id-btn-cancel-inv {
        border: 1.5px solid #fca5a5;
        background: #fef2f2;
        color: #dc2626;
        min-height: 40px;
    }
    .id-btn-cancel-inv:hover:not(:disabled) { background: #fee2e2; }
    .id-btn-cancel-inv:disabled { opacity: .4; cursor: not-allowed; }

    /* ════════════════════════════════════════
       STATUS TIMELINE
    ════════════════════════════════════════ */
    .id-timeline-card {
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        overflow: hidden;
        animation: idCardIn .4s .18s ease both;
    }

    .id-timeline-head {
        padding: 12px 16px;
        font-size: .75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .6px;
        color: #94a3b8;
        background: #f8fafc;
        border-bottom: 1px solid #f1f5f9;
    }

    .id-timeline {
        padding: 16px;
        display: flex;
        flex-direction: column;
    }

    .id-tl-item {
        display: flex;
        align-items: flex-start;
        gap: 12px;
        position: relative;
        padding-bottom: 16px;
    }

    .id-tl-item:last-child { padding-bottom: 0; }

    .id-tl-item::before {
        content: '';
        position: absolute;
        left: 11px;
        top: 22px;
        bottom: 0;
        width: 1.5px;
        background: #e2e8f0;
    }

    .id-tl-item:last-child::before { display: none; }

    .id-tl-dot {
        width: 24px;
        height: 24px;
        min-width: 24px;
        border-radius: 50%;
        flex-shrink: 0;
        border: 2px solid #e2e8f0;
        background: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 1;
        transition: all .2s;
    }

    .id-tl-done .id-tl-dot      { background: #2563b0; border-color: #2563b0; color: #fff; }
    .id-tl-paid .id-tl-dot      { background: #059669; border-color: #059669; color: #fff; }
    .id-tl-cancelled .id-tl-dot { background: #dc2626; border-color: #dc2626; color: #fff; }
    .id-tl-pending .id-tl-dot   { background: #f8fafc; border-color: #e2e8f0; }
    .id-tl-done::before          { background: #2563b0; opacity: .35; }

    .id-tl-label { font-size: .8125rem; font-weight: 700; color: #334155; margin-bottom: 1px; }
    .id-tl-date  { font-size: .75rem; color: #94a3b8; }

    /* ════════════════════════════════════════
       SPINNERS
    ════════════════════════════════════════ */
    .id-spinner {
        width: 16px;
        height: 16px;
        border: 2px solid rgba(255,255,255,.35);
        border-top-color: #fff;
        border-radius: 50%;
        animation: idSpin .7s linear infinite;
        display: inline-block;
        flex-shrink: 0;
    }

    .id-spinner-outline { border-color: rgba(37,99,176,.25); border-top-color: #2563b0; }
    .id-spinner-green   { border-color: rgba(5,150,105,.25); border-top-color: #059669; }
    .id-spinner-red     { border-color: rgba(220,38,38,.25); border-top-color: #dc2626; }

    @keyframes idSpin { to { transform: rotate(360deg) } }

    /* ════════════════════════════════════════
       MOBILE STICKY ACTION BAR
       Hidden on desktop, shown on mobile
    ════════════════════════════════════════ */
    .id-mobile-bar {
        display: none; /* hidden on desktop */
    }

    /* ════════════════════════════════════════
       RESPONSIVE — TABLET (≤ 1080px)
    ════════════════════════════════════════ */
    @media (max-width: 1080px) {
        .id-body {
            grid-template-columns: 1fr;
        }

        .id-side {
            position: static; /* unstick on tablet/mobile */
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 1rem;
        }

        .id-totals-card { grid-column: 1 / -1; }

        .id-actions {
            flex-direction: row;
            flex-wrap: wrap;
        }

        .id-actions .id-btn-back,
        .id-actions .id-btn-draft,
        .id-actions .id-btn-send,
        .id-actions .id-btn-paid,
        .id-actions .id-btn-cancel-inv {
            width: auto;
            flex: 1 1 auto;
            min-width: 120px;
        }

        .id-timeline-card { grid-column: 1 / -1; }
    }

    /* ════════════════════════════════════════
       RESPONSIVE — LARGE PHONE (≤ 768px)
    ════════════════════════════════════════ */
    @media (max-width: 768px) {
        .id-page {
            padding: 1rem 1rem 6rem; /* bottom padding for sticky bar */
        }

        .id-header {
            flex-direction: column;
            align-items: flex-start;
        }

        .id-header-left,
        .id-header-right {
            width: 100%;
            min-width: 0;
        }

        .id-header-right {
            justify-content: flex-start;
            flex-wrap: wrap;
        }

        .id-inv-number {
            word-break: break-word;
        }

        /* Header */
        .id-inv-number { font-size: 1.15rem; }
        .id-inv-sub    { font-size: .75rem; }

        /* Meta grid: 2 cols still works, collapse at 640 */
        .id-meta-item { padding: 12px 14px; }

        /* Side: collapse to single column */
        .id-side {
            grid-template-columns: 1fr;
        }

        .id-totals-card { grid-column: 1; }
        .id-timeline-card { grid-column: 1; }

        /* Hide the sidebar actions panel — use mobile bar instead */
        .id-actions { display: none; }

        /* Show mobile sticky bar */
        .id-mobile-bar {
            display: flex;
            align-items: center;
            gap: 8px;
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            z-index: 200;
            background: rgba(255,255,255,0.95);
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            border-top: 1px solid #e2e8f0;
            padding: 10px 16px;
            padding-bottom: max(10px, env(safe-area-inset-bottom));
            box-shadow: 0 -4px 20px rgba(0,0,0,.08);
        }

        .id-mb-btn {
            flex: 1;
            height: 44px;
            min-height: 44px;
            border-radius: 10px;
            font-size: .8rem;
            padding: 0 10px;
            gap: 5px;
            /* override width:100% from base */
            width: auto !important;
        }

        /* Give the primary action more space */
        .id-mb-primary {
            flex: 2;
        }

        /* Totals: horizontal on phone */
        .id-totals-body { gap: 7px; }
        .id-totals-row  { font-size: .82rem; }
        .id-totals-grand strong { font-size: 1.1rem; }

        /* Table scroll hint */
        .id-table-scroll::after {
            content: '';
            display: block;
            position: sticky;
            right: 0;
            top: 0;
            bottom: 0;
            width: 24px;
            background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
            pointer-events: none;
        }

        .id-table {
            min-width: 860px;
        }

        .id-td {
            padding-top: 7px;
        }

        .id-td::before {
            content: attr(data-label);
            display: block;
            font-size: .62rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: .05em;
            color: #94a3b8;
            margin-bottom: 4px;
            white-space: nowrap;
        }

        .id-td-del::before { content: ''; display: none; }
        .id-td-total { vertical-align: top; }
        .id-td-total .id-line-total { display: inline-block; margin-top: 2px; }

        .id-cell-input,
        .id-cell-select {
            min-width: 120px;
        }
    }

    /* ════════════════════════════════════════
       RESPONSIVE — SMALL PHONE (≤ 640px)
    ════════════════════════════════════════ */
    @media (max-width: 640px) {
        /* Meta grid: single column */
        .id-meta-grid {
            grid-template-columns: 1fr;
        }

        .id-page {
            overflow-x: hidden;
        }

        /* Tighter card header */
        .id-card-head {
            padding: 11px 14px;
            font-size: .78rem;
        }

        .id-add-line-btn {
            font-size: .72rem;
            padding: 0 10px;
            height: 28px;
        }

        /* Company card */
        .id-company-row {
            gap: 6px 12px;
            font-size: .77rem;
        }

        /* Alert text */
        .id-alert { font-size: .82rem; padding: 10px 13px; }

        /* Header tighter */
        .id-header { margin-bottom: 1rem; gap: 8px; }
        .id-back-btn { width: 34px; height: 34px; min-width: 34px; }
        .id-inv-number { font-size: 1rem; }
        .id-badge { font-size: .7rem; padding: 4px 9px; }

        /* Mobile bar: smaller gap */
        .id-mobile-bar { gap: 6px; padding: 8px 12px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
        .id-mb-btn { font-size: .75rem; padding: 0 8px; }

        /* Lines footer */
        .id-lines-footer { padding: 8px 12px; }
        .id-add-ghost    { font-size: .77rem; }

        .id-table {
            min-width: 620px;
        }
    }

    /* ════════════════════════════════════════
       RESPONSIVE — VERY SMALL (≤ 380px)
    ════════════════════════════════════════ */
    @media (max-width: 380px) {
        .id-page { padding: 0.75rem 0.75rem 5.5rem; }
        .id-inv-number { font-size: .95rem; }
        .id-inv-sub { display: none; }
        .id-meta-item { padding: 10px 12px; }
        .id-meta-lbl { font-size: .68rem; }
        .id-meta-val { font-size: .82rem; }
    }

    /* ── TEIF panel ─────────────────────────────────── */
    .id-teif-panel { border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; margin-top: 12px; }
    .id-teif-toggle { width: 100%; display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: #f8fafc; border: none; cursor: pointer; font-size: .85rem; font-weight: 600; color: #334155; }
    .id-teif-toggle:hover { background: #f1f5f9; }
    .id-teif-title { display: flex; align-items: center; gap: 6px; flex: 1; }
    .id-teif-chevron { transition: transform .2s; color: #64748b; }
    .id-teif-chevron.open { transform: rotate(180deg); }
    .id-teif-body { padding: 14px; background: #fff; border-top: 1px solid #e2e8f0; }
    .id-teif-hint { font-size: .82rem; color: #64748b; margin: 0 0 12px; }
    .id-teif-info { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
    .id-teif-row { display: flex; justify-content: space-between; font-size: .82rem; }
    .id-teif-row span:first-child { color: #64748b; }
    .id-teif-cert { font-size: .75rem; color: #475569; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .id-teif-error { background: #fef2f2; color: #b91c1c; border-radius: 6px; padding: 8px 10px; font-size: .8rem; margin-bottom: 10px; }
    .id-teif-log { border-top: 1px solid #f1f5f9; padding-top: 8px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
    .id-teif-log-row { display: flex; gap: 8px; font-size: .78rem; color: #475569; }
    .id-teif-log-time { color: #94a3b8; min-width: 40px; }
    .id-teif-log-msg { color: #64748b; }
    .id-teif-actions { display: flex; gap: 8px; flex-wrap: wrap; }
    .id-teif-btn { padding: 6px 12px; border-radius: 6px; border: 1px solid #e2e8f0; background: #f8fafc; color: #334155; font-size: .82rem; font-weight: 500; cursor: pointer; display: flex; align-items: center; gap: 5px; }
    .id-teif-btn:hover:not(:disabled) { background: #f1f5f9; }
    .id-teif-btn:disabled { opacity: .5; cursor: not-allowed; }
    .id-teif-btn--primary { background: #2563eb; color: #fff; border-color: #2563eb; }
    .id-teif-btn--primary:hover:not(:disabled) { background: #1d4ed8; }
    .id-teif-badge { padding: 2px 8px; border-radius: 99px; font-size: .72rem; font-weight: 600; }
    .id-teif-badge--success { background: #dcfce7; color: #15803d; }
    .id-teif-badge--info { background: #dbeafe; color: #1d4ed8; }
    .id-teif-badge--error { background: #fef2f2; color: #b91c1c; }
    .id-teif-badge--neutral { background: #f1f5f9; color: #475569; }
    .id-spinner-sm { width: 12px; height: 12px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
