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

:root,
html.dark,
body.dark {
    --bg: #09090b;
    --surface: #18181b;
    --surface2: #27272a;
    --border: #3f3f46;
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-glow: rgba(129, 140, 248, 0.3);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-lg: 16px;
    --nav-height: 64px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.6);
    --gradient: linear-gradient(135deg, #818cf8, #c084fc);
    --input-bg: #18181b;
    --modal-bg: rgba(0, 0, 0, 0.85);
    --row-hover: rgba(255, 255, 255, 0.04);
    --alert-error-bg: rgba(239, 68, 68, 0.15);
    --alert-error-text: #fca5a5;
    --alert-error-border: rgba(239, 68, 68, 0.3);
    --alert-success-bg: rgba(16, 185, 129, 0.15);
    --alert-success-text: #6ee7b7;
    --alert-success-border: rgba(16, 185, 129, 0.3);
    --nav-bg: rgba(24, 24, 27, 0.75);
}

html.light,
body.light {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface2: #f1f5f9;
    --border: #e2e8f0;
    --text: #111827;
    --text-muted: #4b5563;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-glow: rgba(79, 70, 229, .2);
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --warning: #d97706;
    --shadow: 0 2px 8px rgba(0, 0, 0, .06);
    --shadow-hover: 0 6px 20px rgba(0, 0, 0, .1);
    --gradient: linear-gradient(135deg, #4f46e5, #3b82f6);
    --input-bg: #ffffff;
    --modal-bg: rgba(0, 0, 0, .4);
    --row-hover: rgba(0, 0, 0, .02);
    --alert-error-bg: rgba(239, 68, 68, .08);
    --alert-error-text: #b91c1c;
    --alert-error-border: rgba(239, 68, 68, .2);
    --alert-success-bg: rgba(34, 197, 94, .08);
    --alert-success-text: #15803d;
    --alert-success-border: rgba(34, 197, 94, .2);
    --nav-bg: rgba(255, 255, 255, 0.85);
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background .3s, color .3s;
}

a {
    color: var(--primary);
    text-decoration: none
}

a:hover {
    text-decoration: underline
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem
}

.login-container {
    width: 100%;
    max-width: 420px
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    box-shadow: var(--shadow)
}

.login-box h1 {
    font-size: 1.5rem;
    margin-bottom: .35rem;
    font-weight: 700
}

.login-box .subtitle {
    color: var(--text-muted);
    margin-bottom: 1.75rem;
    font-size: .9rem
}

.navbar {
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-height);
    flex-wrap: nowrap;
    transition: background .3s, border-color .3s;
}

.nav-brand {
    font-size: 1.15rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap
}

.nav-links {
    display: flex;
    gap: .25rem;
    align-items: center;
    flex-wrap: wrap
}

.nav-links a {
    color: var(--text-muted);
    padding: .45rem .75rem;
    border-radius: var(--radius);
    font-size: .84rem;
    transition: all .2s;
    white-space: nowrap
}

.nav-links a:hover,
.nav-links a.active {
    background: var(--surface2);
    color: var(--text);
    text-decoration: none
}

.nav-links a.nav-danger {
    color: var(--danger)
}

.nav-links a.nav-danger:hover {
    background: rgba(239, 68, 68, .1);
    color: var(--danger)
}

/* Dropdown Submenu */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    color: var(--text-muted);
    padding: .45rem .75rem;
    border-radius: var(--radius);
    font-size: .84rem;
    transition: all .2s;
    white-space: nowrap;
    cursor: pointer;
    background: none;
    border: none;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: .3rem;
}

.nav-dropdown-toggle:hover,
.nav-dropdown.open .nav-dropdown-toggle {
    background: var(--surface2);
    color: var(--text);
}

.nav-dropdown-arrow {
    font-size: .65rem;
    transition: transform .2s;
}

.nav-dropdown.open .nav-dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .35rem;
    min-width: 190px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 200;
    animation: dropdownFade .15s ease;
}

