/* SUBandL global widget. Scoped under .sbw so it never touches the host app.
   Dark mode follows the host: html.dark or [data-theme="dark"]. */

.sbw {
    --sbw-bg: #ffffff; --sbw-soft: #f6f7f9; --sbw-text: #1f2430; --sbw-muted: #667085; --sbw-line: #e4e7ec;
    --sbw-primary: #2563eb; --sbw-primary-text: #ffffff;
    --sbw-ok: #15803d; --sbw-ok-bg: #ecfdf3; --sbw-warn: #b45309; --sbw-warn-bg: #fffbeb; --sbw-warn-line: #fcd34d;
    --sbw-bad: #b91c1c; --sbw-bad-bg: #fef2f2; --sbw-info: #1d4ed8; --sbw-info-bg: #eff6ff;
    --sbw-shadow: 0 20px 50px rgba(15, 23, 42, .22);
    font-family: inherit; font-size: 14px; line-height: 1.5; color: var(--sbw-text);
}
html.dark .sbw, [data-theme="dark"] .sbw {
    --sbw-bg: #1b1f27; --sbw-soft: #242934; --sbw-text: #e6e8ec; --sbw-muted: #9aa3b2; --sbw-line: #333a47;
    --sbw-primary: #60a5fa; --sbw-primary-text: #0b1220;
    --sbw-ok: #4ade80; --sbw-ok-bg: rgba(74, 222, 128, .12); --sbw-warn: #fbbf24; --sbw-warn-bg: rgba(251, 191, 36, .1); --sbw-warn-line: rgba(251, 191, 36, .45);
    --sbw-bad: #f87171; --sbw-bad-bg: rgba(248, 113, 113, .12); --sbw-info: #93c5fd; --sbw-info-bg: rgba(96, 165, 250, .14);
    --sbw-shadow: 0 20px 50px rgba(0, 0, 0, .55);
}
.sbw[hidden], .sbw [hidden] { display: none !important; }
.sbw *, .sbw *::before, .sbw *::after { box-sizing: border-box; }

/* Edge tab */
.sbw-tab {
    position: fixed; top: 50%; right: 0; z-index: 10030; transform: translateY(-50%);
    display: flex; align-items: center; justify-content: center; width: 36px; height: 44px;
    border: 1px solid var(--sbw-line); border-right: 0; border-radius: 10px 0 0 10px;
    background: var(--sbw-bg); color: var(--sbw-muted); box-shadow: -2px 4px 14px rgba(15, 23, 42, .12);
    cursor: pointer; transition: width .15s, color .15s;
}
.sbw-tab:hover, .sbw-tab:focus-visible { width: 42px; color: var(--sbw-primary); outline: none; }
.sbw-tab.sbw-attention { color: var(--sbw-warn); }
.sbw-dot { position: absolute; top: 7px; left: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--sbw-bad); box-shadow: 0 0 0 2px var(--sbw-bg); }

