/* ========================================
   D4T4 — Clean Dark Theme
   Professional SaaS design
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: rgba(139, 92, 246, 0.15);
    --secondary: #3b82f6;
    --secondary-light: rgba(59, 130, 246, 0.15);
    --accent: #ec4899;
    --accent-light: rgba(236, 72, 153, 0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --danger: #ef4444;

    --bg: #09090b;
    --bg-card: rgba(255, 255, 255, 0.03);
    --bg-elevated: rgba(255, 255, 255, 0.06);
    --bg-tertiary: rgba(255, 255, 255, 0.08);

    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    --border-focus: rgba(139, 92, 246, 0.5);

    --text: #e4e4e7;
    --text-bright: #fafafa;
    --text-muted: #71717a;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 24px rgba(139, 92, 246, 0.15);
    --glow: var(--shadow-glow);
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg); color: var(--text);
    line-height: 1.6; overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-dark); }

/* Hide legacy effects */
#matrix-bg, .scanlines, .cursor { display: none !important; }

/* ── Reusable Layout ── */
.container { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.page-wrap { min-height: 100vh; padding: 84px 24px 40px; }
.page-container { max-width: 960px; margin: 0 auto; }
.page-wide { max-width: 1100px; margin: 0 auto; }
.text-muted { color: var(--text-muted); }

/* ── Reusable Cards ── */
.section-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 16px;
}
.section-card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.section-card-header h2 {
    font-size: 0.92rem; font-weight: 600; color: var(--text-bright);
}
.section-card-body { padding: 20px; }

.section-heading {
    font-size: 0.82rem; font-weight: 600; color: var(--text-bright);
    margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.section-heading .count {
    font-size: 0.6rem; background: var(--primary); color: #fff;
    padding: 1px 7px; border-radius: 8px; font-weight: 700;
}

/* ── Navigation ── */
.nav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    background: rgba(9, 9, 11, 0.8); border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
.nav .container {
    display: flex; justify-content: space-between; align-items: center; height: 56px;
}
.nav-logo {
    font-size: 1.25rem; font-weight: 800; text-decoration: none;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #8b5cf6, #3b82f6);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
    color: var(--text-muted); text-decoration: none; font-size: 0.8rem;
    font-weight: 500; padding: 6px 12px; border-radius: var(--radius-sm);
    transition: all 0.15s;
}
.nav-links a:hover, .nav-links a.active {
    color: var(--text-bright); background: rgba(255, 255, 255, 0.05);
}

/* ── Buttons ── */
.btn-primary {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 22px; background: var(--primary); color: #fff;
    font-family: inherit; font-size: 0.85rem; font-weight: 600;
    border: none; border-radius: var(--radius); cursor: pointer; transition: all 0.15s;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-glow); color: #fff; }

.btn-outline {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 22px; background: transparent; color: var(--text);
    font-family: inherit; font-size: 0.85rem; font-weight: 500;
    border: 1px solid var(--border-light); border-radius: var(--radius);
    cursor: pointer; transition: all 0.15s;
}
.btn-outline:hover { background: rgba(255,255,255,0.04); border-color: var(--primary); color: var(--primary); }

.btn-sm {
    padding: 6px 14px; font-size: 0.78rem;
}

.btn-danger {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 22px; background: transparent; color: var(--danger);
    font-family: inherit; font-size: 0.85rem; font-weight: 500;
    border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius);
    cursor: pointer; transition: all 0.15s;
}
.btn-danger:hover { background: rgba(239,68,68,0.1); border-color: var(--danger); }

.btn-logout {
    padding: 7px 14px; background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger);
    font-family: inherit; font-size: 0.78rem; font-weight: 500;
    cursor: pointer; text-decoration: none;
    border-radius: var(--radius-sm); transition: all 0.15s;
}
.btn-logout:hover { background: rgba(239, 68, 68, 0.1); border-color: var(--danger); color: var(--danger); }

.btn-copy {
    padding: 6px 12px; background: transparent;
    border: 1px solid var(--border); color: var(--text-muted);
    font-family: inherit; font-size: 0.72rem; cursor: pointer;
    border-radius: var(--radius-sm); transition: all 0.15s;
}
.btn-copy:hover { border-color: var(--primary); color: var(--primary); }
.btn-copy.copied { border-color: var(--success); color: var(--success); background: var(--success-light); }