.nav-dropdown.open .nav-dropdown-menu {
    display: flex;
    flex-direction: column;
}

.nav-dropdown-menu a {
    color: var(--text-muted);
    padding: .55rem .85rem;
    border-radius: 8px;
    font-size: .84rem;
    transition: all .2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a.active {
    background: var(--surface2);
    color: var(--text);
    text-decoration: none;
}

.nav-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: .25rem .5rem;
}

@keyframes dropdownFade {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: .25rem;
    line-height: 1;
    flex-shrink: 0
}

.theme-toggle {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .35rem .55rem;
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
    color: var(--text);
    transition: all .2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background: var(--border)
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.75rem
}

.container.form-page {
    max-width: 700px;
    margin: 0 auto
}

/* ── Analytics Charts ──────────────────────────────── */
.analytics-section {
    margin-bottom: 2rem;
}

.analytics-section h2 {
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
    margin-bottom: 0;
    align-items: start;
}

.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.chart-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #0ea5e9);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.25rem;
}

.chart-card-header .chart-title {
    margin-bottom: 0;
}

.period-pills {
    display: flex;
    gap: .3rem;
    flex-wrap: wrap;
}

.period-pill {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    padding: .2rem .6rem;
    cursor: pointer;
    transition: all .15s ease;
    line-height: 1.4;
}

.period-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.period-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.chart-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 1.25rem;
}

.chart-wrap {
    position: relative;
    width: 100%;
    max-height: 300px;
}

.chart-wrap canvas {
    max-height: 300px;
}

.chart-wrap-sm {
    max-height: 260px;
}

.chart-wrap-sm canvas {
    max-height: 260px;
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .chart-wrap,
    .chart-wrap canvas {
        max-height: 240px;
    }

    .chart-wrap-sm,
    .chart-wrap-sm canvas {
        max-height: 220px;
    }
}

@media (max-width: 480px) {
    .stats-grid:has(> .stat-card:nth-child(odd):last-child) {
        grid-template-columns: 1fr;
    }
}

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

/* Ensure a row of 3 cards takes exactly 3 equal columns on large screens */
.stats-grid:has(> .stat-card:nth-child(3):last-child) {
    grid-template-columns: repeat(3, 1fr);
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: left;
    transition: transform .2s, box-shadow .2s, border-color .2s;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, var(--primary-glow), transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary);
}

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

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--surface2);
    color: var(--primary);
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.stat-card:hover .stat-icon {
    transform: scale(1.1) rotate(5deg);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

.stat-number {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    z-index: 1;
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}

.stat-active .stat-icon {
    color: var(--success);
    background: var(--alert-success-bg);
}

.stat-warning .stat-icon {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.15);
}

.stat-expired .stat-icon {
    color: var(--danger);
    background: var(--alert-error-bg);
}

.stat-revenue .stat-icon {
    color: #a78bfa;
    background: rgba(167, 139, 250, 0.15);
}

.stat-active::before {
    background: radial-gradient(circle at top right, var(--alert-success-bg), transparent 60%);
}

.stat-warning::before {
    background: radial-gradient(circle at top right, rgba(245, 158, 11, 0.15), transparent 60%);
}

.stat-expired::before {
    background: radial-gradient(circle at top right, var(--alert-error-bg), transparent 60%);
}

.stat-revenue::before {
    background: radial-gradient(circle at top right, rgba(167, 139, 250, 0.2), transparent 60%);
}

.section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow);
    transition: background .3s, border-color .3s;
}

.section h2 {
    font-size: 1.15rem;
    margin-bottom: 1.15rem;
    color: var(--text);
    font-weight: 600
}

.form-group {
    margin-bottom: 1.25rem;
    text-align: left
}

.form-group label {
    display: block;
    margin-bottom: .4rem;
    font-size: .85rem;
    color: var(--text-muted);
    font-weight: 500
}

