/* ============================================
   MARKASBOT Design System
   Dark/Light Mode · Premium SaaS Dashboard
   ============================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ============================================
   CSS Custom Properties — Dark Theme (default)
   ============================================ */
:root,
.theme-dark {
    --bg-primary: #0c0e14;
    --bg-secondary: #12151e;
    --bg-card: #171b26;
    --bg-card-hover: #1c2030;
    --bg-input: #0f1219;
    --bg-sidebar: #0e1018;
    --bg-topbar: rgba(12, 14, 20, .85);
    --border: rgba(255, 255, 255, .06);
    --border-hover: rgba(255, 255, 255, .12);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #475569;
    --brand: #1a3a6b;
    --brand-hover: #244e8a;
    --brand-glow: rgba(26, 58, 107, .15);
    --brand-text: #5b9bd5;
    --accent: #c9a94e;
    --accent-hover: #d4b85c;
    --accent-glow: rgba(201, 169, 78, .12);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, .1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, .1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, .1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, .1);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, .3), 0 0 0 1px var(--border);
    --shadow-card-hover: 0 8px 25px rgba(0, 0, 0, .35), 0 0 0 1px var(--border-hover);
    --radius: 12px;
    --radius-lg: 16px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --transition: .2s cubic-bezier(.4, 0, .2, 1);
}

/* ============================================
   CSS Custom Properties — Light Theme
   ============================================ */
.theme-light {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-topbar: rgba(255, 255, 255, .92);
    --border: rgba(0, 0, 0, .10);
    --border-hover: rgba(0, 0, 0, .18);
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #475569;
    --brand: #14305e;
    --brand-hover: #1a3a6b;
    --brand-glow: rgba(20, 48, 94, .06);
    --brand-text: #14305e;
    --accent: #92750e;
    --accent-hover: #b8962e;
    --accent-glow: rgba(146, 117, 14, .08);
    --success: #047857;
    --success-bg: rgba(4, 120, 87, .08);
    --warning: #b45309;
    --warning-bg: rgba(180, 83, 9, .08);
    --danger: #b91c1c;
    --danger-bg: rgba(185, 28, 28, .08);
    --info: #1d4ed8;
    --info-bg: rgba(29, 78, 216, .06);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, .08), 0 0 0 1px var(--border);
    --shadow-card-hover: 0 8px 25px rgba(0, 0, 0, .10), 0 0 0 1px var(--border-hover);
}

/* ── Light Theme — Component Overrides ── */
.theme-light .sidebar {
    background: #fff;
    border-right-color: rgba(0, 0, 0, .08);
    box-shadow: 1px 0 3px rgba(0, 0, 0, .04);
}

.theme-light .sidebar-link.active {
    color: #14305e;
    background: rgba(20, 48, 94, .08);
}

.theme-light .sidebar-link:hover {
    color: #0f172a;
    background: rgba(0, 0, 0, .04);
}

