/* ============================================
   FLAIO Design System — Linear-Inspired
   ============================================ */

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

/* --- Light Mode (default) --- */
:root {
    --bg: #FFFFFF;
    --surface: #FFFFFF;
    --surface-hover: #F9F9FB;
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --primary: #5E6AD2;
    --primary-hover: #4F5ABF;
    --text: #1B1B1F;
    --text-secondary: #6B6F76;
    --text-tertiary: #8C8F94;
    --danger: #E5484D;
    --danger-bg: rgba(229, 72, 77, 0.08);
    --danger-border: rgba(229, 72, 77, 0.2);
    --success: #30A46C;
    --success-bg: rgba(48, 164, 108, 0.08);
    --success-border: rgba(48, 164, 108, 0.2);
    --radius: 8px;
    --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary);
}

/* --- Dark Mode --- */
[data-theme="dark"] {
    --bg: #101012;
    --surface: #18181B;
    --surface-hover: #1E1E22;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --primary: #5E6AD2;
    --primary-hover: #6E7AE2;
    --text: #F1F1F4;
    --text-secondary: #8A8F98;
    --text-tertiary: #5C5F66;
    --danger: #E5484D;
    --danger-bg: rgba(229, 72, 77, 0.12);
    --danger-border: rgba(229, 72, 77, 0.25);
    --success: #30A46C;
    --success-bg: rgba(48, 164, 108, 0.12);
    --success-border: rgba(48, 164, 108, 0.25);
    --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary);
}

/* Auto dark mode when no explicit preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #101012;
        --surface: #18181B;
        --surface-hover: #1E1E22;
        --border: rgba(255, 255, 255, 0.08);
        --border-hover: rgba(255, 255, 255, 0.15);
        --primary: #5E6AD2;
        --primary-hover: #6E7AE2;
        --text: #F1F1F4;
        --text-secondary: #8A8F98;
        --text-tertiary: #5C5F66;
        --danger: #E5484D;
        --danger-bg: rgba(229, 72, 77, 0.12);
        --danger-border: rgba(229, 72, 77, 0.25);
        --success: #30A46C;
        --success-bg: rgba(48, 164, 108, 0.12);
        --success-border: rgba(48, 164, 108, 0.25);
        --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--primary);
    }
}

/* --- Base --- */
body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.15s ease, color 0.15s ease;
}

/* --- FLAIO Wordmark --- */
.flaio-wordmark {
    text-align: center;
    margin-bottom: 28px;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--text);
    user-select: none;
}

/* --- Layout --- */
.auth-container {
    width: 100%;
    max-width: 380px;
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.auth-card h1 {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
    color: var(--text);
}

.auth-card .subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 28px;
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

.form-group input:hover {
    border-color: var(--border-hover);
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}

.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 42px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    border-radius: 6px;
    padding: 0;
}

.password-toggle:hover {
    color: var(--text);
    background: rgba(128,128,128,0.08);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

.password-toggle .icon-eye-off {
    display: none;
}

.password-toggle[data-visible="true"] .icon-eye {
    display: none;
}

.password-toggle[data-visible="true"] .icon-eye-off {
    display: block;
}

/* Honeypot: offscreen positioning beats display:none (most commodity bots
   skip display:none but fill any DOM input). */
.honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* --- Buttons --- */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 44px;
    padding: 0 16px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
    user-select: none;
}

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

.btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn-primary {
    background: var(--primary);
    color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-social {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    margin-top: 10px;
    gap: 10px;
}

.btn-social:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

/* --- Divider --- */
.divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    color: var(--text-tertiary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider::before { margin-right: 16px; }
.divider::after { margin-left: 16px; }

/* --- Messages --- */
.error-message {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 16px;
    display: none;
}

.error-message.visible { display: block; }

.success-message {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 16px;
    display: none;
}

.success-message.visible { display: block; }

/* --- Links --- */
.link-row {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.link-row a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.link-row a:hover { text-decoration: underline; }

.forgot-link {
    display: block;
    text-align: right;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    margin-top: -8px;
    margin-bottom: 16px;
    transition: color 0.15s ease;
}

.forgot-link:hover { color: var(--text); }

/* --- Consent Page --- */
.scope-list {
    list-style: none;
    margin: 16px 0;
}

.scope-list li {
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.consent-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.consent-actions .btn { flex: 1; }

/* --- Theme Toggle --- */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    z-index: 100;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    color: var(--text);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

/* Hide the inactive icon */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ============================================
   Pricing Page
   ============================================ */

.pricing-body {
    display: block;
    min-height: 100vh;
}

.pricing-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 60px 24px 80px;
}

.pricing-header {
    text-align: center;
    margin-bottom: 40px;
}

.pricing-header .flaio-wordmark {
    margin-bottom: 20px;
    font-size: 36px;
}

.pricing-header h1 {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
    color: var(--text);
}

.pricing-header p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* --- Status messages --- */
.pricing-status {
    max-width: 500px;
    margin: 0 auto 24px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    text-align: center;
}

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

.pricing-status-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
}

.pricing-status-info {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

/* --- Billing Toggle --- */
.pricing-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 40px;
}

.pricing-toggle {
    display: flex;
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3px;
    cursor: pointer;
    font-family: inherit;
}

.pricing-toggle-option {
    position: relative;
    z-index: 1;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.15s ease;
    user-select: none;
}

.pricing-toggle-option.active {
    color: var(--text);
}

.pricing-toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: transform 0.2s ease;
    pointer-events: none;
}

.pricing-badge {
    position: absolute;
    left: calc(50% + 80px);
    font-size: 12px;
    font-weight: 500;
    color: var(--primary);
    background: rgba(94, 106, 210, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    white-space: nowrap;
}

.pricing-badge.visible {
    opacity: 1;
    transform: translateX(0);
}

/* --- Pricing Grid --- */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 48px;
}

.pricing-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px 24px 28px;
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

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

.pricing-card.highlighted {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.pricing-recommended {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

.pricing-card-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

.pricing-card-price {
    margin-bottom: 4px;
}

.price-amount {
    font-size: 40px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--text);
}

.price-period {
    font-size: 14px;
    color: var(--text-secondary);
    margin-left: 2px;
}

.pricing-card-billed {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 24px;
    min-height: 20px;
}

.pricing-card-tagline {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-style: italic;
}

.pricing-card-features {
    list-style: none;
    flex: 1;
    margin-bottom: 24px;
}

.pricing-card-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 0;
}

.pricing-card-features li svg {
    color: var(--success);
    flex-shrink: 0;
}

/* --- Per-App Features in Pricing Cards --- */
.pricing-app-features {
    flex: 1;
    margin-bottom: 24px;
}

.pricing-app-row {
    margin-bottom: 16px;
}

.pricing-app-row:last-child {
    margin-bottom: 0;
}

.pricing-app-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.pricing-app-icon {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    flex-shrink: 0;
}

.pricing-app-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.01em;
}

.pricing-app-list {
    list-style: none;
    padding-left: 30px;
}

.pricing-app-list li {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 2px 0;
    line-height: 1.5;
}

.pricing-cta {
    margin-top: auto;
}

/* --- VPA Pro Add-on --- */
.pricing-addon {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    margin-bottom: 48px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.pricing-addon:hover {
    border-color: var(--border-hover);
}

.pricing-addon-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.pricing-addon-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    flex-shrink: 0;
}

.pricing-addon-title {
    flex: 1;
}

.pricing-addon-title h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.pricing-addon-title p {
    font-size: 14px;
    color: var(--text-secondary);
}

.pricing-addon-price {
    text-align: right;
    flex-shrink: 0;
}

.pricing-addon-requires {
    font-size: 13px;
    color: var(--primary);
    margin-top: 2px;
}

