/* Typography: Sora (Display) & JetBrains Mono (Code) */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&family=Sora:wght@400;500;600;700&display=swap');

:root {
    /* --- LIGHT THEME (Default) --- */
    --bg-app: #f3f4f6;
    --bg-panel: #ffffff;
    --bg-panel-hover: #f9fafb;
    --bg-input: #ffffff;
    --bg-code: #f1f5f9;
    --bg-header: rgba(255, 255, 255, 0.85);

    --border-subtle: #e5e7eb;
    --border-active: #d1d5db;

    --text-main: #111827;
    --text-muted: #6b7280;
    --text-on-accent: #ffffff;

    /* Accent: Deep Teal (darkened for WCAG AA contrast) */
    --accent-primary: #0f766e;
    --accent-hover: #115e59;
    --accent-surface: rgba(13, 148, 136, 0.1);

    /* Surface contrast (for elements that need high contrast) */
    --surface-contrast: #ffffff;
    --overlay-bg: rgba(0, 0, 0, 0.4);

    /* Functional Colors */
    --color-success: #059669;
    --bg-success: #d1fae5;
    --color-danger: #dc2626;
    --bg-danger: #fee2e2;

    /* Effects */
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 0 3px rgba(13, 148, 136, 0.2);

    /* Dimensions */
    --radius-card: 12px;
    --radius-btn: 8px;
    --header-height: 70px;

    /* Fonts */
    --font-display: 'Sora', sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* --- DARK THEME OVERRIDES --- */
[data-theme="dark"] {
    --bg-app: #0f172a;
    --bg-panel: #1e293b;
    --bg-panel-hover: #253045;
    --bg-input: #0f172a;
    --bg-code: #020617;
    --bg-header: rgba(15, 23, 42, 0.85);

    --border-subtle: #334155;
    --border-active: #475569;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --accent-primary: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-surface: rgba(45, 212, 191, 0.15);
    --text-on-accent: #0f172a;

    --color-success: #34d399;
    --bg-success: rgba(52, 211, 153, 0.15);
    --color-danger: #f87171;
    --bg-danger: rgba(248, 113, 113, 0.15);

    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 0 3px rgba(45, 212, 191, 0.2);

    --surface-contrast: #ffffff;
    --overlay-bg: rgba(0, 0, 0, 0.6);
}

/* Auto-detect Dark Mode */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-app: #0f172a;
        --bg-panel: #1e293b;
        --bg-panel-hover: #253045;
        --bg-input: #0f172a;
        --bg-code: #020617;
        --bg-header: rgba(15, 23, 42, 0.85);
        --border-subtle: #334155;
        --border-active: #475569;
        --text-main: #f8fafc;
        --text-muted: #94a3b8;
        --accent-primary: #2dd4bf;
        --accent-hover: #5eead4;
        --accent-surface: rgba(45, 212, 191, 0.15);
        --text-on-accent: #0f172a;
        --color-success: #34d399;
        --bg-success: rgba(52, 211, 153, 0.15);
        --color-danger: #f87171;
        --bg-danger: rgba(248, 113, 113, 0.15);
        --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
        --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.4);
        --shadow-glow: 0 0 0 3px rgba(45, 212, 191, 0.2);
        --surface-contrast: #ffffff;
        --overlay-bg: rgba(0, 0, 0, 0.6);
    }
}

/* --- RESET & BASE --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* Focus styles for keyboard navigation */
:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    font-family: var(--font-body);
    -webkit-overflow-scrolling: touch;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* --- HEADER --- */
.app-header {
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 50;
    will-change: transform;
}
/* Enable backdrop blur only on desktop */
@media (min-width: 769px) {
    .app-header {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
}
.logo-section h1 { font-size: 1.2rem; }
.logo-icon { color: var(--accent-primary); flex-shrink: 0; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* --- LAYOUT --- */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
    animation: fadeIn 0.6s ease-out;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.section-header h2 {
    font-size: 1.4rem;
    color: var(--text-main);
}

/* --- CARDS --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Staggered Entrance */
.card { animation: slideUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; }
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }
.card:nth-child(6) { animation-delay: 0.3s; }

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.card {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

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

.card.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px var(--accent-primary), var(--shadow-card);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-main);
}

.card-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}
.detail-row span:first-child {
    color: var(--text-muted);
    font-weight: 500;
}