/* ── Alerts ── */
.alert {
    padding: 12px 16px; border: 1px solid; font-size: 0.82rem;
    margin-bottom: 16px; border-radius: var(--radius);
}
.alert-error { border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.08); color: var(--danger); }
.alert-success { border-color: rgba(16,185,129,0.3); background: var(--success-light); color: var(--success); }
.alert-info { border-color: rgba(59,130,246,0.3); background: var(--secondary-light); color: var(--secondary); }
.alert-warning { border-color: rgba(245,158,11,0.3); background: var(--warning-light); color: var(--warning); }

/* ── Forms (shared) ── */
.form-group label {
    display: block; font-size: 0.75rem; font-weight: 500;
    color: var(--text-muted); margin-bottom: 5px;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font-family: inherit; font-size: 0.85rem;
    transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.12);
}
.form-group input::placeholder, .form-group textarea::placeholder {
    color: var(--text-muted); font-size: 0.78rem;
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-hint { display: block; font-size: 0.68rem; color: var(--text-muted); margin-top: 3px; }
.field-hint { display: block; font-size: 0.68rem; margin-top: 3px; }

/* ── Role System ── */
.role-badge {
    display: inline-block; padding: 3px 10px;
    font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: #fff; border-radius: 4px;
}
.role-badge.small { padding: 2px 8px; font-size: 0.62rem; }

/* ── Status Badges ── */
.status-badge-active { color: var(--success); }
.status-badge-maintenance { color: var(--warning); }
.status-badge-disabled { color: var(--danger); }
.status-badge-updating { color: var(--secondary); }

/* ── Tags ── */
.thread-tag {
    font-size: 0.58rem; padding: 2px 8px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    display: inline-block; border-radius: 4px;
}

/* ── Dashboard Page ── */
.dashboard-page { min-height: 100vh; padding: 84px 24px 40px; }
.dashboard-container, .admin-container { max-width: 960px; margin: 0 auto; }
.dashboard-header {
    display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
}
.dashboard-header h1 { font-size: 1.2rem; font-weight: 700; color: var(--text-bright); }

/* ── Admin Panel ── */
.admin-container { max-width: 1100px; }
.admin-stats { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-stat {
    flex: 1; min-width: 100px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px; text-align: center;
}
.admin-stat-value { display: block; font-size: 1.4rem; font-weight: 700; color: var(--text-bright); }
.admin-stat-label {
    font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.06em; margin-top: 3px; display: block; font-weight: 500;
}
.admin-tabs {
    display: flex; gap: 2px; margin-bottom: 20px;
    border-bottom: 1px solid var(--border); overflow-x: auto;
}
.admin-tab {
    padding: 10px 18px; background: none; border: none;
    border-bottom: 2px solid transparent; color: var(--text-muted);
    font-family: inherit; font-size: 0.8rem; font-weight: 500;
    cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); margin-bottom: 20px; overflow: hidden;
}
.admin-panel-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px;
}
.admin-panel-header h2 { font-size: 0.92rem; font-weight: 600; color: var(--text-bright); }
.admin-search input {
    padding: 8px 12px; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font-family: inherit; font-size: 0.82rem;
    min-width: 200px; transition: border-color 0.15s;
}
.admin-search input:focus { outline: none; border-color: var(--primary); }

