/* Inventory SaaS — Theme Package 7
   Billing, subscriptions, system health, platform administration
*/

.admin-page {
    max-width: 1500px;
    margin: 0 auto;
}

.admin-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.admin-page-title {
    margin: 0;
    font-size: 26px;
    font-weight: 850;
    letter-spacing: -.035em;
}

.admin-page-subtitle {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.admin-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* SaaS summary */
.saas-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.saas-summary-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.saas-summary-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.saas-summary-value {
    margin-top: 7px;
    color: var(--text);
    font-size: 27px;
    line-height: 1;
    font-weight: 900;
    letter-spacing: -.04em;
}

.saas-summary-meta {
    margin-top: 8px;
    color: var(--muted);
    font-size: 11px;
}

/* Billing overview */
.billing-overview {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
    gap: 16px;
    margin-bottom: 18px;
}

.billing-panel,
.system-panel,
.platform-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.panel-title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
}

.panel-subtitle {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.panel-body {
    padding: 18px;
}

.current-plan-card {
    padding: 18px;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    background: linear-gradient(180deg, #eff6ff, #fff);
}

.current-plan-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.current-plan-name {
    margin: 0;
    color: #1e3a8a;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: -.03em;
}

.current-plan-price {
    margin-top: 5px;
    color: #0f172a;
    font-size: 14px;
    font-weight: 750;
}

.plan-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.plan-status-pill.active {
    background: var(--success-bg);
    color: #166534;
}

.plan-status-pill.trial {
    background: var(--info-bg);
    color: #075985;
}

.plan-status-pill.past-due,
.plan-status-pill.cancelled,
.plan-status-pill.canceled {
    background: var(--danger-bg);
    color: #991b1b;
}

.billing-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.billing-meta-item {
    padding: 11px 12px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: #fff;
}

.billing-meta-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .045em;
}

.billing-meta-value {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 750;
}

/* Usage */
.usage-list {
    display: grid;
    gap: 14px;
}

.usage-item {
    display: grid;
    gap: 6px;
}

.usage-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #475569;
    font-size: 12px;
}

.usage-header strong {
    color: var(--text);
}

