:root {
    --app-border: #d9dee8;
    --app-muted: #64748b;
    --app-panel: #ffffff;
    --app-soft: #f6f8fb;
}

[data-bs-theme="dark"] {
    --app-border: #2f3a4f;
    --app-muted: #a7b0c0;
    --app-panel: #121826;
    --app-soft: #0e1420;
}

body {
    background: var(--app-soft);
    font-size: 14px;
}

.navbar {
    backdrop-filter: blur(10px);
}

.navbar-nav {
    row-gap: 4px;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(14, 165, 233, .12), transparent 32%),
        linear-gradient(315deg, rgba(34, 197, 94, .12), transparent 32%),
        var(--app-soft);
}

.auth-card,
.panel,
.metric-card,
.plan-card {
    background: var(--app-panel);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}

.auth-card {
    width: min(100%, 420px);
    padding: 28px;
}

.auth-card-wide {
    width: min(100%, 760px);
}

.page-header {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 24px;
    line-height: 1.2;
    margin: 0;
}

.page-header p,
.panel-title a,
.metric-card span,
.plan-card p {
    color: var(--app-muted);
}

.page-header p {
    margin: 4px 0 0;
}

.panel {
    padding: 18px;
}

.scroll-form {
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

.scroll-form::-webkit-scrollbar {
    width: 8px;
}

.scroll-form::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, .35);
    border-radius: 8px;
}

.panel h2,
.panel-title h2,
.plan-card h2 {
    font-size: 16px;
    margin: 0 0 14px;
}

.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.metric-card {
    padding: 16px;
    display: grid;
    gap: 8px;
}

.metric-card i {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #0f766e;
    background: rgba(20, 184, 166, .13);
    font-size: 18px;
}

.metric-card strong {
    font-size: 22px;
}

.metric-card small {
    color: var(--app-muted);
}

.dashboard-status-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    padding: 12px 16px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-panel);
}

.dashboard-status-bar span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.dashboard-status-bar .bi-circle-fill {
    font-size: 8px;
}

.dashboard-status-bar a {
    margin-left: auto;
    text-decoration: none;
}

.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.quick-action-grid a {
    min-height: 112px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 14px;
    color: var(--bs-body-color);
    text-decoration: none;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-soft);
    transition: border-color .2s ease, transform .2s ease;
}

.quick-action-grid a:hover {
    border-color: var(--bs-primary);
    transform: translateY(-2px);
}

.quick-action-grid i {
    color: var(--bs-primary);
    font-size: 21px;
}

.quick-action-grid span {
    font-weight: 600;
}

.quick-action-grid small {
    color: var(--app-muted);
}

.attention-list {
    display: grid;
    gap: 10px;
}

.attention-list a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    color: var(--bs-body-color);
    text-decoration: none;
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.attention-list a:hover {
    background: var(--app-soft);
}

.attention-list a > span:last-child,
.dashboard-list-item > span {
    min-width: 0;
}

.attention-list strong,
.attention-list small,
.dashboard-list-item strong,
.dashboard-list-item small {
    display: block;
}

.attention-list small,
.dashboard-list-item small {
    color: var(--app-muted);
}

.attention-icon,
.list-icon {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: grid;
    place-items: center;
    border-radius: 8px;
}

.list-icon {
    color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), .1);
}

.dashboard-list {
    display: grid;
}

.dashboard-list-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 0;
    color: var(--bs-body-color);
    text-decoration: none;
    border-bottom: 1px solid var(--app-border);
}

.dashboard-list-item:first-child {
    padding-top: 0;
}

.dashboard-list-item:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.trend-chart {
    height: 240px;
    display: grid;
    grid-template-columns: repeat(7, minmax(36px, 1fr));
    align-items: end;
    gap: 12px;
    padding-top: 22px;
}

.trend-column {
    height: 100%;
    display: grid;
    grid-template-rows: 22px 1fr 22px;
    align-items: end;
    gap: 5px;
    text-align: center;
}

.trend-value {
    overflow: hidden;
    color: var(--app-muted);
    font-size: 11px;
    text-overflow: ellipsis;
}

.trend-bar {
    width: min(44px, 78%);
    height: var(--bar-height);
    min-height: 5px;
    justify-self: center;
    border-radius: 7px 7px 2px 2px;
    background: linear-gradient(180deg, var(--bs-primary), rgba(var(--bs-primary-rgb), .55));
}

.trend-column small {
    color: var(--app-muted);
}

.pie-dashboard {
    min-height: 240px;
    display: grid;
    grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
    align-items: center;
    gap: 20px;
}

.pie-dashboard-compact {
    min-height: 210px;
    grid-template-columns: minmax(140px, 190px) minmax(0, 1fr);
}