/* Admin Table */
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.admin-table th {
    padding: 10px 14px; text-align: left; font-size: 0.7rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
    border-bottom: 1px solid var(--border); background: var(--bg-elevated);
}
.admin-table td {
    padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.admin-table tbody tr:hover { background: rgba(139,92,246,0.03); }
.admin-user-cell { display: flex; flex-direction: column; gap: 2px; }
.admin-user-cell strong { color: var(--text-bright); font-size: 0.82rem; }
.admin-account-id { font-size: 0.7rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

.admin-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.admin-btn {
    padding: 5px 10px; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 0.72rem; cursor: pointer;
    transition: all 0.15s; font-family: inherit; font-weight: 500;
}
.admin-btn:hover { border-color: var(--text-muted); color: var(--text); }
.admin-btn.ban:hover { border-color: var(--danger); color: var(--danger); background: rgba(239,68,68,0.08); }
.admin-btn.suspend:hover { border-color: var(--warning); color: var(--warning); background: var(--warning-light); }
.admin-btn.unban:hover { border-color: var(--success); color: var(--success); background: var(--success-light); }
.admin-btn.delete:hover { border-color: var(--danger); color: var(--danger); }
.admin-btn.role-btn:hover { border-color: var(--secondary); color: var(--secondary); background: var(--secondary-light); }

/* Admin Form */
.admin-form-card {
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius); margin: 16px 20px;
}
.admin-form { padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.admin-form select {
    width: 100%; padding: 10px 12px; background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font-family: inherit; font-size: 0.82rem;
}
.admin-form select:focus { outline: none; border-color: var(--primary); }
.admin-form-row { display: flex; gap: 12px; align-items: flex-end; }

/* Admin Announcements */
.admin-announcements-list { padding: 0 20px 20px; }
.admin-announcement {
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius); margin-top: 10px; padding: 14px;
}
.admin-announcement-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 10px; margin-bottom: 8px; flex-wrap: wrap;
}
.admin-announcement-header strong { color: var(--text-bright); font-size: 0.85rem; }
.admin-announcement-meta { display: flex; align-items: center; gap: 8px; font-size: 0.7rem; color: var(--text-muted); }
.admin-announcement-body { font-size: 0.82rem; color: var(--text); line-height: 1.6; }

.ann-pin { margin-right: 4px; font-size: 0.82rem; }
.ann-priority {
    font-size: 0.62rem; font-weight: 700; padding: 2px 7px;
    text-transform: uppercase; letter-spacing: 0.04em; margin-right: 5px; border-radius: 4px;
}
.ann-priority-info { background: var(--secondary-light); color: var(--secondary); border: 1px solid rgba(59,130,246,0.3); }
.ann-priority-warning { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.ann-priority-critical { background: var(--accent-light); color: var(--accent); border: 1px solid rgba(236,72,153,0.3); }

/* Admin Sellers */
.admin-sellers-list { display: flex; flex-direction: column; gap: 8px; }
.admin-seller-card {
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius); transition: border-color 0.15s;
}
.admin-seller-card:hover { border-color: var(--border-light); }
.admin-seller-header { display: flex; align-items: center; gap: 14px; padding: 12px; }
.admin-seller-logo-wrap { display: flex; flex-direction: column; align-items: center; gap: 5px; flex-shrink: 0; }
.admin-seller-logo { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary); }
.admin-seller-logo-placeholder {
    width: 48px; height: 48px; border-radius: 50%; background: var(--primary-light);
    border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem; color: var(--primary);
}
.admin-seller-logo-actions { display: flex; gap: 4px; }
.admin-seller-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-seller-info strong { color: var(--text-bright); font-size: 0.85rem; }
.admin-seller-actions { display: flex; gap: 5px; flex-shrink: 0; }

/* Admin Audit Log */
.admin-log-list { padding: 14px 20px; }
.admin-log-entry {
    display: flex; gap: 10px; padding: 8px 0;
    border-bottom: 1px solid var(--border); font-size: 0.78rem; align-items: baseline; flex-wrap: wrap;
}
.admin-log-time { color: var(--text-muted); font-family: 'JetBrains Mono', monospace; min-width: 90px; font-size: 0.7rem; }
.admin-log-admin { color: var(--accent); font-weight: 600; min-width: 70px; }
.admin-log-action { color: var(--primary); text-transform: uppercase; font-weight: 600; min-width: 50px; }
.admin-log-details { color: var(--text); }

/* ── Module Admin Cards ── */
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.module-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; transition: border-color 0.15s;
}
.module-card:hover { border-color: var(--border-light); }
.module-card-head {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;
}
.module-card-head h3 { font-size: 0.85rem; font-weight: 600; color: var(--text-bright); }
.module-status-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.module-status-dot.active { background: var(--success); box-shadow: 0 0 6px rgba(16,185,129,0.5); }
.module-status-dot.maintenance { background: var(--warning); box-shadow: 0 0 6px rgba(245,158,11,0.5); }
.module-status-dot.disabled { background: var(--danger); box-shadow: 0 0 6px rgba(239,68,68,0.5); }
.module-status-dot.updating { background: var(--secondary); box-shadow: 0 0 6px rgba(59,130,246,0.5); }
.module-card-desc { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 10px; }
.module-card-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.module-card-controls select {
    padding: 5px 8px; background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: 0.72rem;
}
.module-card-controls input {
    flex: 1; min-width: 120px; padding: 5px 8px; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text); font-family: inherit; font-size: 0.72rem;
}