/* Offcanvas: 1000px wide, at most 75% of the screen (full width on phones) */
.sbw-backdrop { position: fixed; inset: 0; z-index: 10039; background: rgba(15, 23, 42, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
.sbw-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 10040; width: 1000px; max-width: 75%;
    display: flex; flex-direction: column; background: var(--sbw-soft); box-shadow: var(--sbw-shadow);
    transform: translateX(105%); visibility: hidden;
    transition: transform .25s ease, visibility 0s linear .25s; outline: none;
}
.sbw-open .sbw-backdrop { opacity: 1; pointer-events: auto; }
.sbw-open .sbw-panel { transform: none; visibility: visible; transition: transform .25s ease; }
@media (max-width: 640px) {
    .sbw-panel { max-width: 100%; }
}
html.sbw-noscroll, html.sbw-noscroll body { overflow: hidden !important; }
.sbw-head { flex-shrink: 0; border-bottom: 1px solid var(--sbw-line); background: var(--sbw-bg); }
.sbw-head-in { display: flex; align-items: center; gap: 16px; max-width: 1040px; margin: 0 auto; padding: 0 20px; min-height: 60px; }
.sbw-head h2 { margin: 0; font-size: 17px; font-weight: 700; white-space: nowrap; }
.sbw-tabs { display: flex; gap: 4px; flex: 1; align-self: stretch; overflow-x: auto; }
.sbw-tabbtn {
    position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px;
    border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--sbw-muted);
    font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer;
}
.sbw-tabbtn:hover { color: var(--sbw-text); }
.sbw-tabbtn.sbw-active { color: var(--sbw-primary); border-bottom-color: var(--sbw-primary); }
.sbw-tabbtn:focus-visible { outline: 2px solid var(--sbw-primary); outline-offset: -2px; }
.sbw-pip { width: 7px; height: 7px; border-radius: 50%; background: var(--sbw-bad); }
.sbw-close, .sbw-back { margin-inline-start: auto; }
.sbw-back { white-space: nowrap; }
.sbw-icon { display: inline-flex; padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--sbw-muted); cursor: pointer; }
.sbw-icon:hover { background: var(--sbw-soft); color: var(--sbw-text); }
.sbw-body { flex: 1; overflow-y: auto; }
.sbw-body-in {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; gap: 16px;
    max-width: 1040px; margin: 0 auto; padding: 20px 20px 40px;
}
.sbw-wide { grid-column: 1 / -1; }

@media (max-width: 560px) {
    .sbw-head-in { gap: 8px; padding: 0 8px; }
    .sbw-head h2 { display: none; }
    .sbw-tabbtn { padding: 0 10px; }
    .sbw-body-in { padding: 12px 12px 32px; gap: 12px; }
}

/* Page mode: /subscription/* shows the panel as the page itself */
.sbw-page .sbw-tab, .sbw-page .sbw-close, .sbw-page .sbw-backdrop { display: none; }
.sbw-notab .sbw-tab { display: none; }
.sbw-page .sbw-panel { left: 0; width: auto; max-width: none; box-shadow: none; }

/* Cards */
.sbw-card { border: 1px solid var(--sbw-line); border-radius: 12px; padding: 14px 16px; background: var(--sbw-bg); }
.sbw-card h3 { margin: 0 0 10px; font-size: 14px; font-weight: 700; }
.sbw-card p { margin: 0 0 6px; }
.sbw-warn { border-color: var(--sbw-warn-line); background: var(--sbw-warn-bg); }
.sbw-amount { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 10px; }
.sbw-amount strong { font-size: 22px; font-weight: 800; color: var(--sbw-warn); }
.sbw-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--sbw-muted); }
.sbw-muted { color: var(--sbw-muted); font-size: 12.5px; }
.sbw-kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sbw-kv > span:first-child { color: var(--sbw-muted); }
.sbw-kv small { color: var(--sbw-muted); font-weight: 400; }
.sbw-version-row { display: flex; align-items: center; gap: 6px; }
.sbw-version-sync { padding: 4px; }
.sbw-box { margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: var(--sbw-soft); }
.sbw-box .sbw-label { margin-bottom: 4px; }
.sbw-box p { margin: 0 0 2px; }
.sbw-box ul { margin: 4px 0 0; padding-inline-start: 18px; }
.sbw-pre { white-space: pre-line; }
.sbw-note { font-size: 12.5px; }
.sbw-note.sbw-bad { color: var(--sbw-bad); }
.sbw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 16px; margin-bottom: 4px; }
.sbw-value { font-weight: 600; word-break: break-word; }
.sbw-card a { color: var(--sbw-primary); }

/* Forms */
.sbw-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.sbw-input {
    flex: 1 1 220px; min-width: 0; padding: 8px 12px; border: 1px solid var(--sbw-line); border-radius: 8px;
    background: var(--sbw-bg); color: var(--sbw-text); font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.sbw-input:focus { outline: 2px solid var(--sbw-primary); outline-offset: -1px; border-color: transparent; }
.sbw-check { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; cursor: pointer; }
.sbw-check input { width: 16px; height: 16px; accent-color: var(--sbw-primary); }
.sbw-check:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.sbw-btn:disabled:not([data-sbw="update-run"]) { cursor: not-allowed; }

/* History */
.sbw-table-wrap { overflow-x: auto; }
.sbw-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 13px; }
.sbw-table th, .sbw-table td { padding: 8px 10px; border-bottom: 1px solid var(--sbw-line); text-align: start; vertical-align: top; }
.sbw-table th { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--sbw-muted); }
.sbw-table td:first-child { white-space: nowrap; }

