/* LinkRaze Dashboard — Modern Dark Theme */

/* Shared brand palette (--bg-*, --orange*, --text-*, --border*, --radius,
   --font-*). Source of truth: shared/linkraze-tokens.css → scripts/sync-tokens. */
@import "tokens.css";

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

:root {
  /* Dashboard-local tokens — brand palette comes from tokens.css above. */
  --bg-hover:        #1F2433;
  --orange-glow:     rgba(255, 106, 26, 0.15);
  --orange-subtle:   rgba(255, 106, 26, 0.06);
  --text-dim:        #6B7584;

  --radius-lg:       16px;
  --radius-sm:       6px;
  --transition:      0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s ease;

  --fw-400: 400;
  --fw-500: 500;
  --fw-600: 600;
  --fw-700: 700;
  --fw-800: 800;
}

html { scroll-behavior: smooth; font-size: 16px; }

body {
    background: var(--bg-base);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- Auth Pages ---- */

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: min(420px, calc(100% - 32px));
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.auth-box.mfa-setup-box {
    width: min(700px, calc(100% - 32px));
}

.auth-box h1 {
    font-size: 24px;
    font-weight: var(--fw-800);
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 28px;
    letter-spacing: -0.01em;
}

.auth-footer {
    margin-top: 16px;
    text-align: center;
    font-size: 13px;
}

/* ---- Form Fields ---- */

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: var(--fw-600);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.field input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-alternate);
    border: 1.5px solid var(--border-dim);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: var(--fw-400);
    transition: all var(--transition-fast);
    line-height: 1.5;
}

.field input::placeholder {
    color: var(--text-dim);
}

.field input:focus {
    outline: none;
    background: var(--bg-surface);
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-subtle);
    color: var(--text-primary);
}

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--bg-alternate);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: var(--fw-600);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    user-select: none;
}