.theme-light .topbar {
    background: rgba(255, 255, 255, .92);
    border-bottom-color: rgba(0, 0, 0, .06);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.theme-light .topbar-btn {
    border-color: rgba(0, 0, 0, .1);
    color: #334155;
}

.theme-light .topbar-btn:hover {
    background: rgba(20, 48, 94, .06);
    color: #14305e;
    border-color: #14305e;
}

.theme-light table thead th {
    background: #f8fafc;
    color: #334155;
    border-bottom-color: rgba(0, 0, 0, .08);
}

.theme-light table tbody td {
    color: #334155;
    border-bottom-color: rgba(0, 0, 0, .05);
}

.theme-light table tbody tr:hover {
    background: rgba(0, 0, 0, .02);
}

.theme-light .form-input,
.theme-light .form-select,
.theme-light .form-textarea {
    background: #f8fafc;
    border-color: rgba(0, 0, 0, .12);
    color: #0f172a;
}

.theme-light .form-input:focus,
.theme-light .form-select:focus,
.theme-light .form-textarea:focus {
    border-color: #14305e;
    box-shadow: 0 0 0 3px rgba(20, 48, 94, .08);
}

.theme-light .form-label {
    color: #334155;
}

.theme-light .card {
    border-color: rgba(0, 0, 0, .08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .05);
}

.theme-light .stat-card {
    border-color: rgba(0, 0, 0, .06);
}

.theme-light .stat-label {
    color: #475569;
}

.theme-light .alert-info {
    background: rgba(29, 78, 216, .06);
    color: #1d4ed8;
}

.theme-light .alert-success {
    background: rgba(4, 120, 87, .06);
    color: #047857;
}

.theme-light .alert-error {
    background: rgba(185, 28, 28, .06);
    color: #b91c1c;
}

.theme-light .alert-warning {
    background: rgba(180, 83, 9, .06);
    color: #b45309;
}

.theme-light .badge-brand {
    background: rgba(20, 48, 94, .08);
    color: #14305e;
}

.theme-light .filter-pill {
    background: #fff;
    border-color: rgba(0, 0, 0, .08);
    color: #334155;
}

.theme-light .filter-pill:hover,
.theme-light .filter-pill.active {
    background: #14305e;
    color: #fff;
    border-color: #14305e;
}

.theme-light .proof-box {
    background: #f8fafc;
    border-color: rgba(0, 0, 0, .12);
}

.theme-light .pkg-card {
    border-color: rgba(0, 0, 0, .08);
}

.theme-light .pkg-card:hover {
    border-color: #14305e;
    box-shadow: 0 0 0 1px #14305e, 0 8px 25px rgba(0, 0, 0, .08);
}

.theme-light .product-card {
    border-color: rgba(0, 0, 0, .08);
}

.theme-light .tutorial-card {
    border-color: rgba(0, 0, 0, .08);
}

.theme-light .license-key {
    background: rgba(20, 48, 94, .06);
    color: #14305e;
}

.theme-light .ref-link {
    color: #475569;
}

.theme-light .quick-action {
    border-color: rgba(0, 0, 0, .08);
    color: #334155;
}

.theme-light .quick-action:hover {
    border-color: #14305e;
    color: #14305e;
}

.theme-light .sidebar-overlay.active {
    background: rgba(0, 0, 0, .25);
}

.theme-light .sidebar.open {
    box-shadow: 8px 0 30px rgba(0, 0, 0, .1);
}

/* File upload dropzone */
.upload-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-input);
}

.upload-dropzone:hover {
    border-color: var(--brand);
    background: var(--brand-glow);
}

.upload-dropzone input[type="file"] {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Tutorial action button (download/link) */
.tutorial-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, #0f2847, var(--brand), #244e8a);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition);
    border: 1px solid var(--accent);
}

.tutorial-action-btn:hover {
    background: linear-gradient(135deg, var(--brand), #244e8a, #2d5ea0);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 58, 107, .3);
}

/* ============================================
   Reset & Base
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

a:hover {
    color: var(--brand-hover);
}

img {
    max-width: 100%;
    height: auto;
}

::selection {
    background: var(--brand);
    color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================
   Layout: Sidebar + Main
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 2px solid var(--accent);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-brand-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.3px;
}

.sidebar-brand-sub {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.sidebar-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    padding: 12px 10px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
    text-decoration: none;
}

.sidebar-link:hover {
    color: var(--text-primary);
    background: var(--brand-glow);
}

.sidebar-link.active {
    color: var(--brand);
    background: var(--brand-glow);
    font-weight: 600;
}

.sidebar-link .icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.sidebar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #0f2847, var(--brand), #244e8a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-user-role {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Topbar --- */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-topbar);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.3px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-size: 16px;
}

.topbar-btn:hover {
    background: var(--brand-glow);
    color: var(--brand);
    border-color: var(--brand);
}

.mobile-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 20px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* --- Page Content --- */
.page-content {
    flex: 1;
    padding: 28px;
    width: 100%;
}

/* ============================================
   Auth Layout (no sidebar)
   ============================================ */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.auth-layout::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    top: -200px;
    right: -200px;
    pointer-events: none;
}

.auth-layout::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, var(--brand-glow), transparent 70%);
    bottom: -150px;
    left: -150px;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: 2px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: var(--shadow-card);
    position: relative;
    z-index: 1;
}

.auth-card.wide {
    max-width: 560px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 28px;
}

.auth-brand-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 12px;
    border-radius: 14px;
    overflow: hidden;
}

.auth-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.auth-brand h1 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -.5px;
}