/* ── Tool Management Sub-tabs ── */
.tool-subtabs {
    display: flex; gap: 0; border-bottom: 1px solid var(--border);
    margin: 0 0 20px; padding: 0 20px;
}
.tool-subtab {
    padding: 10px 18px; background: none; border: none; color: var(--text-muted);
    font-family: inherit; font-size: 0.78rem; font-weight: 500; cursor: pointer;
    border-bottom: 2px solid transparent; transition: all 0.15s;
}
.tool-subtab:hover { color: var(--text); }
.tool-subtab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tool-subpanel { display: none; padding: 0 20px 20px; }
.tool-subpanel.active { display: block; }

/* ── Session Stats ── */
.ts-stats { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.ts-stat {
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 18px; flex: 1; min-width: 110px; text-align: center;
}
.ts-stat-val { display: block; font-size: 1.3rem; font-weight: 700; color: var(--text-bright); }
.ts-stat-val.ts-blue { color: var(--secondary); }
.ts-stat-val.ts-green { color: var(--primary); }
.ts-stat-val.ts-red { color: var(--accent); }
.ts-stat-lbl { display: block; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-top: 3px; }
.ts-pulse-dot {
    width: 6px; height: 6px; border-radius: 50%; background: var(--primary); display: inline-block;
    animation: ts-pulse 2s ease-in-out infinite;
}
@keyframes ts-pulse { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

/* ── Sessions Table ── */
.ts-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.ts-table { width: 100%; border-collapse: collapse; font-size: 0.72rem; }
.ts-table th {
    text-align: left; padding: 10px 12px; background: var(--bg-elevated); color: var(--text-muted);
    font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border);
    white-space: nowrap; font-weight: 600;
}
.ts-table td { padding: 9px 12px; border-bottom: 1px solid rgba(255,255,255,0.03); color: var(--text); white-space: nowrap; }
.ts-table tr:hover td { background: rgba(255,255,255,0.02); }
.ts-tag { display: inline-block; padding: 2px 8px; font-size: 0.58rem; letter-spacing: 0.04em; border-radius: 4px; font-weight: 600; text-transform: uppercase; }
.ts-tag-active, .ts-tag-live { background: rgba(139,92,246,0.12); color: var(--primary); }
.ts-tag-kicked, .ts-tag-killed { background: rgba(236,72,153,0.12); color: var(--accent); }
.ts-tag-offline { background: rgba(100,100,100,0.15); color: var(--text-muted); }

/* ── Kill Switch Product Cards ── */
.ts-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.ts-product-card {
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
    overflow: hidden; transition: border-color 0.15s;
}
.ts-product-card:hover { border-color: var(--border-light); }
.ts-product-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,0.02);
}
.ts-product-name { font-size: 0.82rem; font-weight: 600; color: var(--text-bright); }
.ts-product-body { padding: 14px 16px; }
.ts-field { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.03); }
.ts-field:last-child { border-bottom: none; }
.ts-field-label { color: var(--text-muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; }
.ts-input {
    background: var(--bg); border: 1px solid var(--border); color: var(--text);
    font-family: inherit; font-size: 0.72rem; padding: 5px 10px; border-radius: var(--radius-sm); width: 180px;
}
.ts-input:focus { border-color: var(--primary); outline: none; }

/* Toggle switch */
.ts-toggle {
    position: relative; width: 38px; height: 20px; background: var(--bg);
    border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: all 0.2s;
}
.ts-toggle.danger-on { background: rgba(236,72,153,0.15); border-color: var(--accent); }
.ts-toggle::after {
    content: ''; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px;
    background: var(--text-muted); border-radius: 50%; transition: all 0.2s;
}
.ts-toggle.danger-on::after { left: 21px; background: var(--accent); }

/* ── Role Select Grid ── */
.role-select { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
.role-option {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 8px; background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-muted); font-size: 0.78rem;
    cursor: pointer; transition: all 0.15s; position: relative;
}
.role-option:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.role-option.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.role-option.active::after { content: '\2713'; position: absolute; top: 4px; right: 6px; font-size: 0.7rem; color: var(--primary); font-weight: 700; }
.role-option-icon { font-size: 1.2rem; }
.role-option-label { text-transform: uppercase; letter-spacing: 0.04em; text-align: center; line-height: 1.2; font-weight: 500; }
.admin-role-note { margin-top: 10px; padding: 10px 14px; background: var(--accent-light); border: 1px solid rgba(236,72,153,0.25); border-radius: var(--radius); font-size: 0.78rem; line-height: 1.5; }

/* ── Profile Page ── */
.profile-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); margin-bottom: 20px; overflow: hidden;
}
.profile-body { padding: 28px; }
.profile-avatar-section {
    display: flex; align-items: center; gap: 20px;
    margin-bottom: 28px; padding-bottom: 20px; border-bottom: 1px solid var(--border);
}
.profile-avatar-wrapper { position: relative; width: 72px; height: 72px; flex-shrink: 0; }
.profile-avatar-img { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid var(--primary); }
.profile-avatar-placeholder {
    width: 72px; height: 72px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.3rem; color: #fff; border: 2px solid var(--primary);
}
.avatar-upload-btn {
    position: absolute; bottom: -3px; right: -3px; width: 26px; height: 26px;
    background: var(--bg-card); border: 1px solid var(--primary); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 0.85rem; transition: all 0.15s;
}
.avatar-upload-btn:hover { background: var(--primary); color: #fff; }
.profile-avatar-info h3 { font-size: 1.1rem; color: var(--text-bright); margin-bottom: 2px; }
.profile-avatar-info p { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 3px; }
.profile-member-since { font-size: 0.7rem; color: var(--primary); }
.profile-form { display: flex; flex-direction: column; gap: 16px; margin-bottom: 28px; }
.profile-form textarea {
    width: 100%; padding: 10px 12px; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font-family: inherit; font-size: 0.85rem;
    resize: vertical; min-height: 80px; transition: border-color 0.15s;
}
.profile-form textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(139,92,246,0.12); }
.profile-form textarea::placeholder { color: var(--text-muted); }
.profile-form-actions { display: flex; align-items: center; gap: 14px; }
.profile-form-actions .btn-login, .profile-form-actions .btn-primary { width: auto; padding: 10px 22px; }
.btn-cancel-link { font-size: 0.82rem; color: var(--text-muted); text-decoration: none; }
.btn-cancel-link:hover { color: var(--text); }
.profile-readonly { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); }
.profile-readonly-body { padding: 4px 0; }
.readonly-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.readonly-row:last-child { border-bottom: none; }
.readonly-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.readonly-value { font-size: 0.82rem; color: var(--text); }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px); z-index: 1000;
    display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); width: 100%; max-width: 420px; box-shadow: var(--shadow-lg);
}
.modal-body { padding: 24px; }
.modal-body h3 { color: var(--text-bright); margin-bottom: 8px; }
.modal-body select {
    width: 100%; padding: 10px 12px; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: var(--radius);
    color: var(--text); font-family: inherit; font-size: 0.82rem;
}
.modal-body select:focus { outline: none; border-color: var(--primary); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ── Login Page ── */
.login-page {
    min-height: 100vh; display: flex; align-items: center;
    justify-content: center; padding: 24px; background: var(--bg);
}
.login-container { width: 100%; max-width: 420px; }
.login-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; padding: 32px 28px 0; }
.login-logo {
    font-size: 1.8rem; font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    text-decoration: none;
}
.login-subtitle { color: var(--text-muted); font-size: 0.85rem; margin-top: 6px; }
.login-tabs {
    display: flex; margin: 20px 28px; background: var(--bg-elevated);
    border-radius: var(--radius); padding: 3px;
}
.tab-btn {
    flex: 1; padding: 9px; background: transparent; border: none;
    border-radius: var(--radius-sm); font-family: inherit; font-size: 0.78rem;
    font-weight: 500; color: var(--text-muted); cursor: pointer; transition: all 0.15s;
}
.tab-btn.active { background: var(--primary); color: #fff; }
.tab-btn:not(.active):hover { color: var(--text); }
.login-form { display: flex; flex-direction: column; gap: 16px; padding: 0 28px; }
.btn-login {
    width: 100%; padding: 10px; background: var(--primary); color: #fff;
    font-family: inherit; font-size: 0.85rem; font-weight: 600;
    border: none; border-radius: var(--radius); cursor: pointer; transition: opacity 0.15s;
}
.btn-login:hover { opacity: 0.9; }
.remember-me { padding: 0 28px 8px; }
.remember-label {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.78rem; color: var(--text-muted); cursor: pointer; user-select: none;
}
.remember-label input[type="checkbox"] { display: none; }
.remember-check {
    width: 16px; height: 16px; border: 1px solid var(--border);
    border-radius: 4px; background: var(--bg-elevated);
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all 0.15s;
}
.remember-label input:checked + .remember-check { border-color: var(--primary); background: var(--primary); }
.remember-label input:checked + .remember-check::after { content: '\2713'; color: #fff; font-size: 0.6rem; font-weight: 700; }
.login-divider { text-align: center; padding: 18px 0; position: relative; }
.login-divider::before { content: ''; position: absolute; left: 28px; right: 28px; top: 50%; height: 1px; background: var(--border); }
.login-divider span { position: relative; background: var(--bg-card); padding: 0 14px; color: var(--text-muted); font-size: 0.72rem; }
.login-footer { text-align: center; padding: 18px 28px 28px; font-size: 0.78rem; }
.login-footer a { color: var(--primary); }
.login-footer a:hover { opacity: 0.8; }

/* Generate account */
.generate-section { padding: 0 28px 28px; }
.generate-btn {
    width: 100%; padding: 12px; background: transparent;
    border: 2px dashed var(--border-light); color: var(--primary);
    font-family: inherit; font-size: 0.85rem; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    border-radius: var(--radius);
}
.generate-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.generate-btn .icon { font-size: 1.1rem; }
.credentials-card {
    background: var(--bg-elevated); border: 1px solid var(--primary);
    border-radius: var(--radius-lg); margin: 0 28px 28px; box-shadow: var(--shadow-glow); overflow: hidden;
}
.credentials-header {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}
.credentials-header .badge {
    padding: 3px 8px; background: var(--primary); color: #fff;
    font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; border-radius: 4px;
}
.credentials-header .warning-text { font-size: 0.78rem; color: var(--warning); }
.credentials-body { padding: 16px; }
.credential-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 8px;
}
.credential-row:last-child { margin-bottom: 0; }
.credential-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 3px; }
.credential-value { font-family: 'JetBrains Mono', monospace; font-size: 0.9rem; color: var(--primary); font-weight: 600; word-break: break-all; }
.credentials-warning {
    padding: 10px 12px; border: 1px solid rgba(245,158,11,0.25); background: var(--warning-light);
    margin-top: 12px; font-size: 0.78rem; color: var(--warning); line-height: 1.5; border-radius: var(--radius);
}
.credentials-warning strong { color: var(--warning); }