.btn:hover { 
    background: var(--bg-surface);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
}
.btn:active {
    transform: translateY(0);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { 
    background: var(--orange);
    border-color: var(--orange); 
    color: #fff;
    box-shadow: 0 4px 12px rgba(255, 106, 26, 0.2);
}
.btn-primary:hover { 
    background: var(--orange-hover);
    border-color: var(--orange-hover);
    box-shadow: 0 8px 24px rgba(255, 106, 26, 0.3);
}
.btn-primary:active {
    background: var(--orange-active);
}

/* Google sign-in button: white surface, dark text, light border. */
.btn-google {
    background: #ffffff;
    color: #1f1f1f;
    border-color: #dadce0;
    font-weight: 500;
}
.btn-google:hover { background: #f5f5f5; }
.btn-google:disabled { background: #f0f0f0; color: #5f6368; }

.btn-danger { 
    background: rgba(244, 63, 94, 0.1);
    border-color: rgba(244, 63, 94, 0.3);
    color: #FF5A7E;
}
.btn-danger:hover { 
    background: rgba(244, 63, 94, 0.2);
    border-color: rgba(244, 63, 94, 0.5);
}

.btn-ghost { 
    background: transparent; 
    border-color: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { 
    background: var(--bg-alternate);
    color: var(--text-primary);
}

.btn-full { width: 100%; }
.btn-large { padding: 12px 24px; font-size: 15px; }
.btn-small { padding: 4px 10px; font-size: 12px; }

/* ---- Header ---- */

.header {
    background: rgba(18, 21, 26, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-dim);
    padding: 12px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-brand {
    font-size: 18px;
    font-weight: var(--fw-800);
    color: var(--orange);
    letter-spacing: -0.01em;
    transition: color var(--transition-fast);
    text-decoration: none;
    cursor: pointer;
}

.header-brand:hover {
    color: var(--orange-hover);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

/* User Avatar Dropdown Menu */
.user-menu-container {
    position: relative;
}

.user-avatar-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange) 0%, var(--orange-active) 100%);
    color: #fff;
    font-weight: var(--fw-700);
    font-size: 15px;
    border: 2px solid var(--orange);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.user-avatar-btn:hover {
    background: linear-gradient(135deg, var(--orange-hover) 0%, var(--orange-active) 100%);
    border-color: var(--orange-hover);
    box-shadow: 0 4px 16px rgba(255, 106, 26, 0.4);
    transform: scale(1.08);
}

.user-avatar-btn.active {
    background: linear-gradient(135deg, var(--orange-hover) 0%, var(--orange-active) 100%);
    border-color: var(--orange-accent);
    box-shadow: 0 0 12px rgba(255, 106, 26, 0.6);
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 200px;
    background: rgba(18, 21, 26, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.95);
    transition: all var(--transition-fast);
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.user-dropdown-header {
    padding: 12px 16px;
    font-size: 11px;
    font-weight: var(--fw-600);
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-dim);
    word-break: break-all;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.user-dropdown-item {
    display: block;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition-fast);
    cursor: pointer;
    border-left: 3px solid transparent;
}

.user-dropdown-item:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-left-color: var(--orange);
}

.user-dropdown-item-danger {
    color: #FF5A7E;
}

.user-dropdown-item-danger:hover {
    background: rgba(255, 90, 126, 0.1);
    border-left-color: #FF5A7E;
}

.user-dropdown-separator {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.user-dropdown-version {
    padding: 10px 16px;
    color: var(--text-dim);
    font-size: 11px;
    font-family: var(--font-mono);
    cursor: help;
    user-select: text;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-top: 1px solid var(--border-dim);
    background: rgba(0, 0, 0, 0.2);
}

/* ---- Main Content ---- */

.main {
    flex: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
    width: 100%;
}

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

.page-title h2 {
    font-size: 18px;
    color: var(--text-primary);
}

/* ---- Account Settings ---- */

.settings-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 20px 0 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.settings-subsection-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 18px 0 8px;
}

/* IP Whitelist */
.iw-my-ip-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.iw-add-mine-btn {
    margin-left: auto;
}

.iw-list {
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.iw-empty {
    font-style: italic;
}

.iw-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 8px 12px;
}

.iw-row-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.iw-cidr {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    color: var(--text-primary);
}

.iw-label {
    font-size: 11px;
    color: var(--text-muted);
}

.iw-add-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.iw-confirm-btn {
    margin-top: 8px;
}

/* ---- Privacy & Data ---- */

.privacy-subsection {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 16px 0 8px;
}

.privacy-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.privacy-delete-confirm {
    margin-top: 12px;
    padding: 12px;
    background: rgba(244, 63, 94, 0.05);
    border: 1px solid rgba(244, 63, 94, 0.2);
    border-radius: 6px;
}

.privacy-delete-confirm.hidden {
    display: none;
}

.text-warning {
    color: #FF5A7E;
    font-size: 13px;
}

.privacy-delete-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ---- Machine Grid ---- */

.machine-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.machine-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    transition: border-color 0.15s;
}

.machine-card:hover {
    border-color: var(--border-warm);
}

.machine-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.machine-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-online   { background: #4c8; box-shadow: 0 0 6px #4c8; }
.status-degraded { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
.status-offline  { background: #666; }
.status-hint     { font-size: 11px; color: #f59e0b; }

.machine-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
    font-size: 13px;
}

.machine-actions {
    display: flex;
    gap: 8px;
}

/* ---- Connect Page ---- */

.connect-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 28px;
    margin-top: 16px;
}

.connect-panel h2 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.session-info {
    margin-bottom: 24px;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-dim);
}

.info-label {
    color: var(--text-muted);
    font-size: 13px;
    min-width: 120px;
    flex-shrink: 0;
}

.info-value {
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    word-break: break-all;
}

.connect-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ---- Utilities ---- */

.alert {
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: #4a2020;
    border: 1px solid #c44;
    color: #f88;
}

.alert-info {
    background: #3a2e10;
    border: 1px solid #a87c30;
    color: #e8c46a;
}

.alert-ok {
    background: #1a3a1a;
    border: 1px solid #4c8;
    color: #8e8;
}

/* ---- Stats Bar ---- */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-pill {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
    min-width: 120px;
    flex: 1;
}

.stat-pill-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.stat-pill-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---- Disabled button ---- */
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.hidden { display: none !important; }

.loading {
    color: var(--text-muted);
    padding: 20px;
    text-align: center;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state p + p { margin-top: 8px; }

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

.link { color: var(--orange); text-decoration: none; }
.link:hover { text-decoration: underline; }

.back-link {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 13px;
}

/* ---- Session badge (Phase 4) ---- */
.session-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
}

.session-badge-active {
    background-color: #f59e0b;
    color: #fff;
}

/* ---- Resume button (Phase 5) ---- */
.btn-resume {
    background-color: #f59e0b;
    border-color: #d97706;
}

.btn-resume:hover:not(:disabled) {
    background-color: #d97706;
}

/* ---- Eviction warning dialog (Phase 6) ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-dialog {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-dialog h3 {
    margin: 0 0 12px 0;
}

.modal-dialog p {
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.sessions-list {
    background: var(--bg-alternate);
    border-radius: 4px;
    padding: 12px;
    margin: 12px 0 0 0;
    max-height: 200px;
    overflow-y: auto;
}

.sessions-list > div {
    padding: 4px 0;
    font-size: 13px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.modal-actions button {
    flex: 1;
}

/* ---- Sessions sidebar (Phase 7) ---- */
.sessions-sidebar {
    position: fixed;
    right: 0;
    top: 56px;
    bottom: 0;
    width: 320px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    padding: 0;
    overflow-y: auto;
    z-index: 100;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
    transform: translateX(0);
    transition: transform 0.2s ease;
}

.sessions-sidebar.hidden {
    transform: translateX(100%);
    pointer-events: none;
}

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

.sidebar-header h3 {
    margin: 0;
    font-size: 15px;
}

.sidebar-close {
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.sidebar-close:hover {
    color: var(--text-primary);
}

.sidebar-sessions-list {
    padding: 8px 0;
}

.session-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-dim);
    gap: 12px;
}

.session-info {
    flex: 1;
    min-width: 0;
}

.session-hostname {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.session-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-small {
    padding: 4px 10px;
    font-size: 12px;
}

/* Sessions button in header */
.btn-header-sessions {
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 10px;
    letter-spacing: -1px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-right: 8px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-header-sessions:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sessions-btn-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f59e0b;
    color: #000;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}


/* ---- MFA (Two-Factor Authentication) ---- */

.alert-warn {
    background: #4a3010;
    border: 1px solid #c88030;
    color: #f5c478;
}

.mfa-setup-box {
    width: min(440px, calc(100% - 32px));
}

.mfa-intro {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

.mfa-qr {
    display: flex;
    justify-content: center;
    margin: 16px 0;
    padding: 12px;
    background: #fff;
    border-radius: 6px;
}

.mfa-qr img {
    display: block;
    width: 200px;
    height: 200px;
    image-rendering: pixelated;
}

.mfa-secret-label {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 8px;
    margin-bottom: 6px;
}

.mfa-secret {
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 14px;
    letter-spacing: 1px;
    text-align: center;
    background: var(--bg-alternate);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px;
    color: var(--text-primary);
    user-select: all;
    cursor: pointer;
    margin-bottom: 20px;
    word-break: break-all;
}

.mfa-secret:hover {
    border-color: var(--orange);
}

.mfa-form {
    margin-top: 8px;
}

.mfa-code-input {
    width: 100%;
    padding: 14px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font: inherit;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 28px;
    letter-spacing: 8px;
    text-align: center;
}

.mfa-code-input.mfa-recovery-input {
    font-size: 16px;
    letter-spacing: 2px;
}

.mfa-code-input:focus {
    outline: none;
    border-color: var(--orange);
}

.mfa-method-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 20px 0;
}

.mfa-method-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mfa-method-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.mfa-method-desc {
    font-size: 12px;
    color: var(--text-muted);
    flex: 1;
    line-height: 1.5;
}

.recovery-codes-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px 10px;
    background: var(--bg-alternate);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px;
    margin: 20px 0;
}

.recovery-code {
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--text-primary);
    user-select: all;
    padding: 6px 4px;
    letter-spacing: 0.5px;
    text-align: center;
    word-break: break-all;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 3px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.recovery-code:hover {
    background: rgba(255, 106, 26, 0.1);
    border-color: var(--orange);
}

.mfa-recovery-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-start;
    margin-bottom: 16px;
}

.mfa-recovery-actions button {
    flex: 0 1 auto;
}

.mfa-ack-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
}

.mfa-ack-label {
    color: var(--text-secondary);
    cursor: pointer;
}

.mfa-status-banner {
    margin-bottom: 12px;
}

.mfa-regen-wrap {
    margin: 12px 0 16px;
}

.mfa-regen-form {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.mfa-regen-form.hidden {
    display: none;
}

.mfa-regen-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.hidden { display: none !important; }

/* ===== Billing page (PAYMENT_SYSTEM_PLAN.md �Phase 4) ===== */
.billing-status { color: var(--text-secondary); font-size: 14px; margin: 8px 0 16px; min-height: 20px; }
.billing-current { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 24px; }
.billing-current-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.billing-meta { color: var(--text-muted); font-size: 13px; margin: 8px 0; }
.billing-upgrade { display: flex; flex-wrap: wrap; gap: 16px; }
.billing-upgrade h3 { width: 100%; margin: 8px 0; color: var(--text-primary); }
.billing-plan-card { flex: 1 1 220px; max-width: 320px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.35); }
.billing-plan-card h4 { margin: 0 0 4px; color: var(--text-primary); }
.billing-plan-tagline { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }
.billing-plan-features { list-style: none; padding: 0; margin: 0 0 16px; }
.billing-plan-features li { padding: 4px 0; color: var(--text-secondary); font-size: 14px; }
.billing-plan-features li::before { content: '\2713'; color: #22c55e; margin-right: 8px; font-weight: 600; }
.plan-badge { display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; letter-spacing: 0.05em; }
/* Plan tiers — translucent fills tuned for the dark surface (Free neutral, Pro blue, Elite ember). */
.plan-free { background: var(--bg-surface); color: var(--text-secondary); }
.plan-pro { background: rgba(59, 130, 246, 0.15); color: #93C5FD; }
.plan-elite { background: rgba(255, 106, 26, 0.15); color: var(--orange-accent); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; text-transform: capitalize; background: var(--bg-surface); color: var(--text-secondary); }
/* Subscription status — keep semantic colors (green/red/yellow/indigo), dark-friendly. */
.pill-active { background: rgba(34, 197, 94, 0.15); color: #4ADE80; }
.pill-canceled { background: rgba(239, 68, 68, 0.15); color: #F87171; }
.pill-past_due { background: rgba(250, 204, 21, 0.15); color: #FCD34D; }
.pill-paused { background: rgba(99, 102, 241, 0.15); color: #A5B4FC; }

/* ---- Pair Device section ---- */
.pair-device-result { margin: 8px 0; }
.pair-device-result .token-code {
    display: block;
    font-family: monospace;
    font-size: 0.85rem;
    word-break: break-all;
    background: var(--bg-surface, #2a2a2a);
    padding: 8px 12px;
    border-radius: 4px;
    margin: 6px 0;
}
.pair-device-token-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0;
    font-size: 0.85rem;
}

/* ===== Support Page (support.js) ===== */

/* Panel container */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin: 16px 0;
}

/* Support page title row with heading and new ticket button */
.support-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

/* Button row in detail view (back, delete) */
.support-button-row {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.support-title-row h2 {
    font-size: 20px;
    font-weight: var(--fw-700);
    color: var(--text-primary);
    margin: 0;
}

.support-title-row h3 {
    font-size: 16px;
    font-weight: var(--fw-600);
    color: var(--text-primary);
    margin: 0;
}

/* Status message (loading, error) */
.support-status {
    padding: 12px 0;
    color: var(--text-secondary);
    min-height: 20px;
    font-size: 13px;
}

/* Ticket list container */
.support-list {
    margin-top: 16px;
}

/* Ticket table styling */
.support-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-alternate);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.support-table thead {
    background: var(--bg-surface);
    border-bottom: 1.5px solid var(--border);
}

.support-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: var(--fw-600);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.support-table tbody tr {
    border-bottom: 1px solid var(--border-dim);
    transition: background-color var(--transition-fast);
}

.support-table tbody tr:hover {
    background-color: var(--bg-surface);
}

.support-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-primary);
}

.support-subject {
    font-weight: var(--fw-500);
    color: var(--text-primary);
}

.support-row {
    cursor: pointer;
}

/* Empty state */
.support-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 14px;
    font-style: italic;
}

/* Status badges */
.support-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: var(--fw-600);
    text-transform: capitalize;
    text-align: center;
    min-width: 60px;
}

.support-badge-open {
    background: rgba(59, 130, 246, 0.15);
    color: #60A5FA;
}

.support-badge-inprogress {
    background: rgba(245, 158, 11, 0.15);
    color: #FBBF24;
}

.support-badge-resolved {
    background: rgba(34, 197, 94, 0.15);
    color: #86EFAC;
}

/* Back button in detail view */
.support-back-btn {
    margin-bottom: 16px;
}

/* Detail view title and badge */
.support-detail-title {
    margin: 0;
    font-size: 18px;
    font-weight: var(--fw-600);
    color: var(--text-primary);
}

.support-detail-badge {
    margin-left: 12px;
}

/* Message thread container */
.support-thread {
    background: var(--bg-alternate);
    border: 1px solid var(--border-dim);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 16px 0;
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Individual message */
.support-msg {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border-left: 3px solid var(--border);
}

.support-msg-user {
    border-left-color: var(--orange);
    background: rgba(255, 106, 26, 0.05);
}

.support-msg-admin {
    border-left-color: #4c8;
    background: rgba(76, 200, 136, 0.05);
}

/* Message metadata (sender name, timestamp) */
.support-msg-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: var(--fw-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

/* Message body text */
.support-msg-body {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    word-wrap: break-word;
}

/* Reply input and send button area */
.support-reply-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

/* Textarea styling for support form and reply */
.support-textarea,
.field textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-alternate);
    border: 1.5px solid var(--border-dim);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    transition: all var(--transition-fast);
    resize: vertical;
    min-height: 80px;
}

.support-textarea::placeholder,
.field textarea::placeholder {
    color: var(--text-dim);
}

.support-textarea:focus,
.field textarea:focus {
    outline: none;
    background: var(--bg-surface);
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-subtle);
}

.support-textarea:disabled,
.field textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-alternate);
}