.auth-brand p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Floating Theme Toggle for Auth Pages --- */
.auth-theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition);
    box-shadow: var(--shadow-card);
}

.auth-theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-card-hover);
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-card-hover);
}

.card-flush {
    padding: 0;
}

.card-flush .card-header {
    padding: 16px 20px;
}

.card-flush .table-wrap {
    padding: 0;
}

.card-flush .empty-state {
    padding: 40px 20px;
}

.card-header {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header .badge {
    margin-left: auto;
}

/* ============================================
   Stats Cards
   ============================================ */
.stats-grid {
    display: grid;
    gap: 16px;
}

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

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

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
}

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

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .8px;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
    line-height: 1;
}

.stat-sm {
    font-size: 20px;
    letter-spacing: -.5px;
}

/* ============================================
   Welcome Card
   ============================================ */
.welcome-card {
    background: linear-gradient(135deg, #0f2847, var(--brand), #244e8a);
    border-radius: var(--radius-lg);
    border-bottom: 2px solid var(--accent);
    padding: 28px 32px;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.welcome-card::after {
    content: '';
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255, 255, 255, .08), transparent 70%);
    top: -100px;
    right: -80px;
    pointer-events: none;
}

.welcome-card h2 {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
    position: relative;
    z-index: 1;
}

.welcome-card p {
    font-size: 13px;
    color: rgba(255, 255, 255, .75);
    position: relative;
    z-index: 1;
}

/* ============================================
   Tables
   ============================================ */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    vertical-align: middle;
}

tbody tr:hover {
    background: var(--brand-glow);
}

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

/* ============================================
   Buttons
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:active {
    transform: scale(.97);
}

.btn-primary {
    background: linear-gradient(135deg, #0f2847, var(--brand), #244e8a);
    color: #fff;
    border: 1px solid var(--accent);
    box-shadow: 0 2px 8px rgba(26, 58, 107, .3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--brand), #244e8a, #2d5ea0);
    box-shadow: 0 4px 16px rgba(26, 58, 107, .45);
    color: #fff;
    transform: translateY(-1px);
}

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

.btn-success:hover {
    filter: brightness(1.1);
    color: #fff;
}

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

.btn-danger:hover {
    filter: brightness(1.1);
    color: #fff;
}

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

.btn-warning:hover {
    filter: brightness(1.1);
    color: #fff;
}

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

.btn-outline:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-glow);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
}

.btn-ghost:hover {
    color: var(--brand);
    background: var(--brand-glow);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 12px;
}

.btn-xs {
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 6px;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 15px;
}

.btn:disabled,
.btn.disabled {
    opacity: .5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ============================================
   Badges
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

.badge-brand {
    background: var(--brand-glow);
    color: var(--brand);
}

.badge-member {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.theme-light .badge-member {
    background: #eff6ff;
    color: #2563eb;
}

/* ============================================
   Forms
   ============================================ */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-glow);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ============================================
   Search Toolbar
   ============================================ */
.search-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition);
}

.search-box input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-glow);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 14px;
    z-index: 2;
    line-height: 1;
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    cursor: pointer;
    background: none;
    border: none;
    padding: 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    z-index: 3;
}

.search-clear:hover {
    color: var(--danger);
}

.search-shortcut {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    background: var(--bg-card);
    pointer-events: none;
    opacity: 0.7;
}

/* Hide shortcut when input has value (user typing) or clear button is present */
.search-box input:not(:placeholder-shown) ~ .search-shortcut,
.search-clear ~ .search-shortcut {
    display: none;
}

.filter-select {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    outline: none;
    cursor: pointer;
    min-width: 140px;
}

.filter-select:focus {
    border-color: var(--brand);
}

/* Table Actions */
.table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 11px;
    height: 28px;
}

.form-input-xs {
    height: 28px;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    text-align: center;
}


/* ============================================
   Custom Searchable Select
   ============================================ */
.searchable-select {
    position: relative;
    width: 100%;
}

.searchable-select-input {
    width: 100%;
    cursor: text;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.searchable-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card-hover);
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    margin-top: 4px;
}

.searchable-select-dropdown.show {
    display: block;
}