.form-group input,
.form-group select {
    width: 100%;
    padding: .65rem .9rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9rem;
    transition: border-color .2s, box-shadow .2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow)
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-toggle {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    transition: color 0.2s;
    outline: none;
}

.password-toggle:hover {
    color: var(--primary);
}

.password-wrapper input {
    padding-right: 2.5rem;
    /* Space for the eye icon */
}

.form-group small {
    display: block;
    margin-top: .25rem;
    color: var(--text-muted);
    font-size: .8rem
}

.inline-form {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    background: var(--surface2);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.inline-form input,
.inline-form select {
    padding: 0.65rem 0.85rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    flex: 1;
    min-width: 140px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.inline-form input:focus,
.inline-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow)
}

.inline-edit {
    display: inline;
}

.table-input {
    padding: 0.45rem 0.6rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
    width: 100%;
    min-width: 150px;
    transition: all 0.2s;
}

.table-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
    background: var(--input-bg);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .6rem 1.15rem;
    border: none;
    border-radius: var(--radius);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 2px 8px var(--primary-glow)
}

.btn-primary:hover {
    opacity: .9;
    box-shadow: 0 4px 16px var(--primary-glow);
    text-decoration: none
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border)
}

.btn-secondary:hover {
    background: var(--border);
    text-decoration: none
}

.btn-danger {
    background: var(--danger);
    color: #fff
}

.btn-danger:hover {
    background: var(--danger-hover)
}

.btn-success {
    background: var(--success);
    color: #fff
}

.btn-success:hover {
    background: #16a34a
}

.btn-sm {
    padding: .3rem .6rem;
    font-size: .78rem
}

.btn-full {
    width: 100%;
    padding: .75rem
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -.25rem;
    padding: 0 .25rem
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: .75rem;
    font-size: .84rem
}

.data-table th {
    text-align: left;
    padding: .65rem .7rem;
    background: var(--surface2);
    color: var(--text-muted);
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.data-table td {
    padding: .6rem .7rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle
}

.data-table tbody tr {
    transition: background .15s
}

.data-table tbody tr:hover {
    background: var(--row-hover)
}

.data-table .mono {
    font-family: 'SF Mono', 'Courier New', monospace;
    letter-spacing: .5px;
    word-break: break-all;
    font-size: .82rem
}

.data-table .actions {
    display: grid;
    grid-template-columns: repeat(3, auto);
    justify-content: start;
    gap: .35rem;
    align-items: center
}

.row-expired {
    background: rgba(239, 68, 68, .06) !important
}

.row-expired:hover {
    background: rgba(239, 68, 68, .1) !important
}

.row-warning {
    background: rgba(245, 158, 11, .06) !important
}

.row-warning:hover {
    background: rgba(245, 158, 11, .1) !important
}

.badge {
    display: inline-block;
    padding: .2rem .6rem;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: .02em
}

.badge-active {
    background: rgba(34, 197, 94, .12);
    color: var(--success)
}

.badge-warning {
    background: rgba(245, 158, 11, .12);
    color: var(--warning)
}

.badge-expired {
    background: rgba(239, 68, 68, .12);
    color: var(--danger)
}

.plans-list {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    margin-bottom: .5rem;
    align-items: center
}

.plan-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .65rem;
    background: var(--primary-glow);
    color: var(--primary);
    border: 1px solid rgba(124, 92, 252, .2);
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 600;
}

html.light .plan-badge,
body.light .plan-badge {
    border-color: rgba(79, 70, 229, .3);
}

.btn-del-plan {
    background: rgba(239, 68, 68, .1);
    color: var(--danger);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    margin-left: .1rem;
    transition: transform .2s, background .2s, color .2s;
}

.btn-del-plan:hover {
    background: var(--danger);
    color: #fff;
    transform: scale(1.15);
}

.alert {
    padding: .8rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .9rem;
    word-break: break-word
}

.alert-error {
    background: var(--alert-error-bg);
    color: var(--alert-error-text);
    border: 1px solid var(--alert-error-border)
}