.pricing-addon-price .price-amount {
    font-size: 32px;
}

.pricing-addon-price .pricing-card-billed {
    margin-bottom: 0;
    min-height: 0;
}

.pricing-addon-body {
    display: flex;
    gap: 32px;
    align-items: flex-start;
}

.pricing-addon-features-col {
    flex: 1;
    min-width: 0;
}

.pricing-addon-features {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px 24px;
    margin-bottom: 24px;
}

.pricing-addon-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 4px 0;
}

.pricing-addon-features li svg {
    color: var(--success);
    flex-shrink: 0;
}

.pricing-addon-cta {
    width: auto;
    padding: 0 32px;
}

.pricing-addon-screenshot {
    flex-shrink: 0;
    width: 320px;
}

.pricing-addon-screenshot img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border);
}

@media (max-width: 580px) {
    .pricing-addon-header { flex-direction: column; align-items: flex-start; }
    .pricing-addon-price { text-align: left; }
    .pricing-addon-body { flex-direction: column; }
    .pricing-addon-features { grid-template-columns: 1fr; }
    .pricing-addon-cta { width: 100%; }
    .pricing-addon-screenshot { width: 100%; }
}

/* --- Footer --- */
.pricing-footer {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.pricing-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.pricing-footer a:hover { text-decoration: underline; }

/* --- Responsive --- */
@media (max-width: 960px) {
    .pricing-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 580px) {
    .pricing-grid { grid-template-columns: 1fr; max-width: 380px; margin-left: auto; margin-right: auto; }
    .pricing-container { padding: 40px 16px 60px; }
    .pricing-header h1 { font-size: 22px; }
}

@media (max-width: 480px) {
    .auth-card { padding: 28px 24px; }
    .theme-toggle { top: 12px; right: 12px; }
}

/* ============================================
   Admin Panel
   ============================================ */

.admin-body {
    display: block;
    min-height: 100vh;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

/* --- Header --- */
.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
}

.admin-header .flaio-wordmark {
    margin-bottom: 0;
    font-size: 22px;
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.admin-role-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    background: rgba(94, 106, 210, 0.1);
    padding: 4px 10px;
    border-radius: 20px;
}

.admin-logout {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.admin-logout:hover { color: var(--text); }

/* --- Tabs --- */
.admin-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 0;
}

.admin-tab {
    padding: 14px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.admin-tab:hover { color: var(--text); }

.admin-tab.active {
    color: var(--text);
    border-bottom-color: var(--primary);
}

/* --- Section views --- */
.admin-view { padding-top: 32px; }

/* --- Stats --- */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.admin-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.admin-stat-value {
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-bottom: 4px;
}

.admin-stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* --- Tables --- */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.admin-table td {
    padding: 12px;
    font-size: 14px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table tbody tr {
    transition: background-color 0.1s ease;
}

.admin-table tbody tr:hover {
    background: var(--surface-hover);
}

.admin-table tbody tr.clickable {
    cursor: pointer;
}

.admin-table tbody tr.selected {
    background: var(--surface-hover);
}

/* --- Search --- */
.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 16px;
}

.admin-search-input {
    width: 100%;
    max-width: 320px;
    height: 40px;
    padding: 0 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.admin-search-input::placeholder { color: var(--text-tertiary); }
.admin-search-input:hover { border-color: var(--border-hover); }
.admin-search-input:focus { border-color: var(--primary); box-shadow: var(--focus-ring); }

.admin-results-count {
    font-size: 13px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* --- Pagination --- */
.admin-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.admin-pagination button {
    height: 36px;
    padding: 0 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.admin-pagination button:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

.admin-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- Status Badges --- */
.admin-badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
}

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

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

.admin-badge-inactive {
    color: var(--text-tertiary);
    background: var(--surface-hover);
}

.admin-badge-admin {
    color: var(--primary);
    background: rgba(94, 106, 210, 0.1);
}

/* --- User Detail Panel --- */
.admin-user-detail {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    margin-top: 20px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.admin-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.admin-detail-info h3 {
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.admin-detail-meta {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}

.admin-detail-meta span {
    display: inline-block;
    margin-right: 20px;
}

.admin-detail-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.admin-btn {
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.admin-btn-default {
    background: transparent;
    color: var(--text);
}

.admin-btn-default:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

.admin-btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger-border);
}

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

.admin-btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.admin-btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

.admin-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Detail Sections --- */
.admin-detail-section {
    margin-top: 24px;
}

.admin-detail-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

/* --- Inline Form --- */
.admin-form-inline {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.admin-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-form-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}

.admin-form-group select,
.admin-form-group input {
    height: 36px;
    padding: 0 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s ease;
}

.admin-form-group select:focus,
.admin-form-group input:focus {
    border-color: var(--primary);
}

/* --- Notification Messages --- */
.admin-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.admin-toast.visible { opacity: 1; }

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

.admin-toast-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: var(--danger);
}

.admin-toast-info {
    background: #eff6ff;
    border: 1px solid #93c5fd;
    color: #1d4ed8;
}
[data-theme="dark"] .admin-toast-info {
    background: #1e3a5f;
    border-color: #3b82f6;
    color: #93c5fd;
}

/* --- Empty State --- */
.admin-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* --- Loading --- */
.admin-loading {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* --- Section Title --- */
.admin-section-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 20px;
}

/* --- Tier Breakdown Table --- */
.admin-breakdown {
    margin-top: 8px;
}

.admin-breakdown h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

/* --- Responsive --- */
@media (max-width: 960px) {
    .admin-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 580px) {
    .admin-stats { grid-template-columns: 1fr; }
    .admin-container { padding: 0 16px 60px; }
    .admin-toolbar { flex-direction: column; align-items: stretch; }
    .admin-search-input { max-width: 100%; }
    .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .admin-detail-header { flex-direction: column; }
    .admin-form-inline { flex-direction: column; }
    .admin-tab { padding: 12px 14px; font-size: 12px; }
}

/* Permissions Matrix — Linear-style */
.perm-matrix-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.perm-matrix {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    width: 100%;
    min-width: 600px;
}

.perm-matrix th,
.perm-matrix td {
    padding: 0;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    text-align: center;
    font-size: 12px;
}
.perm-matrix th:last-child,
.perm-matrix td:last-child { border-right: none; }
.perm-matrix tbody tr:last-child td { border-bottom: none; }

/* Header rows */
.perm-matrix thead th {
    background: var(--surface);
    font-weight: 500;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 3;
}

/* App group header */
.perm-matrix .perm-app-header {
    background: var(--surface);
    color: var(--text-primary, #1a1a1a);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

/* Permission column headers */
.perm-matrix .perm-col-header {
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
}

/* Sticky user column */
.perm-matrix .perm-user-cell {
    text-align: left;
    font-weight: 500;
    font-size: 13px;
    min-width: 160px;
    max-width: 200px;
    padding: 8px 12px;
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg);
    color: var(--text-primary, #1a1a1a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sticky corner cells (top-left) */
.perm-matrix thead .perm-user-cell {
    z-index: 4;
    background: var(--surface);
}

.perm-admin-badge {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    vertical-align: middle;
}

.perm-user-email {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Permission cells */
.perm-matrix td.perm-cell {
    width: 36px;
    height: 36px;
    padding: 0;
    cursor: pointer;
    transition: background 0.1s ease;
    position: relative;
}
.perm-matrix td.perm-cell:hover { opacity: 0.8; }

/* Status dot inside cell */
.perm-cell .perm-dot-inner {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    vertical-align: middle;
}

.perm-cell.perm-granted-tier { background: rgba(34, 197, 94, 0.12); }
.perm-cell.perm-granted-tier .perm-dot-inner { background: #22c55e; }

.perm-cell.perm-granted-override { background: rgba(99, 102, 241, 0.12); }
.perm-cell.perm-granted-override .perm-dot-inner { background: #6366f1; }

.perm-cell.perm-denied-override { background: rgba(239, 68, 68, 0.1); }
.perm-cell.perm-denied-override .perm-dot-inner { background: #ef4444; }

.perm-cell.perm-granted-admin { background: rgba(139, 92, 246, 0.1); }
.perm-cell.perm-granted-admin .perm-dot-inner { background: #8b5cf6; }

.perm-cell.perm-none { background: transparent; }
.perm-cell.perm-none .perm-dot-inner { background: var(--border); width: 8px; height: 8px; }

/* Alternating row stripes */
.perm-matrix tbody tr:nth-child(even) td { background-color: rgba(0,0,0,0.015); }
.perm-matrix tbody tr:nth-child(even) td.perm-user-cell { background: var(--bg); }
[data-theme="dark"] .perm-matrix tbody tr:nth-child(even) td { background-color: rgba(255,255,255,0.02); }
[data-theme="dark"] .perm-matrix tbody tr:nth-child(even) td.perm-user-cell { background: var(--bg); }

/* Hover row highlight */
.perm-matrix tbody tr:hover td { background-color: rgba(0,0,0,0.03); }
.perm-matrix tbody tr:hover td.perm-user-cell { background: var(--surface-hover); }
[data-theme="dark"] .perm-matrix tbody tr:hover td { background-color: rgba(255,255,255,0.03); }
[data-theme="dark"] .perm-matrix tbody tr:hover td.perm-user-cell { background: var(--surface-hover); }

/* Override hover with cell-specific colors */
.perm-matrix tbody tr:hover td.perm-cell.perm-granted-tier { background: rgba(34, 197, 94, 0.18); }
.perm-matrix tbody tr:hover td.perm-cell.perm-granted-override { background: rgba(99, 102, 241, 0.18); }
.perm-matrix tbody tr:hover td.perm-cell.perm-denied-override { background: rgba(239, 68, 68, 0.15); }
.perm-matrix tbody tr:hover td.perm-cell.perm-granted-admin { background: rgba(139, 92, 246, 0.15); }

/* Legend */
.perm-legend {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding: 0 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.perm-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.perm-legend .perm-dot-legend {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.perm-dot-legend.lg-tier { background: #22c55e; }
.perm-dot-legend.lg-override { background: #6366f1; }
.perm-dot-legend.lg-deny { background: #ef4444; }
.perm-dot-legend.lg-admin { background: #8b5cf6; }
.perm-dot-legend.lg-none { background: var(--border); }

/* ============================================
   Profile Page
   ============================================ */

.profile-body {
    display: block;
    min-height: 100vh;
}

.profile-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

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

.profile-header .flaio-wordmark {
    margin-bottom: 0;
    font-size: 22px;
}

.profile-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.profile-nav-link {
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}
.profile-nav-link:hover { color: var(--text); }

.profile-title {
    font-size: 22px;
    font-weight: 600;
    margin: 32px 0 8px;
}

.profile-section {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.profile-section h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

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

.profile-inline-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.profile-form-stack {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 360px;
}

.profile-form-stack .form-group {
    margin-bottom: 16px;
}

/* Avatar */
.profile-avatar-row {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 28px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.profile-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

/* Account info grid */
.profile-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.profile-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-info-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}

.profile-info-value {
    font-size: 14px;
    color: var(--text);
}

/* Profile responsive */
@media (max-width: 580px) {
    .profile-container { padding: 0 16px 60px; }
    .profile-inline-form { flex-direction: column; align-items: stretch; }
    .profile-avatar-row { flex-direction: column; align-items: flex-start; }
    .profile-info-grid { grid-template-columns: 1fr; }
    .profile-form-stack { max-width: 100%; }
}