.searchable-select-option {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.searchable-select-option:last-child {
    border-bottom: none;
}

.searchable-select-option:hover,
.searchable-select-option.selected {
    background: var(--brand-glow);
    color: var(--brand-text);
}

.searchable-select-option .sub-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ============================================
   Alerts / Flash Messages
   ============================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideDown .3s ease;
}

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

.alert-error {
    background: var(--danger-bg);
    color: var(--danger);
    border-left: 3px solid var(--danger);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning);
    border-left: 3px solid var(--warning);
}

.alert-info {
    background: var(--info-bg);
    color: var(--info);
    border-left: 3px solid var(--info);
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
}

.empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: .5;
}

.empty-text {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ============================================
   Package Cards (Order page)
   ============================================ */
.pkg-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: all var(--transition);
}

.pkg-card:hover {
    border-color: var(--brand);
    box-shadow: 0 0 0 1px var(--brand), var(--shadow-card-hover);
    transform: translateY(-2px);
}

.pkg-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.pkg-price {
    font-size: 22px;
    font-weight: 800;
    color: var(--brand);
    letter-spacing: -.5px;
    margin-bottom: 2px;
}

.pkg-duration {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ============================================
   Bank Card
   ============================================ */
.bank-card {
    background: linear-gradient(135deg, #0f2847, var(--brand), #244e8a);
    border-top: 2px solid var(--accent);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    color: #fff;
}

.bank-name {
    font-size: 12px;
    font-weight: 600;
    opacity: .8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bank-account {
    font-size: 22px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    margin: 6px 0 4px;
    letter-spacing: 1px;
}

.bank-holder {
    font-size: 13px;
    opacity: .8;
}

/* ============================================
   Referral Link
   ============================================ */
.ref-link {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    word-break: break-all;
    padding: 6px 0;
}

/* ============================================
   License Key Display
   ============================================ */
.license-key {
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 600;
    color: var(--brand);
    letter-spacing: 1px;
    background: var(--brand-glow);
    padding: 6px 12px;
    border-radius: 6px;
    display: inline-block;
}

/* ============================================
   Product Card (Catalog)
   ============================================ */
.product-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    transition: all var(--transition);
}

.product-card:hover {
    border-color: var(--brand);
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
}

.product-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.product-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.product-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.5;
}

/* ============================================
   Tutorial Card
   ============================================ */
.tutorial-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    transition: all var(--transition);
}

.tutorial-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-card-hover);
}

.tutorial-card h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.tutorial-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.tutorial-video {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: var(--radius-sm);
    border: none;
    margin-bottom: 12px;
}

/* ============================================
   Quick Action Buttons
   ============================================ */
.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
}

.quick-action:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-glow);
}

/* ============================================
   Filter Pills
   ============================================ */