/* Input styling for support form */
.support-input {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-alternate);
    border: 1.5px solid var(--border-dim);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.support-input::placeholder {
    color: var(--text-dim);
}

.support-input:focus {
    outline: none;
    background: var(--bg-surface);
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-subtle);
}

/* New ticket modal overlay and dialog */
.support-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.support-modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.support-modal h3 {
    font-size: 18px;
    font-weight: var(--fw-700);
    color: var(--text-primary);
    margin: 0 0 20px;
}

.support-modal label {
    display: block;
    margin: 16px 0 8px;
    font-size: 12px;
    font-weight: var(--fw-600);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Error message in modal */
.support-modal-error {
    padding: 12px 14px;
    background: rgba(244, 63, 94, 0.1);
    border: 1.5px solid rgba(244, 63, 94, 0.3);
    border-radius: var(--radius-sm);
    color: #FF5A7E;
    font-size: 13px;
    margin-bottom: 16px;
}

/* Support table row */
.support-row {
    transition: background var(--transition-fast);
}

.support-row:hover {
    background: var(--bg-surface);
}

/* Subject cell */
.support-subject {
    font-weight: var(--fw-500);
    color: var(--text-primary);
}

/* Actions cell */
.support-actions-cell {
    text-align: center;
    padding: 10px 8px !important;
}

.support-actions-cell .btn {
    font-size: 12px;
    padding: 6px 12px;
}

/* Success state in modal */
.support-modal-success {
    text-align: center;
}

.support-modal-success h3 {
    color: #64C864;
}

/* Modal button row */
.support-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Send error message (ephemeral toast) */
.support-send-error {
    padding: 10px 14px;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.3);
    border-radius: var(--radius-sm);
    color: #FF5A7E;
    font-size: 13px;
    animation: slideIn 0.2s ease-out;
}

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

