:root {
    color-scheme: dark;
    --bg: #030712;
    --bg-alt: #0f172a;
    --panel: rgba(15, 23, 42, 0.72);
    --border: rgba(148, 163, 184, 0.25);
    --text: #e2e8f0;
    --muted: #94a3b8;
    --accent: #38bdf8;
    --accent-strong: #22d3ee;
    --success: #34d399;
    --warning: #f97316;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

a {
    color: inherit;
}

.ghost-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.ghost-link:hover {
    text-decoration: underline;
}

.muted {
    color: var(--muted);
}

.gradient-bg {
    background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.35), transparent 40%),
                radial-gradient(circle at 20% 20%, rgba(14, 165, 233, 0.4), transparent 55%),
                var(--bg);
    min-height: 100vh;
}

.auth-page {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1.5rem, 5vw, 4rem);
}

.auth-card {
    background: rgba(248, 250, 252, 0.02);
    border: 1px solid var(--border);
    border-radius: 32px;
    padding: clamp(2rem, 5vw, 3rem);
    max-width: 460px;
    width: 100%;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}

.brand-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent);
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.brand-pill-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

.brand-pill .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}

.auth-card h2 {
    margin: 1rem 0 0.5rem;
}

.auth-subtext,
.auth-footnote {
    color: var(--muted);
    margin: 0 0 1.25rem;
    font-size: 0.95rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-weight: 500;
}

.auth-form input,
.control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-radius: 14px;
    border: 1px solid var(--border);
    padding: 0.85rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text);
    font-size: 1rem;
    width: 100%;
}

.auth-form input:focus,
.control:focus {
    outline: 2px solid rgba(56, 189, 248, 0.6);
    outline-offset: 2px;
}

.form-errors {
    border-radius: 16px;
    padding: 0.75rem 1rem;
    background: rgba(248, 113, 113, 0.18);
    border: 1px solid rgba(248, 113, 113, 0.4);
    margin-bottom: 1rem;
    font-weight: 600;
}

.form-errors.compact {
    margin-top: 0.25rem;
}

.field-error {
    color: #fca5a5;
    font-size: 0.85rem;
}

.field-error-inline {
    color: #fca5a5;
    font-size: 0.85rem;
    display: block;
    margin-top: 0.35rem;
}

.primary-btn {
    border: none;
    border-radius: 16px;
    padding: 0.9rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
    color: #020617;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 15px 35px rgba(34, 211, 238, 0.3);
}

.dashboard-body {
    background: linear-gradient(180deg, #020617 0%, #0f172a 60%, #020617 100%);
    min-height: 100vh;
}

.flash-container {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    width: min(420px, 90vw);
}

.flash {
    margin: 0 auto 0.75rem;
    padding: 0.85rem 1.2rem;
    border-radius: 999px;
    text-align: center;
    font-weight: 600;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.85);
    box-shadow: 0 10px 25px rgba(2, 6, 23, 0.4);
}

.flash.success {
    border-color: rgba(74, 222, 128, 0.45);
    color: #4ade80;
}

.dashboard-shell {
    width: min(1200px, 100%);
    margin: 0 auto;
    padding: clamp(1.5rem, 4vw, 3.5rem);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.dashboard-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
    padding-bottom: 1.5rem;
}

.dashboard-header h1 {
    margin: 0.5rem 0 0;
    font-size: clamp(1.8rem, 3vw, 2.2rem);
}

