:root[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-panel: rgba(255, 255, 255, 0.94);
    --bg-subtle: #e2e8f0;
    --border: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent: #0284c7;
    --accent-hover: #0369a1;
    --canvas-bg: #f8fafc;
    --tree-selected: #e0f2fe;
}

:root[data-theme="dark"] {
    --bg-main: #070d1e;
    --bg-panel: rgba(15, 23, 42, 0.92);
    --bg-subtle: #1e293b;
    --border: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --accent-hover: #0284c7;
    --canvas-bg: #070d1e;
    --tree-selected: #0369a1;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html,
body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-main);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
}

.select-input,
.text-input {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 6px 10px;
    border-radius: 6px;
    outline: none;
    font-size: 0.85rem;
}

.btn {
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover {
    opacity: 0.9;
}
.btn-secondary {
    background: var(--bg-subtle);
    color: var(--text-main);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--border);
}
.btn-secondary.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-success {
    background: #10b981;
    color: white;
}
.btn-warning {
    background: #f59e0b;
    color: white;
}
.btn-danger {
    background: #ef4444;
    color: white;
}

.hidden {
    display: none !important;
}

.role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    color: var(--text-main);
    white-space: nowrap;
}

.event-banner {
    position: absolute;
    top: 62px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--accent);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    font-size: 0.82rem;
    max-width: min(92vw, 640px);
}

.auth-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.74);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 16px;
}

.auth-modal-card {
    width: 100%;
    max-width: 390px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-modal-card h3 {
    font-size: 1.05rem;
    color: var(--accent);
}

.auth-modal-card p {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.auth-modal-error {
    font-size: 0.8rem;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 6px;
    padding: 6px 10px;
}

.auth-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 4px;
}

.save-dirty-dot {
    display: none;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fef08a;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.55);
    flex-shrink: 0;
}

.btn.is-dirty {
    background: #f59e0b !important;
    color: #0f172a !important;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
    animation: mai-save-pulse 1.8s ease-in-out infinite;
}

.btn.is-dirty .save-dirty-dot {
    display: inline-block;
    background: #dc2626;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75);
}

@keyframes mai-save-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.35);
    }
    50% {
        box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.12);
    }
}