/* ============================================================
   Mobile gaming profiles — on-screen controls editor
   Reuses the web viewer's edit-mode modules + CSS (loaded from
   /viewer/). The viewer styles only show controls on touch devices
   and reference --sb-* tokens; the rules below supply those tokens
   and force the editor visible on desktop pointers.
   ============================================================ */

.mgp-intro {
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.mgp-loading {
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 14px;
}

.mgp-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.mgp-panel-left {
    flex: 0 0 240px;
    min-width: 220px;
}

.mgp-panel-right {
    flex: 1 1 480px;
    min-width: 320px;
}

.mgp-section-label {
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.mgp-profile-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.mgp-profile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.mgp-profile-row:hover {
    border-color: var(--orange);
    background: var(--bg-hover);
}

.mgp-profile-row.mgp-profile-active {
    border-color: var(--orange);
    background: var(--orange-subtle);
}

.mgp-profile-name {
    font-size: 14px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mgp-profile-badge {
    flex-shrink: 0;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--orange-glow);
    color: var(--orange-accent);
    font-size: 11px;
    font-weight: 700;
}

.mgp-profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mgp-status {
    margin-top: 12px;
    min-height: 18px;
    font-size: 12px;
    color: var(--text-muted);
}

.mgp-status-saving { color: var(--text-secondary); }
.mgp-status-saved  { color: #51cf66; }
.mgp-status-error  { color: #FF5A7E; }

/* --- The editor canvas + viewer-token scope --- */
#mgp-editor {
    /* Color tokens consumed by the viewer's edit-mode CSS (var(--sb-*)). */
    --sb-bg-base: #12151A;
    --sb-bg-card: #171B22;
    --sb-bg-surface: #1E232C;
    --sb-text-primary: #F5F7FA;
    --sb-text-secondary: #B2B8C4;
    --sb-text-muted: #8C9399;
    --sb-border: #252A33;
    --sb-border-dim: #25252A;
    --sb-orange: #FF6A1A;
    --sb-orange-hover: #FF8533;
}

.mgp-fake-canvas {
    position: relative;            /* positioning context for #editOverlay / #editToolbar */
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 320px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 38%, #1b2230 0%, #11141b 60%, #0b0d12 100%);
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.5);
    user-select: none;
}

.mgp-canvas-hint {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    max-width: 90%;
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
    pointer-events: none;
    z-index: 1;
}

/* Force the editor visible regardless of pointer type. The viewer hides the
   overlay/controls/toolbar on @media (pointer: fine) (desktop); these higher-
   specificity rules override that so the editor works on the dashboard. */
#mgp-editor #editOverlay { display: block !important; }
#mgp-editor .em-button { display: block !important; }
#mgp-editor .em-dpad { display: block !important; }
#mgp-editor .em-analog { display: block !important; }
#mgp-editor #editToolbar.mobile-visible { display: flex !important; }

/* --- D-pad preset modal (the viewer's modal.css is not loaded here) --- */
#mgp-editor .lr-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(8, 9, 11, 0.72);
}

#mgp-editor .lr-modal-overlay.lr-modal-scroll { overflow: auto; }

#mgp-editor .lr-modal-card {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--sb-border);
    background: var(--sb-bg-card);
    color: var(--sb-text-primary);
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
}