/* ── Dashboard Announcements ── */
.dash-section-title {
    font-size: 1rem; font-weight: 600; color: var(--text-bright);
    margin-bottom: 12px; margin-top: 20px;
    display: flex; align-items: center; gap: 8px;
}
.section-icon { font-size: 0.95rem; color: var(--secondary); }
.ann-count {
    font-size: 0.6rem; background: var(--secondary); color: #fff;
    padding: 2px 7px; font-weight: 700; border-radius: 10px; margin-left: 4px;
}
.dash-announcements { margin-top: 8px; }
.dash-announcement {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px;
    transition: border-color 0.15s; position: relative; overflow: hidden;
}
.dash-announcement:hover { border-color: var(--border-light); }
.dash-announcement-info { border-left: 3px solid var(--secondary); }
.dash-announcement-warning { border-left: 3px solid var(--warning); background: rgba(245,158,11,0.02); }
.dash-announcement-critical { border-left: 3px solid var(--accent); background: rgba(236,72,153,0.02); }
.dash-announcement-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px;
}
.ann-title-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.dash-announcement-head strong { color: var(--text-bright); font-size: 0.82rem; }
.dash-announcement-date { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.dash-announcement-body { font-size: 0.78rem; color: var(--text); line-height: 1.5; }
.dash-announcement-footer { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--border); }
.ann-author { font-size: 0.62rem; color: var(--text-muted); font-style: italic; }

