:root {
    --shell-sidebar: 304px;
    --shell-bg: #f4f7f8;
    --shell-surface: #ffffff;
    --shell-ink: #142033;
    --shell-muted: #64748b;
    --shell-line: #dfe7ee;
    --shell-primary: #0f7a45;
    --shell-primary-2: #155e75;
    --shell-accent: #b45309;
    --shell-rose: #be123c;
    --shell-shadow: 0 16px 38px rgba(20, 32, 51, .08);
}

body {
    background: linear-gradient(180deg, #eef5f2 0, #f6f8fb 320px, #f7f9fb 100%);
    color: var(--shell-ink);
}

.app-layout {
    display: block;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--shell-sidebar);
    padding: 16px 14px;
    border-left: 1px solid rgba(223, 231, 238, .9);
    background: linear-gradient(180deg, rgba(255, 255, 255, .97), rgba(249, 252, 253, .97));
    box-shadow: -14px 0 42px rgba(20, 32, 51, .06);
    backdrop-filter: blur(18px);
    display: block;
    overflow: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 6px 16px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--shell-line);
}

.sidebar-brand .brand {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-width: 0;
    margin: 0;
    color: var(--shell-ink);
}

.sidebar-brand .brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--shell-primary), var(--shell-primary-2));
    color: #fff;
    display: grid;
    place-items: center;
}

.sidebar-brand strong,
.sidebar-brand small {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-brand strong {
    font-weight: 900;
}

.sidebar-brand small {
    color: var(--shell-muted);
    font-size: .78rem;
}

.sidebar-close,
.sidebar-toggle,
.sidebar-backdrop {
    display: none;
}

.sidebar-nav {
    gap: 16px;
    padding: 8px 2px;
}

.nav-section {
    display: grid;
    gap: 6px;
}

.nav-section h2 {
    margin: 0;
    padding: 0 10px;
    color: #6f7c8f;
    font-size: .72rem;
    line-height: 1.7;
    font-weight: 900;
}

.nav-section-links {
    display: grid;
    gap: 4px;
}

.sidebar-nav a {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #3c485b;
    font-size: .91rem;
    font-weight: 800;
}

.sidebar-nav a i {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #f1f5f7;
    color: #607086;
}

.sidebar-nav a span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-nav a:hover {
    border-color: #cfe0e8;
    background: #f8fbfd;
    color: var(--shell-primary-2);
}

.sidebar-nav a.active,
.sidebar-nav a[aria-current="page"] {
    border-color: rgba(15, 122, 69, .22);
    background: #edf7f1;
    color: var(--shell-primary);
}

.sidebar-nav a.active i,
.sidebar-nav a[aria-current="page"] i {
    background: #dff3e8;
    color: var(--shell-primary);
}

.sidebar-footer {
    position: static;
    width: 100%;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--shell-line);
    background: linear-gradient(180deg, rgba(255, 255, 255, .86), #fff);
}

.sidebar-footer .logout-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    margin: 0;
    border: 1px solid #ffd4d9;
    border-radius: 8px;
    background: #fff5f6;
    color: var(--shell-rose) !important;
    font-weight: 900;
}

.main-content {
    width: calc(100% - var(--shell-sidebar));
    margin-right: var(--shell-sidebar);
    min-height: 100vh;
}

.smart-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    min-height: 78px;
    padding: 12px 24px;
    border-bottom: 1px solid rgba(223, 231, 238, .9);
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(18px);
    display: grid;
    grid-template-columns: minmax(220px, .75fr) minmax(320px, 1.1fr) auto;
    gap: 14px;
    align-items: center;
}

.topbar-context {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-width: 0;
}

.workspace-home,
.sidebar-toggle,
.sidebar-close,
.topbar-tool,
.topbar-alert-menu summary {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--shell-line);
    border-radius: 8px;
    background: #fff;
    color: #405168;
}

.workspace-home:hover,
.sidebar-toggle:hover,
.sidebar-close:hover,
.topbar-tool:hover,
.topbar-alert-menu summary:hover {
    border-color: #c7d8e2;
    color: var(--shell-primary-2);
}

.sidebar-toggle,
.sidebar-close {
    display: none;
}