.code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: var(--bg-code);
    color: var(--text-main);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-actions {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* --- STATUS BADGE (Pulse Icon) --- */
.status-badge {
    width: 22px;
    height: 22px;
    color: var(--text-muted);
    opacity: 0.3;
    flex-shrink: 0;
    transition: all 0.3s ease;
}
.status-badge svg { width: 100%; height: 100%; }

/* Active: Pulsing glow animation */
.status-badge.active {
    color: var(--color-success);
    opacity: 1;
    animation: pulse-glow 2s ease-in-out infinite;
    will-change: transform, opacity;
}
/* Glow effect only on desktop for performance */
@media (min-width: 769px) {
    .status-badge.active {
        filter: drop-shadow(0 0 4px var(--color-success));
    }
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

/* --- BUTTONS --- */
.btn {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* Tactile Squeeze */
.btn:active { transform: scale(0.96); }

.btn-primary {
    background: var(--accent-primary);
    color: var(--text-on-accent);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-danger {
    background: #ef4444;
    color: #fff;
}
.btn-danger:hover {
    background: #dc2626;
}

.btn-secondary {
    background: transparent;
    border-color: var(--border-subtle);
    color: var(--text-main);
}
.btn-secondary:hover {
    background: var(--bg-panel-hover);
    border-color: var(--border-active);
}

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

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-icon {
    padding: 0.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
}
.btn-icon:hover {
    background: var(--bg-panel-hover);
    color: var(--text-main);
}
.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}
.btn-close:hover { color: var(--text-main); }

/* Icon Buttons */
.btn-icon {
    width: 36px;
    height: 36px;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover {
    background: var(--bg-panel-hover);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}
.btn-icon:active { transform: scale(0.95); }
.btn-icon svg { width: 100%; height: 100%; }
.btn-icon-danger:hover {
    color: var(--color-danger);
    border-color: var(--color-danger);
    background: var(--bg-danger);
}

/* Test Connection Button */
.btn-test {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
.animate-spin {
    animation: spin 1s linear infinite;
}

.btn-test.testing {
    color: var(--accent-primary);
    cursor: wait;
}

.btn-test.success {
    color: var(--color-success);
    min-width: 80px;
}

.btn-test.error {
    color: var(--color-danger);
    min-width: 80px;
}

.btn-content {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* --- SETTINGS --- */
.settings-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
}
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}
.setting-info { flex: 1; }
.setting-label {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--text-main);
    display: block;
    margin-bottom: 0.25rem;
}
.setting-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background-color: var(--border-subtle);
    border-radius: 34px;
    transition: .3s cubic-bezier(0.4, 0.0, 0.2, 1);
    cursor: pointer;
}
.toggle-slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--surface-contrast);
    border-radius: 50%;
    transition: .3s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
input:checked + .toggle-slider { background-color: var(--accent-primary); }
input:checked + .toggle-slider::before { transform: translateX(22px); }

/* --- INPUTS --- */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

.current-key-display {
    margin-bottom: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-btn);
    font-size: 0.9rem;
}

.current-key-display .code {
    color: var(--text-main);
    font-weight: 500;
}

input[type="text"], input[type="password"], input[type="url"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-btn);
    background: var(--bg-input);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    transition: all 0.2s;
}
input:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.form-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-btn);
    background: var(--bg-input);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    max-width: 280px;
}
.form-select:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
    outline: none;
}

.input-group {
    display: flex;
    gap: 0.5rem;
}

/* --- MODAL --- */
.modal {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.2s;
}
.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    padding: 2rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.25);
    transform: scale(1);
    transition: transform 0.2s;
}
.modal.hidden .modal-content { transform: scale(0.96); }
.modal-content.compact {
    max-width: 380px;
    text-align: center;
    padding: 2rem 2rem 1.5rem;
}
.modal-content.compact h3 { margin-bottom: 0.75rem; }
.modal-content.compact p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; line-height: 1.5; }
.modal-content.compact .modal-actions { justify-content: center; gap: 1rem; }

.confirm-icon {
    width: 48px; height: 48px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.confirm-icon.warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.confirm-icon.danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.confirm-icon svg { width: 24px; height: 24px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-header h3 {
    font-size: 1.25rem;
    color: var(--text-main);
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* --- STATUS --- */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.8rem;
    background: var(--bg-panel-hover);
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}
.status-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.status-indicator.online .status-dot {
    background: var(--color-success);
    box-shadow: 0 0 0 2px var(--bg-success);
}
.status-indicator.online .status-text { color: var(--color-success); }
.status-indicator.error .status-dot { background: var(--color-danger); }

/* --- VERSION BADGE --- */
.version-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    background: var(--bg-code);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
    user-select: none;
}
.version-badge:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    background: var(--accent-surface);
}
.version-badge:active { transform: scale(0.96); }
@media (max-width: 480px) { .version-badge { display: none; } }

/* --- EMPTY STATE --- */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-panel);
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-card);
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.empty-state-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

/* --- UTILS --- */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.full-width { width: 100%; }

/* --- TOASTS --- */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.toast {
    padding: 1rem 1.25rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--accent-primary);
    border-radius: var(--radius-btn);
    box-shadow: var(--shadow-hover);
    color: var(--text-main);
    font-weight: 500;
    animation: slideInRight 0.3s ease;
    min-width: 250px;
}
.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-danger); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- QUICK GUIDE CARD --- */
.quick-guide { gap: 0; padding: 0; overflow: hidden; margin-bottom: 2rem; }
.quick-guide .card-header.clickable { padding: 1.25rem 1.5rem; cursor: pointer; user-select: none; }
.quick-guide .card-header.clickable:hover { background: var(--bg-panel-hover); }
.header-title { display: flex; align-items: center; gap: 0.75rem; }
.toggle-icon { transition: transform 0.3s ease; color: var(--text-muted); }
.quick-guide.collapsed .guide-content { display: none; }
.quick-guide.collapsed .toggle-icon { transform: rotate(-90deg); }