.dashboard-title-stack h1 {
    margin: 0;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: clamp(1.6rem, 2.8vw, 2.1rem);
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dashboard-title-stack .subtext {
    margin: 0.2rem 0 0;
}

.subtext {
    color: var(--muted);
    margin: 0.4rem 0 0;
}

.eyebrow {
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    color: var(--accent);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-chip {
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    border: 1px solid rgba(148, 163, 184, 0.35);
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--panel);
    padding: 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.stat-card .label {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.stat-card h2 {
    margin: 0.4rem 0;
    font-size: 2rem;
}

.trend {
    margin: 0;
    font-size: 0.9rem;
}

.trend.up {
    color: var(--success);
}

.trend.down {
    color: var(--warning);
}

.trend.neutral {
    color: var(--muted);
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.panel-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 1.5rem;
}

.panel-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.badge {
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    background: rgba(34, 197, 94, 0.18);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.badge.outline {
    background: transparent;
    border-color: rgba(148, 163, 184, 0.4);
    color: var(--muted);
}

.panel-card ul,
.panel-card ol {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--muted);
}

.panel-card li {
    margin-bottom: 0.65rem;
}

.table-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.table-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
    padding-bottom: 1rem;
}

.table-header h2 {
    margin: 0;
}

.table-header p {
    margin: 0.25rem 0 0;
    color: var(--muted);
}

.pagination-info {
    align-self: flex-end;
    color: var(--muted);
    font-weight: 600;
}

.pagination-info span {
    color: var(--text);
    margin-left: 0.3rem;
}

.table-wrapper {
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-color: rgba(148, 163, 184, 0.5) rgba(15, 23, 42, 0.3);
}

.filter-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-bar input {
    flex: 1;
    min-width: 240px;
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 0.8rem 1rem;
    background: rgba(15, 23, 42, 0.7);
    color: var(--text);
    font-size: 0.95rem;
}

.filter-bar input:focus {
    outline: 2px solid rgba(34, 211, 238, 0.5);
    outline-offset: 2px;
}

.primary-btn.compact {
    min-width: 120px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.subscriptions-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.subscriptions-table thead th {
    text-align: left;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.subscriptions-table tbody td {
    padding: 0.85rem 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.subscriptions-table tbody tr:last-child td {
    border-bottom: none;
}

.subscriptions-table td:nth-child(3),
.subscriptions-table td:nth-child(4) {
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 90px;
    padding: 0.2rem 0.75rem;
    border-radius: 999px;
    font-weight: 600;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.status-pill.paid {
    border-color: rgba(34, 197, 94, 0.4);
    color: #4ade80;
    background: rgba(34, 197, 94, 0.12);
}

.status-pill.free {
    border-color: rgba(14, 165, 233, 0.4);
    color: var(--accent);
    background: rgba(14, 165, 233, 0.12);
}

.status-pill.used-pill {
    border-color: rgba(248, 113, 113, 0.5);
    color: #fca5a5;
    background: rgba(248, 113, 113, 0.15);
}

.empty-cell {
    text-align: center;
    color: var(--muted);
    padding: 2rem 0;
}

.pagination-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.page-btn {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: var(--text);
    border-radius: 12px;
    padding: 0.35rem 0.85rem;
    min-width: 42px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, border 0.2s ease;
}

.page-btn:hover:not(:disabled) {
    background: rgba(56, 189, 248, 0.15);
    border-color: rgba(56, 189, 248, 0.6);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-btn.active {
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
    border-color: transparent;
    color: #020617;
}

.ellipsis {
    color: var(--muted);
    font-size: 1.1rem;
    padding: 0 0.35rem;
}

.small {
    font-size: 0.9rem;
}

.clear-link {
    padding: 0.75rem 0;
    font-weight: 600;
}

select.control,
input[type="search" i],
input[type="number" i] {
    background-clip: padding-box;
}

input[type="checkbox"].control {
    width: auto;
    height: 18px;
}

input[type="search"]::-ms-clear,
input[type="search"]::-ms-reveal {
    display: none;
}

input[type="search" i] {
    background-clip: padding-box;
}

select.control {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: rgba(15, 23, 42, 0.6);
    color: var(--text);
}

.subscriptions-table .action-col {
    width: 82px;
}

.tab-switcher {
    display: inline-flex;
    gap: 0.6rem;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.75);
    padding: 0.35rem;
    border-radius: 999px;
    margin: 0.5rem 0;
}

.tab-link {
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    font-weight: 700;
    text-decoration: none;
    color: var(--muted);
    border: 1px solid transparent;
}

.tab-link.active {
    color: #020617;
    background: linear-gradient(120deg, var(--accent), var(--accent-strong));
}

.tab-link:hover:not(.active) {
    border-color: rgba(56, 189, 248, 0.5);
    color: var(--text);
}

.icon-btn {
    border-radius: 12px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.4);
    color: var(--text);
    padding: 0.35rem 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.icon-btn:hover {
    background: rgba(56, 189, 248, 0.25);
    transform: translateY(-1px);
}

.icon-btn.close {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
}

.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding-top: 1rem;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.footer-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.modal-shell {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 20;
}

.modal-shell.open {
    visibility: visible;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.75);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.modal-card {
    position: relative;
    width: min(720px, 94vw);
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.75));
    border-radius: 28px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding: clamp(1.5rem, 4vw, 2.25rem);
    box-shadow: 0 25px 55px rgba(2, 6, 23, 0.55);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-header h3 {
    margin: 0.2rem 0 0.3rem;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-weight: 600;
    color: var(--text);
}

.checkbox-field {
    flex-direction: row;
    align-items: center;
    gap: 0.65rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    align-items: center;
}

.status-pill.in-arrears {
    border-color: rgba(249, 115, 22, 0.5);
    color: var(--warning);
    background: rgba(249, 115, 22, 0.15);
}

@media (max-width: 768px) {
    .auth-card {
        margin: 0 auto;
    }

    .auth-page {
        padding: 1.5rem;
    }

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

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .modal-card {
        width: 95vw;
    }

    .modal-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .footer-actions {
        width: 100%;
        justify-content: flex-start;
    }
}
input[type="search"]::-ms-clear,
input[type="search"]::-ms-reveal {
    display: none;
}

input[type="search" i] {
    background-clip: padding-box;
}