.sbw-badge { display: inline-block; padding: 1px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.sbw-badge.sbw-ok { color: var(--sbw-ok); background: var(--sbw-ok-bg); }
.sbw-badge.sbw-bad { color: var(--sbw-bad); background: var(--sbw-bad-bg); }
.sbw-badge.sbw-warn { color: var(--sbw-warn); background: var(--sbw-warn-bg); }
.sbw-badge.sbw-info, .sbw-badge.sbw-new { color: var(--sbw-info); background: var(--sbw-info-bg); }

.sbw-flash { margin: 0; padding: 9px 12px; border-radius: 10px; font-size: 13px; }
.sbw-flash.sbw-ok { color: var(--sbw-ok); background: var(--sbw-ok-bg); }
.sbw-flash.sbw-bad { color: var(--sbw-bad); background: var(--sbw-bad-bg); }
.sbw-flash.sbw-info { color: var(--sbw-info); background: var(--sbw-info-bg); }

/* Buttons */
.sbw-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.sbw-btn {
    display: inline-flex; align-items: center; justify-content: center; padding: 8px 14px; border-radius: 8px;
    border: 1px solid var(--sbw-primary); background: var(--sbw-primary); color: var(--sbw-primary-text);
    font: inherit; font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.sbw-btn:hover { filter: brightness(1.07); }
.sbw-btn.sbw-ghost { background: transparent; color: var(--sbw-primary); }
.sbw-btn:disabled { opacity: .55; cursor: progress; }
.sbw-btn:focus-visible, .sbw-icon:focus-visible { outline: 2px solid var(--sbw-primary); outline-offset: 2px; }

/* Modals (update + payment): hero header, body, actions */
.sbw-modal { position: fixed; inset: 0; z-index: 10050; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 23, 42, .6); backdrop-filter: blur(3px); animation: sbw-fade .2s ease; }
.sbw-paymodal { z-index: 10049; }
.sbw-modal-card {
    width: min(480px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 0; border-radius: 18px;
    background: var(--sbw-bg); box-shadow: var(--sbw-shadow); animation: sbw-pop .25s cubic-bezier(.2, .9, .3, 1.2);
}
.sbw-modal-card h2 { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.25; }
.sbw-modal-body { padding: 18px 22px 20px; }
.sbw-modal-body > p { margin: 0 0 10px; }
.sbw-hero {
    display: flex; align-items: center; gap: 14px; padding: 22px 22px 18px; color: #fff;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
}
.sbw-hero-locked { background: linear-gradient(135deg, #475569 0%, #7c3aed 100%); }
.sbw-hero-warn { background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%); }
.sbw-hero-danger { background: linear-gradient(135deg, #b91c1c 0%, #ea580c 100%); }
.sbw-hero-icon {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 52px; height: 52px;
    border-radius: 14px; background: rgba(255, 255, 255, .18); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.sbw-hero-kicker { margin: 0 0 2px; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.sbw-versions { margin: 4px 0 0; font-size: 13px; opacity: .92; }
.sbw-versions span { opacity: .8; }
.sbw-versions strong { color: #fff; }
.sbw-news { margin: 4px 0 0; padding-inline-start: 18px; }
.sbw-news li { margin: 2px 0; }
.sbw-assure { list-style: none; margin: 4px 0 6px; padding: 0; display: grid; gap: 6px; }
.sbw-assure li { display: flex; align-items: center; gap: 8px; color: var(--sbw-muted); font-size: 13px; }
.sbw-assure svg { color: var(--sbw-ok); flex-shrink: 0; }
.sbw-btn-lg { padding: 10px 20px; font-size: 14px; }
.sbw-btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* Update stepper */
.sbw-steps { display: flex; gap: 6px; list-style: none; margin: 6px 0 12px; padding: 0; counter-reset: s; }
.sbw-steps li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--sbw-muted); text-align: center; }
.sbw-step-dot {
    display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid var(--sbw-line); background: var(--sbw-bg); font-size: 12px; font-weight: 700;
}
.sbw-step-now { color: var(--sbw-primary); }
.sbw-step-now .sbw-step-dot { border-color: var(--sbw-primary); color: var(--sbw-primary); box-shadow: 0 0 0 4px var(--sbw-info-bg); }
.sbw-step-done { color: var(--sbw-ok); }
.sbw-step-done .sbw-step-dot { border-color: var(--sbw-ok); background: var(--sbw-ok); color: #fff; }
.sbw-progress { position: relative; height: 6px; margin: 0 0 12px; overflow: hidden; border-radius: 99px; background: var(--sbw-soft); }
.sbw-progress span { position: absolute; inset: 0 auto 0 0; width: 40%; border-radius: 99px; background: linear-gradient(90deg, #2563eb, #7c3aed); animation: sbw-slide 1.3s ease-in-out infinite; }

/* Payment: invoices and overdue card */
.sbw-danger { border-color: var(--sbw-bad); background: var(--sbw-bad-bg); }
.sbw-danger .sbw-amount strong { color: var(--sbw-bad); }
.sbw-invoices { display: grid; gap: 6px; margin: 8px 0 10px; }
.sbw-invoice { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border: 1px solid var(--sbw-line); border-radius: 10px; background: var(--sbw-bg); }
.sbw-invoice > div { display: flex; flex-direction: column; }
.sbw-invoice-amt { align-items: flex-end; text-align: end; }
.sbw-invoice-reason { font-size: 12.5px; color: var(--sbw-text); }

/* Late-payment banner: stays until paid */
.sbw-banner {
    position: fixed; left: 50%; bottom: 16px; z-index: 10035; transform: translateX(-50%);
    display: flex; align-items: center; gap: 12px; width: min(760px, calc(100% - 24px)); padding: 10px 12px 10px 14px;
    border: 1px solid var(--sbw-warn-line); border-radius: 14px; background: var(--sbw-warn-bg); color: var(--sbw-text);
    box-shadow: 0 10px 30px rgba(15, 23, 42, .18); animation: sbw-rise .3s ease;
}
.sbw-banner-bad { border-color: var(--sbw-bad); background: var(--sbw-bad-bg); }
.sbw-banner-icon { display: inline-flex; color: var(--sbw-warn); }
.sbw-banner-bad .sbw-banner-icon { color: var(--sbw-bad); }
.sbw-banner-icon svg { width: 22px; height: 22px; }
.sbw-banner-text { flex: 1; font-size: 13px; }
@media (max-width: 560px) {
    .sbw-banner { flex-wrap: wrap; bottom: 8px; }
    .sbw-banner-icon { display: none; }
}

@keyframes sbw-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sbw-pop { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes sbw-rise { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes sbw-slide { 0% { left: -40%; } 100% { left: 100%; } }

/* RTL hosts: dock on the left */
[dir="rtl"] .sbw-tab { right: auto; left: 0; border-right: 1px solid var(--sbw-line); border-left: 0; border-radius: 0 10px 10px 0; }
[dir="rtl"] .sbw-dot { left: auto; right: 7px; }
[dir="rtl"] .sbw-panel { right: auto; left: 0; transform: translateX(-105%); }
[dir="rtl"] .sbw-open .sbw-panel, [dir="rtl"] .sbw-page .sbw-panel { transform: none; }
[dir="rtl"] .sbw-page .sbw-panel { right: 0; }

@media (prefers-reduced-motion: reduce) {
    .sbw-panel, .sbw-open .sbw-panel, .sbw-backdrop, .sbw-tab { transition: none; }
    .sbw-modal, .sbw-modal-card, .sbw-banner { animation: none; }
    .sbw-progress span { animation-duration: 4s; }
}