.guide-content {
    padding: 1.5rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-panel-hover);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.guide-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1.5rem; }
.guide-section h4 { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 0.75rem; }
.code-block {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-code); padding: 0.5rem 0.75rem; border-radius: 6px;
    border: 1px solid var(--border-subtle); margin-bottom: 0.5rem;
    font-family: var(--font-mono); font-size: 0.8rem;
}
.code-block .label { color: var(--accent-primary); font-size: 0.7rem; font-weight: 600; }
.code-pre {
    background: var(--bg-code); padding: 1rem; border-radius: 8px;
    border: 1px solid var(--border-subtle); font-family: var(--font-mono);
    font-size: 0.8rem; overflow-x: auto; line-height: 1.5; white-space: pre; margin: 0;
}

/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
    .header-content { max-width: 960px; }
    .container { max-width: 960px; padding: 2rem 1.5rem; }
    .card-grid { gap: 1.25rem; }
}

@media (max-width: 768px) {
    .app-header { padding: 0 1rem; }
    .container { padding: 1.5rem 1rem; }
    .card-grid { grid-template-columns: 1fr; gap: 1rem; }
    .section-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .section-header .btn { width: 100%; }
    .guide-grid { grid-template-columns: 1fr; }
    .code-pre { font-size: 0.75rem; }
    .modal-content { margin: 1rem; max-width: calc(100% - 2rem); }
}

@media (max-width: 480px) {
    body { background-image: none; }
    .logo-section h1 { font-size: 1rem; }
    .header-actions { gap: 0.5rem; }
    .status-indicator .status-text { display: none; }
    .container { padding: 1rem 0.75rem; }
    .card { padding: 1rem; }
    .card-header { flex-wrap: wrap; gap: 0.5rem; }
    .card-details { font-size: 0.85rem; }
    .detail-row .code { max-width: 140px; }
    .card-actions { justify-content: flex-start; }
}

/* --- ADMIN AUTH OVERLAY --- */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.auth-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-hover);
    animation: slideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    color: var(--accent-primary);
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 12px var(--accent-surface));
}

.auth-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.auth-error {
    display: none;
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-btn);
    color: var(--color-danger);
    background: var(--bg-danger);
    font-size: 0.875rem;
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

.auth-error.show {
    display: block;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.auth-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    user-select: none;
    cursor: pointer;
}

.remember-me input[type="checkbox"] {
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group input {
    flex: 1;
    padding-right: 3rem;
}

.input-group .btn-icon {
    position: absolute;
    right: 0.5rem;
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    font-size: 1.25rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.input-group .btn-icon:hover {
    opacity: 1;
}

.auth-card .btn {
    min-width: 140px;
    height: 44px;
    font-size: 1rem;
}

@media (max-width: 480px) {
    .auth-footer {
        flex-direction: column;
        align-items: stretch;
    }
    
    .auth-card .btn {
        width: 100%;
    }
}

/* --- SENSITIVE WORDS & TABLES --- */
.table-container {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
    background: var(--bg-panel-hover);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

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

.data-table tr:hover td {
    background: var(--bg-panel-hover);
}

.data-table .actions-cell {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Form Textarea for Import */
.form-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-btn);
    background: var(--bg-input);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    resize: vertical;
    transition: all 0.2s;
    line-height: 1.5;
}

.form-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
    outline: none;
}

/* Word Pattern Display */
.word-pattern {
    font-family: var(--font-mono);
    color: var(--text-main);
    background: var(--bg-code);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-subtle);
    display: inline-block;
}

/* Section header with multiple buttons */
.section-header .header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-danger {
    background: var(--color-danger);
    color: var(--text-on-accent);
}

.btn-danger:hover {
    background: #b91c1c;
}

/* --- COLLAPSIBLE SECTION --- */
.collapsible-card {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-card);
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    cursor: pointer;
    background: var(--bg-panel-hover);
    user-select: none;
    transition: background 0.2s;
}

.collapsible-header:hover {
    background: var(--bg-code);
}

.collapsible-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    color: var(--text-main);
}

.collapsible-icon {
    font-size: 0.75rem;
    transition: transform 0.2s;
    color: var(--text-muted);
}

.collapsible-card.expanded .collapsible-icon {
    transform: rotate(90deg);
}

.collapsible-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.collapsible-card.expanded .collapsible-hint {
    display: none;
}

.collapsible-content {
    max-height: 400px;
    overflow-y: auto;
}

.collapsible-content.collapsed {
    display: none;
}