.pie-chart {
    width: min(220px, 100%);
    aspect-ratio: 1;
    position: relative;
    justify-self: center;
    border-radius: 50%;
    background: var(--pie-chart);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .08);
}

.pie-dashboard-compact .pie-chart {
    width: min(190px, 100%);
}

.pie-chart::after {
    content: attr(data-center);
    position: absolute;
    inset: 27%;
    display: grid;
    place-items: center;
    padding: 10px;
    border: 1px solid var(--app-border);
    border-radius: 50%;
    background: var(--app-panel);
    color: var(--bs-body-color);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
}

.pie-legend {
    display: grid;
    gap: 10px;
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--app-border);
}

.pie-legend-item:last-child {
    border-bottom: 0;
}

.pie-legend-item strong,
.pie-legend-item small {
    display: block;
}

.pie-legend-item small {
    color: var(--app-muted);
}

.pie-swatch {
    width: 12px;
    height: 12px;
    flex: 0 0 12px;
    border-radius: 50%;
    background: var(--swatch-color);
}

.activity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 0 22px;
}

.activity-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--app-border);
}

.activity-item > span:last-child,
.activity-item strong,
.activity-item small {
    display: block;
}

.activity-item > span:last-child > span {
    display: block;
    margin: 2px 0;
}

.activity-item small {
    color: var(--app-muted);
}

.activity-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--bs-primary);
    box-shadow: 0 0 0 4px rgba(var(--bs-primary-rgb), .12);
}

.empty-state {
    padding: 22px !important;
    color: var(--app-muted) !important;
    text-align: center;
}

.ticket-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.ticket-heading h2 {
    margin: 2px 0 0;
}

.ticket-message {
    padding: 14px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-soft);
}

.ticket-message p {
    margin: 0;
    line-height: 1.65;
}

.ticket-message-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    color: var(--app-muted);
    font-size: 12px;
}

.ticket-message-meta strong {
    color: var(--bs-body-color);
}

.ticket-response {
    margin-top: 14px;
    border-left: 4px solid var(--bs-primary);
}

.support-solution-panel {
    position: sticky;
    top: 84px;
}

.compact-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
}

.compact-filter label {
    display: grid;
    gap: 4px;
    color: var(--app-muted);
}

.invoice-table {
    min-width: 920px;
}

.invoice-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: end;
}

.invoice-summary span {
    min-width: 140px;
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-soft);
    color: var(--app-muted);
}

.invoice-summary strong {
    color: var(--bs-body-color);
    font-size: 18px;
}

.plan-card {
    padding: 18px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.plan-card strong {
    font-size: 26px;
}

.plan-card small {
    font-size: 13px;
    color: var(--app-muted);
}

.plan-card ul {
    padding-left: 18px;
    margin-bottom: auto;
}

.permission-list {
    max-height: 180px;
    overflow: auto;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--app-soft);
}

.error-box {
    white-space: pre-wrap;
    background: var(--app-soft);
    border: 1px solid var(--app-border);
    border-radius: 8px;
    padding: 12px;
}

@media (max-width: 720px) {
    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .invoice-summary {
        justify-content: stretch;
    }

    .invoice-summary span {
        flex: 1 1 150px;
    }

    .scroll-form {
        max-height: 70vh;
    }

    .dashboard-status-bar {
        align-items: flex-start;
        flex-direction: column;
    }

    .dashboard-status-bar a {
        margin-left: 0;
    }

    .trend-chart {
        height: 200px;
        gap: 5px;
    }

    .trend-value {
        display: none;
    }

    .pie-dashboard,
    .pie-dashboard-compact {
        min-height: 0;
        grid-template-columns: 1fr;
    }

    .pie-chart,
    .pie-dashboard-compact .pie-chart {
        width: min(210px, 72vw);
    }

    .ticket-heading,
    .ticket-message-meta {
        align-items: flex-start;
        flex-direction: column;
    }

    .support-solution-panel {
        position: static;
    }
}

@media print {
    @page {
        margin: 12mm;
    }

    .navbar,
    .page-header .btn,
    button,
    .btn {
        display: none !important;
    }

    html,
    body,
    main,
    .container-fluid,
    .panel {
        background: #fff;
        box-shadow: none;
        width: 100% !important;
        max-width: none !important;
    }

    main,
    .container-fluid,
    .panel {
        margin: 0 !important;
        padding: 0 !important;
    }

    .panel {
        border: 0 !important;
    }

    .scroll-form {
        max-height: none !important;
        overflow: visible !important;
    }

    .table-responsive {
        overflow: visible !important;
    }

    .invoice-table {
        min-width: 0 !important;
        width: 100% !important;
    }

    .invoice-summary {
        justify-content: flex-start;
    }
}