.alert-success {
    background: var(--alert-success-bg);
    color: var(--alert-success-text);
    border: 1px solid var(--alert-success-border)
}

.filter-badges {
    display: flex;
    gap: .6rem;
    margin-bottom: .85rem;
    flex-wrap: wrap
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .75rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: .78rem;
    color: var(--text-muted);
}

.filter-badge strong {
    color: var(--primary);
    font-weight: 700
}

.filter-form {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    margin-bottom: 1.5rem;
    background: var(--surface2);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.filter-row {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap
}

.filter-form input[type="text"],
.filter-form select,
.filter-form input[type="date"] {
    padding: .55rem .75rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .85rem;
    min-width: 160px;
    flex: 1;
    transition: border-color .2s, box-shadow .2s;
}

.filter-form input[type="text"] {
    min-width: 200px
}

.filter-form input:focus,
.filter-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow)
}

.filter-actions {
    gap: .5rem
}

.filter-custom-dates input[type="date"] {
    max-width: 200px
}

.pagination-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 1.25rem;
    padding: .75rem 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.pagination-info {
    font-size: .82rem;
    color: var(--text-muted);
    white-space: nowrap
}

.pagination-controls {
    display: flex;
    gap: .4rem;
    align-items: center
}

.pagination-size {
    display: flex;
    gap: .4rem;
    align-items: center;
    font-size: .82rem;
    color: var(--text-muted);
    margin-left: auto
}

.pagination-size select {
    padding: .3rem .5rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: .82rem;
}

.pagination-goto {
    display: flex;
    align-items: center
}

.goto-form {
    display: flex;
    gap: .3rem;
    align-items: center
}

.goto-input {
    width: 90px;
    padding: .3rem .5rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: .82rem;
}

.goto-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow)
}

.btn-disabled {
    opacity: .4;
    pointer-events: none;
    cursor: default
}

.output-block {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.35rem;
    margin-bottom: 1rem
}

.formatted-output {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: .88rem;
    line-height: 1.75;
    color: var(--text)
}

.copy-buttons {
    display: flex;
    gap: .5rem;
    margin-top: .85rem;
    flex-wrap: wrap
}

.danger-zone {
    border: 1px solid rgba(239, 68, 68, .3)
}

.danger-zone h2 {
    color: #ef4444
}

.danger-zone-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap
}

.danger-zone-info {
    flex: 1;
    min-width: 200px
}

.danger-zone-info strong {
    font-size: .95rem;
    color: var(--text)
}

.danger-zone-info p {
    font-size: .82rem;
    color: var(--text-muted);
    margin-top: .25rem
}

.modal-header-danger {
    border-bottom-color: rgba(239, 68, 68, .3)
}

.modal-header-danger h3 {
    color: #ef4444
}

.renewal-badge {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--primary);
    cursor: default;
}

.renewed-tag {
    font-size: .65rem;
    font-weight: 400;
    opacity: .75;
    margin-left: .15rem;
}

.text-muted {
    color: var(--text-muted);
    font-size: .82rem
}

.action-group {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: nowrap
}

.th-actions {
    width: 160px;
    min-width: 140px;
    text-align: center
}

.td-actions {
    width: 160px;
    min-width: 140px
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface2);
    cursor: pointer;
    font-size: .85rem;
    line-height: 1;
    padding: 0;
    transition: all .2s;
    flex-shrink: 0;
}

.btn-icon:hover {
    transform: scale(1.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .2)
}

.btn-icon-secondary {
    border-color: var(--border)
}

.btn-icon-secondary:hover {
    background: var(--border);
    border-color: var(--text-muted)
}

.btn-icon-primary {
    border-color: var(--primary);
    background: rgba(124, 92, 252, .1)
}

.btn-icon-primary:hover {
    background: rgba(124, 92, 252, .22)
}

.btn-icon-success {
    border-color: var(--success);
    background: rgba(34, 197, 94, .1)
}