.filter-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.filter-pill {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.filter-pill:hover,
.filter-pill.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

/* ============================================
   Proof Upload
   ============================================ */
.proof-box {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
}

.proof-box input[type="file"] {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ============================================
   List Steps (ordered)
   ============================================ */
.list-steps {
    list-style: none;
    counter-reset: step;
    padding: 0;
}

.list-steps li {
    counter-increment: step;
    padding: 10px 0 10px 36px;
    position: relative;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.list-steps li:last-child {
    border-bottom: none;
}

.list-steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--brand-glow);
    color: var(--brand);
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   Sidebar Overlay (mobile)
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 99;
    opacity: 0;
    transition: opacity .3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================
   Profile Avatar (big)
   ============================================ */
.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: linear-gradient(135deg, #0f2847, var(--brand), #244e8a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 16px;
}

/* ============================================
   Utility Classes
   ============================================ */
.text-white {
    color: var(--text-primary) !important;
}

.text-brand {
    color: var(--brand) !important;
}

.text-green {
    color: var(--success) !important;
}

.text-yellow {
    color: var(--warning) !important;
}

.text-red {
    color: var(--danger) !important;
}

.text-purple {
    color: var(--accent) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-xs {
    font-size: 11px !important;
}

.text-sm {
    font-size: 12px !important;
}

.text-base {
    font-size: 14px !important;
}

.text-lg {
    font-size: 18px !important;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace !important;
}

.font-medium {
    font-weight: 500 !important;
}

.font-semibold {
    font-weight: 600 !important;
}

.font-bold {
    font-weight: 700 !important;
}

.flex {
    display: flex !important;
}

.inline-flex {
    display: inline-flex !important;
}

.items-center {
    align-items: center !important;
}

.justify-between {
    justify-content: space-between !important;
}

.justify-center {
    justify-content: center !important;
}

.flex-wrap {
    flex-wrap: wrap !important;
}

.flex-1 {
    flex: 1 !important;
}

.gap-2 {
    gap: 8px !important;
}

.gap-3 {
    gap: 12px !important;
}

.gap-4 {
    gap: 16px !important;
}

.grid {
    display: grid !important;
}

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

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

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.mb-2 {
    margin-bottom: 8px !important;
}

.mb-3 {
    margin-bottom: 12px !important;
}

.mb-4 {
    margin-bottom: 16px !important;
}

.mb-5 {
    margin-bottom: 24px !important;
}

.mt-3 {
    margin-top: 12px !important;
}

.mt-4 {
    margin-top: 16px !important;
}

.py-2 {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

.space-y-3>*+* {
    margin-top: 12px;
}

.space-y-4>*+* {
    margin-top: 16px;
}

.text-center {
    text-align: center !important;
}

.text-right {
    text-align: right !important;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hidden {
    display: none !important;
}

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

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(.96);
    }

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

.animate-page {
    animation: scaleIn .25s ease;
}

/* ============================================
   Responsive — Tablet
   ============================================ */
@media (max-width: 1024px) {
    .stats-4 {
        grid-template-columns: repeat(2, 1fr);
    }

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

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

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

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Responsive — Mobile
   ============================================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, .3);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-toggle {
        display: flex;
    }

    .topbar {
        padding: 0 16px;
    }

    .page-content {
        padding: 20px 16px;
    }

    .stats-3,
    .stats-4,
    .stats-6 {
        grid-template-columns: 1fr 1fr;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .auth-card {
        margin: 16px;
        padding: 24px;
    }

    .welcome-card {
        padding: 20px;
    }

    .welcome-card h2 {
        font-size: 16px;
    }

    .stat-value {
        font-size: 22px;
    }
}

@media (max-width: 480px) {

    .stats-3,
    .stats-4 {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        flex-direction: column;
    }

    .filter-pills {
        flex-direction: column;
    }
}

/* ============================================
   Tables & Pagination
   ============================================ */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    white-space: nowrap;
}

th, td {
    padding: 14px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.8px;
    background: rgba(0,0,0,0.2);
}

td {
    color: var(--text-primary);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
    background: rgba(0,0,0,0.1);
}

.table-info {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination {
    display: flex;
    gap: 6px;
}

.pagination a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    border-radius: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
}

.pagination a:hover:not(.disabled) {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}

.pagination a.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
    pointer-events: none;
}

.pagination a.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: transparent;
    border-color: transparent;
}

/* ============================================
   Manual License Form & Fixes
   ============================================ */
.manual-license-form {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.manual-license-form .form-group {
    margin-bottom: 0;
}

/* Force equal height for inputs and button for perfect alignment */
.manual-license-form .form-input,
.manual-license-form .form-select,
.manual-license-form .btn-generate {
    height: 42px;
    padding-top: 0;
    padding-bottom: 0;
    display: flex;
    align-items: center;
}

.manual-license-form .form-input,
.manual-license-form .form-select {
    padding-left: 12px;
}

.manual-license-form .btn-generate {
    justify-content: center;
}

/* Searchable Select Tweaks */
.searchable-select-input {
    padding-right: 36px !important; /* Space for chevron/clear */
}

.searchable-select .search-clear {
    right: 30px;
    color: var(--text-muted);
}

.searchable-select .search-clear:hover {
    color: var(--danger);
}

@media (max-width: 768px) {
    .d-none-mobile {
        display: none;
    }
    .manual-license-form {
        flex-direction: column;
        align-items: stretch;
    }
    .manual-license-form .form-group {
        width: 100% !important;
        flex: none !important;
        min-width: 0 !important;
        margin-bottom: 12px;
    }
    .manual-license-form .btn-generate {
        margin-top: 4px;
    }
}

/* ============================================
   Modal / Dialog
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card-hover);
    transform: scale(0.95);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

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

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-secondary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}