.usage-bar {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.usage-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.usage-fill.warning {
    background: #f59e0b;
}

.usage-fill.danger {
    background: #dc2626;
}

/* Plan cards */
.plan-comparison-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.plan-card-modern {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.plan-card-modern.featured {
    border-color: #93c5fd;
    box-shadow: 0 14px 35px rgba(37, 99, 235, .11);
}

.plan-ribbon {
    position: absolute;
    right: 13px;
    top: 13px;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.plan-card-header {
    padding: 20px 20px 12px;
}

.plan-card-name {
    margin: 0;
    font-size: 19px;
    font-weight: 900;
}

.plan-card-description {
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.plan-card-price {
    margin-top: 15px;
    color: var(--text);
    font-size: 30px;
    font-weight: 900;
    letter-spacing: -.04em;
}

.plan-card-price small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0;
}

.plan-feature-list {
    flex: 1;
    display: grid;
    gap: 9px;
    padding: 14px 20px 20px;
}

.plan-feature {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    color: #475569;
    font-size: 12px;
}

.plan-feature::before {
    content: "✓";
    color: #16a34a;
    font-weight: 900;
}

.plan-card-footer {
    padding: 16px 20px 20px;
    border-top: 1px solid var(--border);
}

.plan-card-footer .btn,
.plan-card-footer button {
    width: 100%;
}

/* Feature audit */
.feature-audit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
}

.feature-audit-card {
    padding: 15px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.feature-audit-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
}

.feature-audit-name {
    font-size: 13px;
    font-weight: 800;
}

.feature-audit-description {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.5;
}

.feature-state {
    display: inline-flex;
    align-items: center;
    padding: 4px 7px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
}

.feature-state.enabled {
    background: var(--success-bg);
    color: #166534;
}

.feature-state.disabled {
    background: #f1f5f9;
    color: #64748b;
}

.feature-state.locked {
    background: var(--warning-bg);
    color: #92400e;
}

/* System health */
.health-hero {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 20px;
    align-items: center;
    margin-bottom: 18px;
}

.health-score-ring {
    width: 154px;
    height: 154px;
    display: grid;
    place-items: center;
    margin: 0 auto;
    border-radius: 50%;
    background:
        radial-gradient(circle at center, white 59%, transparent 60%),
        conic-gradient(var(--primary) 0 88%, #e2e8f0 88% 100%);
}

.health-score-ring strong {
    font-size: 31px;
    font-weight: 900;
    letter-spacing: -.04em;
}

.health-score-ring span {
    display: block;
    text-align: center;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
}

.health-summary-list {
    display: grid;
    gap: 9px;
}

.health-summary-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #edf2f7;
}

.health-summary-item:last-child {
    border-bottom: 0;
}

.health-status-dot {
    width: 8px;
    height: 8px;
    display: inline-block;
    border-radius: 50%;
    margin-right: 7px;
}

.health-status-dot.ok { background: #22c55e; }
.health-status-dot.warn { background: #f59e0b; }
.health-status-dot.fail { background: #ef4444; }

.health-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.health-check-card {
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
}

.health-check-title {
    font-size: 12px;
    font-weight: 800;
}

.health-check-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 10px;
}

.health-check-value {
    margin-top: 10px;
    font-size: 18px;
    font-weight: 850;
}

/* Operational status */
.ops-status-list {
    display: grid;
    gap: 10px;
}

.ops-status-row {
    display: grid;
    grid-template-columns: minmax(140px, .8fr) minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid #edf2f7;
}

.ops-status-row:last-child {
    border-bottom: 0;
}

.ops-name {
    font-size: 12px;
    font-weight: 800;
}

.ops-description {
    color: var(--muted);
    font-size: 11px;
}

.ops-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
}

.ops-pill.ok {
    background: var(--success-bg);
    color: #166534;
}

.ops-pill.warn {
    background: var(--warning-bg);
    color: #92400e;
}

.ops-pill.fail {
    background: var(--danger-bg);
    color: #991b1b;
}

/* Alert center */
.platform-alert-list {
    display: grid;
    gap: 10px;
}

.platform-alert {
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
}

.platform-alert.high {
    border-left: 4px solid #ef4444;
}

.platform-alert.medium {
    border-left: 4px solid #f59e0b;
}

.platform-alert.low {
    border-left: 4px solid #38bdf8;
}

.platform-alert-title {
    font-size: 12px;
    font-weight: 800;
}

.platform-alert-meta {
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
}

.platform-alert-copy {
    margin-top: 7px;
    color: #475569;
    font-size: 11px;
    line-height: 1.55;
}

/* SMTP / queue / backup cards */
.system-tool-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.system-tool-card {
    display: flex;
    flex-direction: column;
    min-height: 180px;
    padding: 17px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.system-tool-title {
    font-size: 14px;
    font-weight: 850;
}

.system-tool-copy {
    flex: 1;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
}

.system-tool-stat {
    margin: 14px 0;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -.035em;
}

/* Billing invoice doc enhancements */
.invoice-status-bar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    margin-bottom: 16px;
    border-radius: 9px;
    background: #f8fafc;
    border: 1px solid var(--border);
}

.invoice-total-box {
    margin-left: auto;
    width: min(100%, 360px);
    padding: 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.invoice-total-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 6px 0;
    color: #475569;
}

.invoice-total-row.grand-total {
    margin-top: 6px;
    padding-top: 11px;
    border-top: 1px solid var(--border);
    color: var(--text);
    font-size: 17px;
    font-weight: 900;
}

/* Admin tables */
.platform-table .critical-row {
    background: #fff7f7;
}

.platform-table .warning-row {
    background: #fffbeb;
}

/* Responsive */
@media (max-width: 1180px) {
    .saas-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .plan-comparison-grid,
    .system-tool-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .billing-overview {
        grid-template-columns: 1fr;
    }

    .health-hero {
        grid-template-columns: 1fr;
    }

    .health-score-ring {
        margin: 0;
    }
}

@media (max-width: 680px) {
    .saas-summary-grid,
    .plan-comparison-grid,
    .system-tool-grid,
    .billing-meta-grid {
        grid-template-columns: 1fr;
    }

    .admin-page-header,
    .current-plan-row,
    .invoice-status-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-actions {
        width: 100%;
    }

    .admin-actions .btn,
    .admin-actions button {
        flex: 1;
    }

    .ops-status-row {
        grid-template-columns: 1fr;
        gap: 5px;
    }
}

@media print {
    .admin-actions,
    .system-tool-grid .btn,
    .plan-card-footer {
        display: none !important;
    }

    .billing-panel,
    .system-panel,
    .platform-panel,
    .plan-card-modern,
    .system-tool-card {
        box-shadow: none;
    }
}