#mgp-editor .lr-modal-card.modal-lg { max-width: 900px; }

#mgp-editor .lr-modal-title {
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 700;
}

#mgp-editor .lr-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

#mgp-editor .lr-modal-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid var(--sb-border);
    background: var(--sb-bg-surface);
    color: var(--sb-text-secondary);
    font: inherit;
    cursor: pointer;
}

#mgp-editor .lr-modal-btn:hover {
    border-color: var(--sb-orange);
    color: var(--sb-text-primary);
}

#mgp-editor #dpadPresetContainer {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

#mgp-editor .em-preset-preview {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto 12px;
}

#mgp-editor .em-preset-preview-circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--sb-border);
    background: radial-gradient(circle at 50% 50%, var(--sb-bg-card) 0%, var(--sb-bg-surface) 65%, var(--sb-bg-base) 100%);
}

#mgp-editor .em-preset-preview-key,
#mgp-editor .em-preset-preview-center {
    position: absolute;
    transform: translate(-50%, -50%);
    min-width: 24px;
    padding: 3px 6px;
    border-radius: 5px;
    border: 1px solid var(--sb-border);
    background: var(--sb-bg-surface);
    color: var(--sb-text-primary);
    font-size: 10px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    box-sizing: border-box;
}

#mgp-editor .em-preset-preview-center {
    min-width: 28px;
    padding: 4px 8px;
    border-color: var(--sb-orange);
    background: rgba(255, 106, 26, 0.16);
}

@media (max-width: 720px) {
    .mgp-panel-left { flex-basis: 100%; }
    /* The Windows agent only installs on desktop, so hide its download button
       on mobile-width screens. */
    .dl-agent-btn { display: none; }
}