/* ── Notification Bell ── */
.nav-notification {
    position: relative; display: inline-flex; align-items: center;
    color: var(--text-muted); font-size: 1rem; transition: color 0.15s;
    padding: 6px; cursor: pointer; border-radius: var(--radius-sm);
}
.nav-notification:hover { color: var(--primary); background: rgba(255,255,255,0.04); }
.notif-badge {
    position: absolute; top: 0; right: -2px;
    background: var(--accent); color: #fff;
    font-size: 0.52rem; font-weight: 700; min-width: 15px; height: 15px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.notif-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 320px; max-height: 400px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); z-index: 1001;
    display: none; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden;
}
.notif-dropdown.active { display: flex; }
.notif-dropdown-header {
    padding: 10px 14px; border-bottom: 1px solid var(--border);
    font-size: 0.75rem; color: var(--text-muted);
    display: flex; justify-content: space-between; align-items: center; font-weight: 500;
}
.notif-dropdown-body { overflow-y: auto; max-height: 340px; }
.notif-item {
    display: block; padding: 10px 14px; border-bottom: 1px solid var(--border);
    transition: background 0.15s; text-decoration: none;
}
.notif-item:hover { background: rgba(139,92,246,0.04); }
.notif-item.unread { background: rgba(139,92,246,0.06); border-left: 2px solid var(--primary); }
.notif-item-title { font-size: 0.78rem; color: var(--text-bright); font-weight: 500; margin-bottom: 2px; }
.notif-item-body { font-size: 0.7rem; color: var(--text-muted); line-height: 1.4; }
.notif-item-time { font-size: 0.62rem; color: var(--text-muted); margin-top: 3px; }
.notif-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 0.78rem; }
.notif-mark-all {
    padding: 8px 14px; text-align: center; border-top: 1px solid var(--border);
    font-size: 0.72rem; color: var(--primary); cursor: pointer; transition: background 0.15s;
}
.notif-mark-all:hover { background: rgba(139,92,246,0.06); }