.btn-icon-success:hover {
    background: rgba(34, 197, 94, .22)
}

.btn-icon-danger {
    border-color: var(--danger);
    background: rgba(239, 68, 68, .1)
}

.btn-icon-danger:hover {
    background: rgba(239, 68, 68, .22)
}

.cred-table {
    table-layout: auto
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--modal-bg);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px)
}

.modal-overlay.open {
    display: flex
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn .25s ease;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .4)
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(.95) translateY(8px)
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0)
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.35rem;
    border-bottom: 1px solid var(--border)
}

.modal-header h3 {
    font-size: 1.1rem;
    margin: 0;
    font-weight: 600
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: .25rem;
    line-height: 1;
    transition: color .2s
}

.modal-close:hover {
    color: var(--text)
}

.modal-body {
    padding: 1.35rem
}

.modal-info {
    background: var(--surface2);
    border-radius: var(--radius);
    padding: .9rem 1.1rem;
    margin-bottom: 1.1rem
}

.modal-info-row {
    display: flex;
    justify-content: space-between;
    padding: .35rem 0;
    font-size: .88rem;
    gap: .5rem;
    flex-wrap: wrap
}

.modal-label {
    color: var(--text-muted);
    font-weight: 500
}

.modal-highlight {
    color: var(--success);
    font-weight: 600
}

.modal-select {
    width: 100%;
    padding: .65rem .9rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: .9rem;
    transition: border-color .2s, box-shadow .2s;
}

.modal-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow)
}

.modal-actions {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    margin-top: 1.15rem
}

#renewHistoryModal .modal {
    max-width: 650px;
}

.rh-table th,
.rh-table td {
    white-space: nowrap;
}

.empty-msg {
    color: var(--text-muted);
    font-size: .9rem;
    text-align: center;
    padding: 1.75rem 0
}

.days-active {
    color: var(--success);
    font-weight: 600;
    font-size: .8rem;
    white-space: nowrap
}

.days-warning {
    color: var(--warning);
    font-weight: 600;
    font-size: .8rem;
    white-space: nowrap
}

.days-expired {
    color: var(--danger);
    font-weight: 600;
    font-size: .8rem;
    white-space: nowrap
}

.reminder-header {
    margin-bottom: .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap
}

.reminder-summary {
    margin-bottom: 1.75rem
}

.price-info {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .65rem 1.1rem;
    margin-bottom: 1.1rem;
    font-size: .88rem;
    color: var(--text-muted)
}

.price-info strong {
    color: #a78bfa
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
    max-width: 420px;
    width: calc(100vw - 2rem);
}