.topbar-context span,
.topbar-context strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-context span {
    color: var(--shell-ink);
    font-weight: 950;
    font-size: 1.05rem;
}

.topbar-context strong {
    color: var(--shell-muted);
    font-size: .82rem;
}

.topbar-quick-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.topbar-quick-actions a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid var(--shell-line);
    border-radius: 8px;
    background: #fff;
    color: #405168;
    font-size: .86rem;
    font-weight: 900;
    white-space: nowrap;
}

.topbar-quick-actions a:hover,
.topbar-quick-actions a.is-active {
    border-color: rgba(15, 122, 69, .26);
    background: #edf7f1;
    color: var(--shell-primary);
}

.topbar-tools {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.topbar-tool {
    width: auto;
    min-width: 44px;
    padding: 0 11px;
    gap: 0px;
    font-size: .84rem;
    font-weight: 900;
}

.topbar-alert-menu {
    position: relative;
}

.topbar-alert-menu summary {
    position: relative;
    list-style: none;
    cursor: pointer;
}

.topbar-alert-menu summary::-webkit-details-marker {
    display: none;
}

.topbar-alert-menu summary span {
    position: absolute;
    top: -6px;
    left: -6px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--shell-rose);
    color: #fff;
    font-size: .68rem;
    font-weight: 900;
}

.topbar-alert-panel {
    position: absolute;
    top: 52px;
    left: 0;
    width: min(320px, calc(100vw - 32px));
    padding: 10px;
    border: 1px solid var(--shell-line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shell-shadow);
    display: grid;
    gap: 8px;
}

.topbar-alert-panel a,
.empty-alerts {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    background: #f8fbfd;
    color: var(--shell-ink);
}

.topbar-alert-panel em {
    font-style: normal;
    color: var(--shell-primary);
    font-weight: 900;
}

.page {
    width: min(100%, 1480px);
    margin: 0 auto;
    padding: 26px;
}