/* ── Back to Top ── */
.back-to-top {
    position: fixed; bottom: 20px; right: 20px;
    width: 40px; height: 40px; background: var(--bg-card);
    border: 1px solid var(--primary); border-radius: 50%;
    color: var(--primary); font-size: 0.9rem; cursor: pointer; z-index: 999;
    opacity: 0; visibility: hidden; transition: all 0.3s;
    display: flex; align-items: center; justify-content: center;
}
.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover { background: var(--primary); color: #fff; }

/* ── Mobile Menu ── */
.mobile-menu-btn {
    display: none; background: none; border: none;
    cursor: pointer; padding: 14px; z-index: 200;
    -webkit-tap-highlight-color: transparent;
}
.hamburger {
    display: block; width: 22px; height: 2px;
    background: var(--text-bright); position: relative; transition: all 0.3s;
}
.hamburger::before, .hamburger::after {
    content: ''; position: absolute; width: 22px; height: 2px;
    background: var(--text-bright); left: 0; transition: all 0.3s;
}
.hamburger::before { top: -7px; }
.hamburger::after { bottom: -7px; }
.mobile-menu-btn.active .hamburger { background: transparent; }
.mobile-menu-btn.active .hamburger::before { transform: rotate(45deg); top: 0; }
.mobile-menu-btn.active .hamburger::after { transform: rotate(-45deg); bottom: 0; }

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    /* Remove backdrop-filter on mobile so .nav-links (position:fixed) uses
       the viewport as its containing block, not .nav — prevents the menu
       from being clipped to the nav bar height on iOS Safari. */
    .nav {
        backdrop-filter: none; -webkit-backdrop-filter: none;
        background: rgba(9, 9, 11, 0.97);
    }
    .mobile-menu-btn { display: block; }
    .nav-links {
        position: fixed; top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(9, 9, 11, 0.97); flex-direction: column; align-items: stretch;
        gap: 0; display: none; z-index: 200; padding: 80px 20px 32px;
        overflow-y: auto; -webkit-overflow-scrolling: touch;
    }
    .nav-links.active { display: flex; }
    .nav-links a, .nav-links .nav-notification {
        font-size: 1.1rem; padding: 16px 20px; min-height: 54px;
        display: flex; align-items: center;
        border-bottom: 1px solid rgba(255,255,255,0.06); color: var(--text);
        text-decoration: none; border-radius: 10px; background: none;
        font-weight: 500; letter-spacing: 0.01em;
        transition: background 0.15s;
    }
    .nav-links a:hover, .nav-links a.active {
        background: rgba(139,92,246,0.1); color: var(--text-bright);
    }
    .nav-links a.active {
        color: var(--primary); font-weight: 600;
    }
    .nav-links .notif-badge {
        font-size: 0.7rem; padding: 2px 7px; margin-left: 8px;
    }
    .nav-links .btn-logout {
        margin: 20px 0 0; text-align: center; justify-content: center;
        border-radius: var(--radius); background: rgba(239,68,68,0.1);
        color: #ef4444; font-weight: 600; border-bottom: none;
    }
    .nav-links .btn-logout:hover { background: rgba(239,68,68,0.2); }

    .page-wrap { padding: 70px 16px 30px; }
    .dashboard-page { padding: 70px 16px 30px; }

    /* Admin */
    .admin-stats { flex-direction: column; }
    .admin-stat { min-width: auto; }
    .admin-table th:nth-child(4), .admin-table td:nth-child(4) { display: none; }
    .admin-form-row { flex-direction: column; }
    .admin-search input { min-width: 140px; width: 100%; }
    .admin-panel-header { flex-direction: column; align-items: stretch; }
    .admin-tab { padding: 10px 14px; min-height: 44px; font-size: 0.72rem; }
    .tool-subtabs { overflow-x: auto; padding: 0 14px; }
    .tool-subtab { padding: 8px 14px; font-size: 0.72rem; white-space: nowrap; }
    .tool-subpanel { padding: 0 14px 14px; }
    .ts-stats { flex-direction: column; }
    .ts-product-grid { grid-template-columns: 1fr; }
    .ts-input { width: 140px; }
    .admin-btn { padding: 7px 10px; min-height: 34px; }
    .admin-form-card { margin: 14px; }
    .admin-form { padding: 14px; }
    .admin-announcements-list { padding: 0 14px 14px; }
    .admin-log-list { padding: 10px 14px; }
    .admin-log-entry { flex-direction: column; gap: 3px; }

    /* Profile */
    .profile-body { padding: 18px; }
    .profile-avatar-section { flex-direction: column; text-align: center; }
    .profile-form-actions { flex-direction: column; }
    .profile-form-actions .btn-login, .profile-form-actions .btn-primary { width: 100%; min-height: 44px; }
    .readonly-row { flex-direction: column; align-items: flex-start; gap: 3px; padding: 8px 14px; }
    .btn-cancel-link { text-align: center; display: block; padding: 10px; }

    /* Login */
    .login-form { padding: 0 18px; }
    .login-header { padding: 24px 18px 0; }
    .login-tabs { margin: 16px 18px; }
    .tab-btn { min-height: 44px; }
    .generate-section { padding: 0 18px 24px; }
    .credentials-card { margin: 0 18px 24px; }
    .remember-me { padding: 0 18px 8px; }
    .login-footer { padding: 16px 18px 24px; }
    .credential-row { flex-direction: column; align-items: flex-start; gap: 6px; }
    .btn-copy { margin-left: 0; width: 100%; text-align: center; min-height: 40px; }

    /* Modal */
    .modal-card { max-width: 100%; margin: 14px; }
    .modal-body { padding: 18px; }
    .modal-actions { flex-direction: column; }
    .modal-actions button, .modal-actions .btn-login, .modal-actions .btn-primary { width: 100%; min-height: 44px; }

    /* Module grid */
    .module-grid { grid-template-columns: 1fr; }
    .role-select { grid-template-columns: repeat(2, 1fr); }

    /* General touch targets */
    .btn-primary, .btn-outline, .btn-login, .btn-danger { min-height: 44px; padding: 12px 20px; }
}

@media (max-width: 480px) {
    .container { padding: 0 12px; }
    .page-wrap { padding: 64px 12px 24px; }
    .dashboard-page { padding: 64px 12px 24px; }
    .nav-logo { font-size: 1.1rem; }

    .admin-table th, .admin-table td { padding: 8px 8px; font-size: 0.7rem; }
    .admin-table th:nth-child(3), .admin-table td:nth-child(3) { display: none; }
    .admin-stat-value { font-size: 1.2rem; }

    .profile-avatar-wrapper, .profile-avatar-img, .profile-avatar-placeholder { width: 56px; height: 56px; }
    .profile-avatar-info h3 { font-size: 1rem; }
}