.toast {
    pointer-events: all;
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 4px solid var(--success);
    border-radius: 12px;
    padding: 1rem 1rem 1rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.toast-hide {
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease-in;
}

.toast.toast-error {
    border-left-color: #ef4444;
}

.toast.toast-warning {
    border-left-color: #f59e0b;
}

.toast-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.toast-icon.icon-success {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.toast-icon.icon-error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.toast-icon.icon-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: #f8fafc;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toast-message {
    font-size: 0.9rem;
    color: #cbd5e1;
    line-height: 1.4;
    word-break: break-word;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #f8fafc;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 12px 12px;
    background: var(--success);
    animation: toastProgress 4s linear forwards;
}

.toast-error .toast-progress {
    background: #ef4444;
}

.toast-warning .toast-progress {
    background: #f59e0b;
}

@keyframes toastProgress {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

@media(max-width:480px) {
    .container {
        padding: .75rem
    }

    .section {
        padding: 1rem;
        border-radius: var(--radius)
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: .6rem
    }

    /* Last odd stat card spans full width */
    .stats-grid>.stat-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .stat-card {
        padding: .85rem .5rem;
        border-radius: var(--radius)
    }

    .stat-number {
        font-size: 1.15rem;
        overflow-wrap: break-word;
        word-break: break-word;
        min-width: 0;
    }

    .stat-label {
        font-size: .72rem
    }

    .stat-card {
        min-width: 0;
        overflow: hidden;
    }

    .inline-form {
        flex-direction: column;
        gap: .5rem
    }

    .inline-form input,
    .inline-form select {
        min-width: auto;
        width: 100%;
        flex: none
    }

    .inline-form .btn {
        width: 100%
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
        gap: .4rem
    }

    .filter-form input[type="text"],
    .filter-form select,
    .filter-form input[type="date"] {
        min-width: auto;
        width: 100%
    }

    .filter-form .btn {
        width: 100%
    }

    .filter-badges {
        flex-direction: column;
        gap: .3rem
    }

    .pagination-bar {
        flex-direction: column;
        gap: .6rem;
        align-items: stretch
    }

    .pagination-size {
        margin-left: 0
    }

    .pagination-controls {
        justify-content: center
    }

    .goto-form {
        width: 100%
    }

    .goto-input {
        flex: 1
    }

    .data-table {
        font-size: .75rem
    }

    .data-table th,
    .data-table td {
        padding: .35rem .4rem
    }

    .btn-sm {
        padding: .25rem .4rem;
        font-size: .72rem
    }

    .action-group {
        gap: .2rem
    }

    .output-block {
        padding: .85rem
    }

    .formatted-output {
        font-size: .82rem;
        line-height: 1.6
    }

    .copy-buttons {
        gap: .35rem
    }

    .copy-buttons .btn {
        flex: 1;
        min-width: 0;
        text-align: center
    }

    .modal {
        max-width: calc(100vw - 1rem);
        margin: .5rem;
        border-radius: var(--radius)
    }

    .modal-header {
        padding: .85rem 1rem
    }

    .modal-body {
        padding: 1rem
    }

    .modal-actions {
        flex-direction: column
    }

    .modal-actions .btn {
        width: 100%
    }

    .login-box {
        padding: 1.5rem;
        border-radius: var(--radius)
    }

    .login-box h1 {
        font-size: 1.2rem
    }

    .page-link {
        width: 1.75rem;
        height: 1.75rem;
        font-size: .78rem
    }

    .toast-container {
        top: 1rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: 100%;
        width: auto;
    }
}

@media(min-width:481px) and (max-width:768px) {
    .container {
        padding: 1rem
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Override the 3-column rule on mobile */
    .stats-grid:has(> .stat-card:nth-child(3):last-child) {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-number {
        font-size: 1.25rem;
        overflow-wrap: break-word;
        word-break: break-word;
        min-width: 0;
    }

    .stat-card {
        min-width: 0;
        overflow: hidden;
    }

    .inline-form {
        flex-wrap: wrap
    }

    .inline-form input,
    .inline-form select {
        min-width: 140px
    }

    .filter-row {
        flex-wrap: wrap
    }

    .filter-form input[type="text"] {
        min-width: auto;
        flex: 1
    }

    .filter-form select {
        min-width: auto
    }

    .data-table {
        font-size: .78rem
    }

    .data-table th,
    .data-table td {
        padding: .4rem .5rem
    }

    .output-block {
        padding: 1rem
    }

    .modal {
        max-width: calc(100vw - 2rem)
    }
}

@media(max-width:768px) {
    .navbar {
        padding: .6rem 1rem;
        gap: .5rem;
    }

    .nav-brand {
        font-size: 1.05rem;
        flex: 1;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: .5rem .75rem;
        gap: .15rem;
        z-index: 99;
        box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
        align-items: stretch;
    }

    .nav-links.open {
        display: flex;
        animation: slideDown .2s ease
    }

    .nav-links a {
        padding: .6rem .8rem;
        border-radius: var(--radius);
        text-align: center;
    }

    .nav-dropdown {
        width: 100%;
    }

    .nav-dropdown-toggle {
        width: 100%;
        padding: .6rem .8rem;
        border-radius: var(--radius);
        justify-content: center;
        text-align: center;
    }

    .nav-dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: transparent;
        padding: .25rem 0 0 0;
        min-width: 0;
        animation: none;
    }

    .nav-dropdown-menu a {
        padding: .5rem .8rem;
        justify-content: center;
        text-align: center;
    }

    .nav-dropdown-divider {
        display: none;
    }

    .nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center
    }

    .theme-toggle {
        margin-right: .5rem
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

@media(min-width:769px) and (max-width:1024px) {
    .container {
        padding: 1.25rem
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr)
    }

    .nav-links {
        gap: .2rem
    }

    .nav-links a {
        padding: .4rem .6rem;
        font-size: .82rem
    }
}

@media(min-width:1025px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
    }
}

@media(min-width:1440px) {
    .container {
        max-width: 1200px;
        padding: 2rem
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem
    }

    .stat-number {
        font-size: 2rem
    }

    .section {
        padding: 2rem
    }

    .data-table {
        font-size: .88rem
    }

    .data-table th,
    .data-table td {
        padding: .7rem .85rem
    }
}

.backup-zone {
    max-width: 600px;
    margin: 3rem auto 2rem auto;
    padding: 1.5rem 2rem;
    border: 1px solid var(--success);
    border-radius: var(--radius-lg);
    background: rgba(46, 204, 113, 0.05);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.1);
}

.backup-zone h2 {
    color: var(--success);
    margin: 0 0 0.75rem 0;
    font-size: 1.25rem;
    border-bottom: 1px solid var(--success-border);
    padding-bottom: 0.75rem;
}

.backup-zone-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    margin-top: 1.25rem;
}