.page-title {
    margin-bottom: 18px;
    padding: 18px 20px;
    border: 1px solid var(--shell-line);
    border-radius: 8px;
    background: linear-gradient(135deg, #fff, #f7fbfd);
    box-shadow: 0 10px 26px rgba(20, 32, 51, .04);
}

.page-title h1 {
    margin: 0 0 6px;
    color: var(--shell-ink);
    font-size: clamp(1.35rem, 2.5vw, 2rem);
    font-weight: 950;
}

.page-title p {
    color: var(--shell-muted);
    line-height: 1.8;
}

.card-box,
.card,
.checkout-panel,
.billing-stat-card,
.payment-stage-card,
.pricing-card,
.report-nav-card,
.action-summary-card,
.action-queue-card,
.notification-item,
.review-action-panel {
    border-radius: 8px !important;
    border-color: var(--shell-line) !important;
    box-shadow: 0 12px 30px rgba(20, 32, 51, .055) !important;
}

.stat-card,
.billing-stat-card {
    min-height: 112px;
    background: linear-gradient(180deg, #fff, #f9fcfd);
}

.stat-number,
.billing-stat-card strong {
    color: var(--shell-ink);
    font-weight: 950;
}

.btn,
.form-control,
.form-select,
.input-group-text,
.badge,
.alert,
.dropdown-menu {
    border-radius: 8px !important;
}

.btn {
    font-weight: 850;
}

.table {
    --bs-table-bg: transparent;
}

.table thead th {
    color: #536176;
    font-size: .82rem;
    font-weight: 900;
}

.table tbody tr {
    border-color: #eef2f5;
}

.table tbody td {
    color: #27364b;
}

.smart-table-toolbar,
.assistant-companion,
.floating-assistant,
.assistant-panel,
.guided-tour-popover {
    border-radius: 8px !important;
}

.visitor-page,
.pricing-page,
.checkout-page {
    background: linear-gradient(180deg, #eef5f2 0, #f8fafc 46%, #fff7ed 100%);
}

.visitor-shell,
.pricing-shell {
    width: min(1500px, calc(100% - 34px));
}

.visitor-nav,
.pricing-nav {
    border-radius: 8px !important;
    border: 1px solid rgba(223, 231, 238, .9) !important;
    background: rgba(255, 255, 255, .9) !important;
    box-shadow: 0 14px 38px rgba(20, 32, 51, .08) !important;
}

.studio-home,
.pricing-hero,
.checkout-hero,
.studio-workbench,
.visitor-form-card,
.draft-panel,
.pricing-explain,
.pricing-launch-note,
.pricing-lead {
    border-radius: 8px !important;
}

.studio-copy h1,
.pricing-hero h1,
.checkout-hero h1 {
    font-weight: 950;
    line-height: 1.15;
}

.studio-copy p,
.pricing-hero p,
.checkout-hero p {
    line-height: 1.9;
}

.primary-button,
.outline-button,
.ghost-button,
.pricing-cta,
.pricing-limits span,
.checkout-result-card,
.invoice-meta-grid div,
.payment-provider-state div,
.payment-history-item,
.gateway-choice {
    border-radius: 8px !important;
}

@media (max-width: 1240px) {
    .smart-topbar {
        grid-template-columns: minmax(220px, 1fr) auto;
    }

    .topbar-quick-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
        order: 3;
    }
}

@media (max-width: 1320px) {
    .topbar-quick-actions a span {
        display: none;
    }

    .topbar-quick-actions a {
        min-width: 44px;
        justify-content: center;
        padding: 8px;
    }
}

@media (max-width: 992px) {
    .sidebar-toggle,
    .sidebar-close {
        display: inline-grid;
    }

    .topbar-context {
        grid-template-columns: 44px 44px minmax(0, 1fr);
    }

    .app-sidebar {
        right: calc(-1 * (var(--shell-sidebar) + 48px));
        left: auto;
        transform: none !important;
        transition: none;
        z-index: 60;
    }

    body.sidebar-open .sidebar.app-sidebar,
    body.sidebar-open .app-sidebar {
        right: 0 !important;
        transform: none !important;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 50;
        border: 0;
        background: rgba(15, 23, 42, .35);
    }

    body.sidebar-open .sidebar-backdrop {
        display: block !important;
    }

    .main-content {
        width: 100%;
        margin-right: 0;
    }

    .smart-topbar {
        grid-template-columns: 1fr auto;
        padding: 12px;
    }

    .topbar-quick-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
        overflow-x: auto;
    }

    .topbar-tools {
        justify-content: flex-end;
    }

    .topbar-tool span {
        display: none;
    }

    .page {
        padding: 14px;
    }
}

@media (max-width: 700px) {
    .app-sidebar {
        width: min(88vw, 320px);
    }

    .sidebar-footer {
        width: 100%;
    }

    .page-title {
        padding: 14px;
    }

    .topbar-quick-actions a span {
        display: none;
    }

    .topbar-quick-actions a {
        min-width: 44px;
        justify-content: center;
        padding: 8px;
    }

    .smart-topbar {
        gap: 8px;
    }

    .visitor-shell,
    .pricing-shell {
        width: min(100% - 22px, 560px);
    }
}

@media (max-width: 992px) {
    html body:not(.sidebar-open) .app-layout > .sidebar.app-sidebar {
        right: calc(-1 * (var(--shell-sidebar) + 48px)) !important;
        transform: none !important;
    }

    html body.sidebar-open .app-layout > .sidebar.app-sidebar {
        right: 0 !important;
        transform: none !important;
    }
}

.section-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.section-head-row h2,
.section-head-row h3,
.section-head-row h4,
.section-head-row h5 {
    margin: 0;
    color: #172033;
    font-weight: 950;
}

.section-head-row p {
    margin: 4px 0 0;
    color: #6b7280;
}

.smart-filter-card {
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, .95), rgba(246, 250, 248, .96)),
        #fff;
    box-shadow: 0 18px 46px rgba(20, 32, 51, .08);
}

.insight-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.insight-tile {
    min-height: 104px;
    padding: 16px;
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(20, 32, 51, .07);
}

.insight-tile span {
    display: block;
    color: #64748b;
    font-weight: 850;
    font-size: .82rem;
}

.insight-tile strong {
    display: block;
    margin-top: 8px;
    color: #172033;
    font-size: 1.7rem;
    line-height: 1.1;
    font-weight: 950;
}

.insight-tile em {
    display: block;
    margin-top: 6px;
    color: #7c8798;
    font-style: normal;
    font-size: .82rem;
}

.smart-table-wrap {
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.smart-table-wrap .table {
    margin: 0;
}

.smart-table-wrap .table thead th {
    background: #f8fafc;
    white-space: nowrap;
}

.smart-table-wrap .table tbody tr:hover {
    background: #fbfdfc;
}

.quality-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 58px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef9f2;
    color: #166534;
    font-size: .78rem;
    font-weight: 950;
}

.quality-chip.is-low {
    background: #fff7ed;
    color: #b45309;
}

.quality-chip.is-empty {
    background: #f1f5f9;
    color: #64748b;
}

.responsive-record-list {
    display: grid;
    gap: 12px;
}

.record-card {
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 8px;
    background: #fff;
    padding: 14px;
    box-shadow: 0 14px 34px rgba(20, 32, 51, .07);
}

.record-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.record-card h3 {
    margin: 0;
    color: #172033;
    font-size: 1rem;
    font-weight: 950;
}

.record-card small,
.record-meta {
    color: #64748b;
    font-size: .82rem;
}

.record-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.record-meta-grid div {
    padding: 10px;
    border-radius: 8px;
    background: #f8fafc;
}

.record-meta-grid span {
    display: block;
    color: #64748b;
    font-size: .75rem;
    font-weight: 850;
}

.record-meta-grid strong {
    display: block;
    margin-top: 3px;
    color: #172033;
    font-size: .88rem;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 260px;
    padding: 28px;
    border: 1px dashed rgba(148, 163, 184, .8);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(240, 253, 244, .7), rgba(255, 247, 237, .55)),
        #fff;
    text-align: center;
}

.empty-state.compact {
    min-height: 150px;
    padding: 20px;
}

.empty-state i {
    display: inline-grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: #ecfdf3;
    color: #168a55;
    font-size: 1.5rem;
}

.empty-state h3,
.empty-state h4 {
    margin: 0;
    color: #172033;
    font-weight: 950;
}

.empty-state p {
    max-width: 620px;
    margin: 8px auto 0;
    color: #64748b;
    line-height: 1.8;
}

.subscription-workspace .subscription-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr);
    gap: 18px;
    align-items: stretch;
    margin-bottom: 18px;
}

.subscription-panel {
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 8px;
    background: #fff;
    padding: 20px;
    box-shadow: 0 18px 46px rgba(20, 32, 51, .08);
}

.subscription-date-grid,
.subscription-limit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.subscription-date-grid div,
.subscription-limit-grid div {
    padding: 12px;
    border-radius: 8px;
    background: #f8fafc;
}

.subscription-date-grid span,
.subscription-limit-grid span {
    display: block;
    color: #64748b;
    font-size: .76rem;
    font-weight: 850;
}

.subscription-date-grid strong,
.subscription-limit-grid strong {
    display: block;
    margin-top: 4px;
    color: #172033;
    font-weight: 950;
}

.feature-pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.feature-pill-list span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 999px;
    background: #eef9f2;
    color: #166534;
    font-size: .82rem;
    font-weight: 850;
}

.payment-stage-actions form + button[disabled] {
    display: none !important;
}

@media (max-width: 992px) {
    .subscription-workspace .subscription-hero {
        grid-template-columns: 1fr;
    }

    .desktop-table-only {
        display: none !important;
    }
}

@media (min-width: 993px) {
    .mobile-records-only {
        display: none !important;
    }
}

@media (max-width: 760px) {
    .insight-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .record-meta-grid {
        grid-template-columns: 1fr;
    }

    .smart-table-wrap .table,
    .smart-table-wrap thead,
    .smart-table-wrap tbody,
    .smart-table-wrap th,
    .smart-table-wrap td,
    .smart-table-wrap tr {
        display: block;
    }

    .smart-table-wrap thead {
        display: none;
    }

    .smart-table-wrap tr {
        padding: 12px;
        border-bottom: 1px solid #eef2f5;
    }

    .smart-table-wrap td {
        display: flex;
        justify-content: space-between;
        gap: 16px;
        padding: 8px 0;
        border: 0;
        text-align: start !important;
        white-space: normal !important;
    }

    .smart-table-wrap td::before {
        content: attr(data-label);
        color: #64748b;
        font-weight: 900;
    }
}