.backup-zone-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.35rem;
}

.danger-zone {
    max-width: 600px;
    margin: 2rem auto 3rem auto;
    padding: 1.5rem 2rem;
    border: 1px solid var(--danger);
    border-radius: var(--radius-lg);
    background: var(--alert-error-bg);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.1);
}

.danger-zone h2 {
    color: var(--danger-hover);
    margin: 0 0 0.75rem 0;
    font-size: 1.25rem;
    border-bottom: 1px solid var(--alert-error-border);
    padding-bottom: 0.75rem;
}

.danger-zone-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    margin-top: 1.25rem;
}

.danger-zone-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.35rem;
}

@media (max-width: 650px) {

    .danger-zone-content,
    .backup-zone-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .danger-zone button,
    .backup-zone button {
        width: 100%;
        margin-top: 0.5rem;
    }
}

@media(max-width:768px) {

    /* Responsive Data Table Container */
    .table-responsive {
        overflow-x: hidden;
    }

    /* Responsive Data Table */
    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table th,
    .data-table td,
    .data-table tr {
        display: block;
    }

    /* Hide table headers (but not display: none;, for accessibility) */
    .data-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .data-table tr {
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        margin-bottom: 1rem;
        background: var(--surface2);
        padding: 0.5rem;
    }

    .data-table td {
        /* Behave  like a "row" */
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        position: relative;
        padding: 0.75rem !important;
        text-align: right;
        min-height: 2.5rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        max-width: 100%;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .data-table td::before {
        /* Pseudo headers using CSS data attributes would be ideal, but we'll use a standard block approach for dynamic tables */
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.75rem;
        flex-shrink: 0;
    }

    .data-table td:last-child {
        border-bottom: 0;
        justify-content: center;
    }

    .data-table td:last-child::before {
        display: none;
    }

    .table-input {
        width: 100%;
        min-width: 0;
        text-align: right;
    }

    .actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        justify-content: center !important;
        gap: 0.5rem;
    }

    .inline-edit {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    /* Plans Area Mobile Override */
    td[data-label="Plans (Months & Price)"] {
        flex-direction: column;
        align-items: flex-start !important;
        text-align: left !important;
    }

    td[data-label="Plans (Months & Price)"]>div {
        width: 100%;
        justify-content: flex-start;
    }
}