/* ===== CSS Variables: Day/Night Theme ===== */
:root {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f7f8fa;
    --text-primary: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #888;
    --border-color: #e0e0e0;
    --border-light: #eee;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
    --accent: #3b82f6;
    --accent-light: #dbeafe;
    --accent-hover: #2563eb;
    --sidebar-bg: #ffffff;
    --sidebar-text: #1a1a2e;
    --sidebar-hover: #f0f4ff;
    --tool-bg: #ffffff;
    --tool-border: #e2e8f0;
    --tool-hover-border: #3b82f6;
    --tooltip-bg: #1e293b;
    --tooltip-text: #fff;
    --modal-bg: #ffffff;
    --modal-header-bg: #1e293b;
    --cap-group-header-bg: #1e293b;
    --cap-group-header-text: #ffffff;
    --cap-item-hover: #f0f4ff;
    --cap-item-border: #f3f4f6;
    --green: #10b981;
    --green-light: #d1fae5;
    --green-hover: #059669;
    --orange: #f59e0b;
    --orange-hover: #d97706;
    --red: #ef4444;
    --red-hover: #dc2626;
    --hamburger-bg: #1e293b;
    --subheader-bg: #334155;
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --subblock-header-color: #1a1a2e;
    --subblock-header-bg: rgba(0, 0, 0, 0.07);
    --block-divider: rgba(0,0,0,0.1);
    --empty-state-color: #64748b;
    --search-border: #d1d5db;
    --search-focus: #3b82f6;
    --wizard-card-border: #e5e7eb;
    --wizard-card-hover-bg: #f0f4ff;
    --wizard-added-bg: #ecfdf5;
    --wizard-added-border: #a7f3d0;
    --badge-active-bg: #d1fae5;
    --badge-active-text: #065f46;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --border-light: #334155;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
    --accent: #60a5fa;
    --accent-light: #1e3a5f;
    --accent-hover: #93bbfd;
    --sidebar-bg: #1e293b;
    --sidebar-text: #e2e8f0;
    --sidebar-hover: #334155;
    --tool-bg: #1e293b;
    --tool-border: #334155;
    --tool-hover-border: #60a5fa;
    --tooltip-bg: #0f172a;
    --tooltip-text: #e2e8f0;
    --modal-bg: #1e293b;
    --modal-header-bg: #0f172a;
    --cap-group-header-bg: #0f172a;
    --cap-group-header-text: #e2e8f0;
    --cap-item-hover: #334155;
    --cap-item-border: #334155;
    --green: #34d399;
    --green-light: #064e3b;
    --green-hover: #10b981;
    --orange: #fbbf24;
    --orange-hover: #f59e0b;
    --red: #f87171;
    --red-hover: #ef4444;
    --hamburger-bg: #334155;
    --subheader-bg: #475569;
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --subblock-header-color: #e2e8f0;
    --subblock-header-bg: rgba(255, 255, 255, 0.08);
    --block-divider: rgba(255,255,255,0.08);
    --empty-state-color: #94a3b8;
    --search-border: #475569;
    --search-focus: #60a5fa;
    --wizard-card-border: #334155;
    --wizard-card-hover-bg: #334155;
    --wizard-added-bg: #064e3b;
    --wizard-added-border: #059669;
    --badge-active-bg: #064e3b;
    --badge-active-text: #6ee7b7;
}

/* ===== Base ===== */
html {
    height: 100%;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

/* ===== Top Header Bar ===== */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--hamburger-bg);
    box-shadow: var(--shadow-md);
}

.top-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.top-header-icon {
    color: #94a3b8;
    flex-shrink: 0;
}

.top-header-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #ffffff;
}

.top-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.header-add-tool {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    padding: 0 14px;
    height: 36px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #cbd5e1;
    font-family: inherit;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.header-add-tool:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.2);
}

.user-menu {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.user-menu-trigger:hover {
    background: rgba(255, 255, 255, 0.1);
}

.top-header-username {
    font-size: 13px;
    font-weight: 500;
    color: #cbd5e1;
}

.top-header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #cbd5e1;
}

/* ===== User Dropdown ===== */
.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    background: var(--modal-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    z-index: 1200;
    animation: slideUp 0.2s ease;
}

.user-dropdown.open {
    display: block;
}

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.user-dropdown-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
}

.user-dropdown-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-dropdown-info strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-dropdown-info span {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.15s ease;
}

.user-dropdown-item:hover {
    background: var(--sidebar-hover);
}

.user-dropdown-item svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.user-dropdown-logout {
    color: var(--red);
}

.user-dropdown-logout svg {
    color: var(--red);
}

/* ===== Workspace Selector ===== */
.workspace-selector {
    position: relative;
}

.ws-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    padding: 0 12px;
    height: 36px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #cbd5e1;
    transition: background 0.2s ease, border-color 0.2s ease;
    font-family: inherit;
}

.ws-trigger:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.2);
}

.ws-trigger svg:first-child {
    opacity: 0.7;
}

.ws-chevron {
    opacity: 0.5;
    transition: transform 0.2s ease;
}

.workspace-dropdown.open ~ .ws-trigger .ws-chevron,
.workspace-selector:has(.workspace-dropdown.open) .ws-chevron {
    transform: rotate(180deg);
}

.workspace-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    background: var(--modal-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    z-index: 1200;
    animation: slideUp 0.2s ease;
}

.workspace-dropdown.open {
    display: block;
}

.ws-dropdown-header {
    padding: 12px 16px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.ws-list {
    max-height: 240px;
    overflow-y: auto;
}

.ws-empty {
    padding: 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
}

.ws-item-wrapper {
    position: relative;
}

.ws-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ws-item:hover {
    background: var(--sidebar-hover);
}

.ws-item-wrapper.ws-active .ws-item {
    background: var(--accent-light);
}

/* Inline confirmation (delete & rename) */
.ws-inline-confirm {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    animation: fadeIn 0.15s ease;
    gap: 8px;
}

.ws-item-wrapper.ws-confirming .ws-item,
.ws-item-wrapper.ws-renaming .ws-item {
    display: none;
}

.ws-item-wrapper.ws-confirming .ws-delete-confirm {
    display: flex;
}

.ws-item-wrapper.ws-renaming .ws-rename-confirm {
    display: flex;
}

.ws-inline-confirm-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.ws-inline-input {
    flex: 1;
    min-width: 0;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ws-inline-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.ws-inline-input.ws-input-error {
    border-color: var(--red);
    animation: shake 0.3s ease;
}

.ws-inline-confirm-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.ws-btn-cancel,
.ws-btn-delete,
.ws-btn-confirm {
    padding: 4px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.ws-btn-cancel {
    background: var(--border-light);
    color: var(--text-primary);
}

.ws-btn-cancel:hover {
    background: var(--border-color);
}

.ws-btn-delete {
    background: var(--red);
    color: #fff;
}

.ws-btn-delete:hover {
    background: #dc2626;
}

.ws-btn-confirm {
    background: var(--accent);
    color: #fff;
}

.ws-btn-confirm:hover {
    background: var(--accent-hover);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ws-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.ws-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ws-item-wrapper.ws-active .ws-item-name {
    color: var(--accent);
}

.ws-item-count {
    font-size: 11px;
    color: var(--text-muted);
}

.ws-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.ws-item:hover .ws-item-actions,
.ws-item-wrapper.ws-active .ws-item-actions {
    opacity: 1;
}

.ws-action-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
    padding: 0;
}

.ws-action-btn:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.ws-delete-btn:hover {
    color: var(--red);
}

.ws-new-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--border-light);
}

.ws-input {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ws-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.ws-input.ws-input-error {
    border-color: var(--red);
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.ws-input-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--accent-light);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    padding: 0;
}

.ws-input-btn:hover {
    background: var(--accent);
    color: #fff;
}

/* ===== New Workspace UI: Type Icons, Indentation, Parent Hint ===== */
.ws-trigger-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    min-width: 0;
}

.ws-parent-hint {
    font-size: 10px;
    color: rgba(203, 213, 225, 0.6);
    font-weight: 400;
    line-height: 1;
    margin-top: -1px;
}

#ws-active-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

#ws-active-icon svg {
    opacity: 0.7;
}

.ws-item-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.ws-type-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--text-muted);
}

.ws-type-enterprise {
    color: var(--red);
}

.ws-indented {
    padding-left: 20px;
}

.ws-indented .ws-item {
    padding-left: 12px;
}

.ws-add-child {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 16px 4px 40px;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
    cursor: pointer;
    transition: color 0.15s ease;
}

.ws-add-child:hover {
    color: var(--accent-hover);
}

.ws-add-child svg {
    opacity: 0.7;
}

.ws-divider {
    height: 1px;
    background: var(--border-light);
    margin: 4px 0;
}

.ws-new-row-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--text-muted);
}

/* ===== Unified Add Workspace Panel ===== */
.ws-add-row {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-top: 1px solid var(--border-light);
}

.ws-add-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: center;
    padding: 6px 0;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    background: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.ws-add-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-light);
}

.ws-add-btn svg {
    opacity: 0.6;
}

.ws-create-panel {
    border-top: 1px solid var(--border-light);
    padding: 10px 12px;
    animation: fadeIn 0.15s ease;
}

.ws-create-type-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.ws-create-type-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 0;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    background: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ws-create-type-btn:hover {
    border-color: var(--text-secondary);
}

.ws-create-type-btn.ws-create-type-active {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.ws-create-type-btn.ws-create-type-active svg {
    stroke: var(--accent);
}

.ws-create-type-btn.ws-create-type-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.ws-create-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ws-create-parent-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.ws-create-parent-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
}

.ws-create-parent-select {
    flex: 1;
    min-width: 0;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.ws-create-parent-select:focus {
    border-color: var(--accent);
}

/* ===== Hamburger Button ===== */
.hamburger-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
    transition: all 0.2s ease;
}

.hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.hamburger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: #ffffff;
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

.hamburger-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.hamburger-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.hamburger-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    top: 56px;
    left: -280px;
    width: 280px;
    height: calc(100% - 56px);
    background: var(--sidebar-bg);
    z-index: 1050;
    box-shadow: var(--shadow-lg);
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0;
    overflow: hidden;
}

.sidebar.open {
    left: 0;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 24px 16px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 32px;
    color: var(--accent);
}
.sidebar-brand svg {
    flex-shrink: 0;
}
.sidebar-brand span {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--sidebar-text);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--sidebar-text, #94a3b8);
    opacity: 0.55;
    padding: 12px 16px 4px;
    user-select: none;
}
.sidebar-section-label:first-child {
    padding-top: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--sidebar-text);
    border-radius: 12px;
    font-weight: 500;
    font-size: 15px;
    transition: all 0.2s ease;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: var(--accent);
}

.sidebar-nav a svg {
    flex-shrink: 0;
    opacity: 0.7;
}
.sidebar-nav a:hover svg {
    opacity: 1;
}

.sidebar-nav .sidebar-add {
    margin-top: 8px;
    background: var(--green);
    color: #ffffff;
    font-weight: 600;
}
.sidebar-nav .sidebar-add:hover {
    background: var(--green-hover);
    color: #ffffff;
}
.sidebar-nav .sidebar-add svg {
    opacity: 1;
}

.sidebar-bottom {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s ease;
}
.theme-toggle:hover {
    background: var(--sidebar-hover);
    color: var(--accent);
}

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

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    width: 100%;
    height: calc(100% - 56px);
    background: var(--overlay-bg);
    z-index: 1040;
    backdrop-filter: blur(3px);
}
.sidebar-backdrop.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

/* ===== Main Content ===== */
.main {
    margin-left: 0;
    padding: 116px 20px 20px 20px;
    min-height: 100%;
    transition: margin-left 0.3s ease;
}

#capabilities, #tooling {
    display: flex;
    flex-direction: column;
    gap: 0;
}

#tooling {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
}

/* ===== Domain Sections ===== */
.domain-section {
    margin-bottom: 8px;
}

.domain-header {
    display: flex;
    align-items: baseline;
    gap: 16px;
    padding: 18px 12px 10px 12px;
    border-bottom: 2px solid var(--border-color);
    margin: 0 8px;
}

.domain-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.domain-description {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.domain-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
}

/* ===== Blocks (Capability Cards) ===== */
.block {
    display: flex;
    flex-direction: column;
    margin: 12px 8px;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.block-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
    text-transform: uppercase;
    border-radius: 16px 16px 0 0;
}

.block-header[data-vendor] {
    cursor: pointer;
}
.block-header[data-vendor] > span {
    cursor: pointer;
}
.block-header[data-vendor]:hover > span {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

.block-header > span {
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.8px;
    text-align: center;
    white-space: nowrap;
}

.block-body {
    display: grid;
    grid-auto-columns: auto;
    grid-auto-flow: column;
    grid-template-rows: auto 1fr;
}

.block-content {
    display: contents;
}

.block-content + .block-content .subblock-header {
    border-left: 1px solid var(--block-divider);
}

.block-content + .block-content .subblock-content {
    border-left: 1px solid var(--block-divider);
}

.subblock-header {
    display: flex;
    color: var(--subblock-header-color);
    background: var(--subblock-header-bg);
    padding: 4px 14px;
    text-align: center;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 11px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    opacity: 0.75;
}

.subblock-content {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    max-height: 100px; /* ~2 rows of 45px tools */
    min-height: 57px; /* at least 1 row: 40px icon + 3px border + 8px margin + 6px pad */
    gap: 2px;
    padding: 6px 8px 8px 8px;
}

/* ===== Tool Icons ===== */
.subblock-tool {
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1.5px solid var(--tool-border);
    width: 40px;
    height: 40px;
    margin: 4px;
    padding: 4px;
    cursor: pointer;
    flex-shrink: 0;
    overflow: visible;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.subblock-tool:hover,
.subblock-tool:focus,
.subblock-tool:active {
    box-shadow: none;
    outline: none;
    border-color: var(--tool-border);
}

.subblock-tool .tooltip-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.subblock-tool .tooltip-container img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

/* ===== Adoption Badges ===== */
.tool-adoption-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid var(--tool-bg);
    z-index: 2;
}

.tool-preferred-star {
    position: absolute;
    top: -4px;
    left: -3px;
    font-size: 11px;
    color: #f59e0b;
    z-index: 2;
    line-height: 1;
}

.adoption-evaluating { background-color: #6366f1; }
.adoption-piloting { background-color: #f59e0b; }
.adoption-scaling { background-color: #f97316; }
.adoption-production { background-color: #10b981; }
.adoption-strategic { background-color: #8b5cf6; }

.tooltip-adoption-label {
    font-size: 11px;
    font-weight: 600;
}
.adoption-text-evaluating { color: #6366f1; }
.adoption-text-piloting { color: #f59e0b; }
.adoption-text-scaling { color: #f97316; }
.adoption-text-production { color: #10b981; }
.adoption-text-strategic { color: #8b5cf6; }

.tooltip-preferred-label {
    color: #f59e0b;
    font-weight: 600;
    font-size: 11px;
}

/* ===== Tooltips ===== */
.tooltip-container {
    position: relative;
    display: inline-block;
}

.tooltip-container .tooltip-text {
    visibility: hidden;
    background-color: var(--tooltip-bg);
    color: var(--tooltip-text);
    text-align: left;
    font-size: 13px;
    border-radius: 10px;
    padding: 8px 14px;
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    white-space: nowrap;
    z-index: 10;
    opacity: 0;
    transition: all 0.2s ease;
    max-width: 220px;
    word-wrap: break-word;
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

/* ===== Clickable Info Headers (capabilities & sub-capabilities) ===== */
.clickable-info {
    cursor: pointer;
}

.block-header .clickable-info:hover {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

.subblock-header .clickable-info:hover {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

/* ===== Description Popup ===== */
.modal-desc {
    width: 480px;
}

.desc-popup-text {
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-primary);
    margin: 0;
}

.desc-popup-importance {
    margin-top: 18px;
    padding: 14px 16px;
    background: var(--card-bg);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    display: none;
}

.desc-popup-importance p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

.desc-importance-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--accent);
    margin-bottom: 8px;
}

.desc-tools-section {
    margin-top: 20px;
}

.desc-tools-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.desc-tools-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
}

.desc-tool-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-tertiary);
}

.desc-tool-item img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    flex-shrink: 0;
    background: #ffffff;
    border-radius: 6px;
    padding: 2px;
}

.desc-tool-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.desc-tool-info strong {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.desc-tool-info span {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Modal Overlay ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    z-index: 1200;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== Modal ===== */
.modal {
    background: var(--modal-bg);
    border-radius: 20px;
    width: 680px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.modal-sm {
    width: 500px;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--modal-header-bg);
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #94a3b8;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}
.modal-close-btn:hover {
    color: #ffffff;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.modal-footer:has(.modal-footer-right) {
    justify-content: space-between;
}

.modal-footer-right {
    display: flex;
    gap: 10px;
}

.btn-icon-only {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
}

/* ===== Buttons ===== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: all 0.2s ease;
}
.btn:hover {
    transform: translateY(-1px);
}
.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--green);
    color: #ffffff;
}
.btn-primary:hover {
    background: var(--green-hover);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-secondary {
    background: var(--accent);
    color: #ffffff;
}
.btn-secondary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}

.btn-cancel {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-cancel:hover {
    background: var(--border-color);
}

.btn-warn {
    background: var(--orange);
    color: #ffffff;
}
.btn-warn:hover {
    background: var(--orange-hover);
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-danger {
    background: var(--red);
    color: #ffffff;
}
.btn-danger:hover {
    background: var(--red-hover);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

/* ===== Wizard Step 1: Tool List ===== */
.wizard-search {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--search-border);
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 16px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--bg-secondary);
    color: var(--text-primary);
}
.wizard-search:focus {
    border-color: var(--search-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.wizard-tool-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}

.wizard-tool-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 2px solid var(--wizard-card-border);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
}
.wizard-tool-card:hover {
    border-color: var(--accent);
    background: var(--wizard-card-hover-bg);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.wizard-tool-card.already-added {
    border-color: var(--wizard-added-border);
    background: var(--wizard-added-bg);
}
.wizard-tool-card.already-added:hover {
    border-color: var(--green);
}

.wizard-tool-card img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.wizard-tool-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}
.wizard-tool-info strong {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}
.wizard-tool-info span {
    font-size: 11px;
    color: var(--text-muted);
}
.wizard-tool-info .cap-count {
    color: var(--accent);
    font-weight: 600;
}

.badge {
    font-size: 10px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
    letter-spacing: 0.3px;
}
.badge-active {
    background: var(--badge-active-bg);
    color: var(--badge-active-text);
}

.wizard-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== Wizard Step 2: Capabilities ===== */
.wizard-tool-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--accent-light);
    border-radius: 14px;
    margin-bottom: 16px;
}
.wizard-tool-header img {
    width: 44px;
    height: 44px;
    object-fit: contain;
}
.wizard-tool-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.wizard-tool-header span {
    color: var(--text-secondary);
    font-size: 13px;
}

.wizard-cap-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.wizard-capabilities {
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
}

.wizard-cap-actions {
    margin-bottom: 14px;
    font-size: 13px;
}
.wizard-cap-actions a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.wizard-cap-actions a:hover {
    text-decoration: underline;
}

.wizard-cap-group {
    margin-bottom: 14px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
}

.wizard-cap-group-header {
    background: var(--cap-group-header-bg);
    color: var(--cap-group-header-text);
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wizard-cap-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid var(--cap-item-border);
    font-size: 13px;
    color: var(--text-primary);
}
.wizard-cap-item:last-child {
    border-bottom: none;
}
.wizard-cap-item:hover {
    background: var(--cap-item-hover);
}
.wizard-cap-item input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

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

.remove-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
}

/* ===== Wizard Step 3: Adoption & Preferred ===== */
.wizard-meta-section {
    margin-top: 16px;
}

.wizard-meta-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.wizard-adoption-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wizard-adoption-option {
    cursor: pointer;
}
.wizard-adoption-option input[type="radio"] {
    display: none;
}

.wizard-adoption-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    transition: border-color 0.15s, background 0.15s;
}
.wizard-adoption-option input[type="radio"]:checked + .wizard-adoption-card {
    border-color: var(--accent);
    background: var(--accent-light);
}
.wizard-adoption-card:hover {
    border-color: var(--accent);
}

.adoption-dot-lg {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.wizard-adoption-info {
    display: flex;
    flex-direction: column;
}
.wizard-adoption-info strong {
    font-size: 14px;
    color: var(--text-primary);
}
.wizard-adoption-info span {
    font-size: 12px;
    color: var(--text-muted);
}

.wizard-preferred-section {
    margin-top: 4px;
}

.wizard-preferred-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    transition: border-color 0.15s, background 0.15s;
}
.wizard-preferred-toggle:has(input:checked) {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.08);
}

.wizard-preferred-toggle input[type="checkbox"] {
    display: none;
}

.wizard-preferred-label {
    display: flex;
    align-items: center;
    gap: 10px;
}
.wizard-preferred-star {
    font-size: 20px;
    color: #d1d5db;
    transition: color 0.15s;
}
.wizard-preferred-toggle:has(input:checked) .wizard-preferred-star {
    color: #f59e0b;
}
.wizard-preferred-label strong {
    display: block;
    font-size: 14px;
    color: var(--text-primary);
}
.wizard-preferred-label > div > span {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 80px 20px;
    text-align: center;
    color: var(--empty-state-color);
}
.empty-state h2 {
    margin: 0 0 10px 0;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}
.empty-state p {
    font-size: 15px;
    max-width: 400px;
    line-height: 1.6;
}

/* ===== Glossary ===== */
.glossary-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px 24px;
    margin: 12px 8px 4px 8px;
}

.glossary-card-header {
    margin-bottom: 8px;
}

.glossary-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.glossary-card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
    line-height: 1.5;
}

.glossary-importance {
    font-size: 13px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}

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

.glossary-sub {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 14px 16px;
}

.glossary-sub-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.glossary-sub-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.45;
    margin-bottom: 6px;
}

.glossary-sub-importance {
    margin-top: 8px;
    margin-bottom: 8px;
}

.glossary-sub-importance p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.45;
    margin: 0;
}

.glossary-sub-tools {
    margin-top: 10px;
}

.glossary-sub-tools .desc-tools-grid {
    grid-template-columns: 1fr;
    max-height: none;
}

/* ===== Radar Chart ===== */
.radar-chart-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

.radar-chart-header {
    text-align: center;
    margin-bottom: 32px;
}

.radar-chart-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px 0;
}

.radar-chart-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

.radar-scoring-link {
    font-size: inherit;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
}

.radar-scoring-link:hover {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}

.scoring-intro {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 20px 0;
}

.scoring-section {
    margin-bottom: 20px;
}

.scoring-dimension {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.scoring-weight {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    padding: 2px 8px;
    border-radius: 10px;
}

.scoring-section > p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 10px 0;
}

.scoring-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.scoring-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 10px;
    border-bottom: 2px solid var(--border-color);
}

.scoring-table td {
    padding: 6px 10px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
}

.scoring-formula {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px 16px;
    text-align: center;
    margin-top: 8px;
}

.radar-chart-explanation {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.radar-explain-item {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 8px 14px;
    line-height: 1.4;
}

.radar-explain-item strong {
    color: var(--text-primary);
}

.radar-chart-body {
    display: flex;
    gap: 48px;
    align-items: flex-start;
}

.radar-chart-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
}

#radar-canvas {
    display: block;
    max-width: 100%;
    height: auto !important;
}

.radar-legend {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    min-width: 0;
}

@media (max-width: 900px) {
    .radar-chart-body {
        flex-direction: column;
    }
    .radar-chart-wrapper {
        flex: none;
        width: 100%;
    }
    .radar-legend {
        flex: none;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

.radar-legend-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 18px;
}

.radar-legend-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.radar-legend-domain {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.radar-legend-score {
    font-size: 13px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    min-width: 65px;
    text-align: center;
}

.radar-score-high {
    background: var(--green-light);
    color: var(--green);
}

.radar-score-mid {
    background: var(--accent-light);
    color: var(--accent);
}

.radar-score-low {
    background: #fef2f2;
    color: var(--red);
}

[data-theme="dark"] .radar-score-high {
    background: rgba(16, 185, 129, 0.15);
}

[data-theme="dark"] .radar-score-mid {
    background: rgba(59, 130, 246, 0.15);
}

[data-theme="dark"] .radar-score-low {
    background: rgba(239, 68, 68, 0.15);
}

.radar-legend-dimensions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.radar-dim {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    padding: 6px 0;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.radar-dim-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.radar-dim-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.radar-legend-bar-track {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.radar-legend-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.4s ease;
}

.radar-legend-detail {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Enterprise Mode ===== */

/* Enterprise Toggle Button */
/* ===== (Enterprise toggle removed — enterprise is now a workspace type) ===== */

/* Enterprise Status Badge on Tool Icons */
.tool-enterprise-badge {
    position: absolute;
    bottom: -2px;
    left: -2px;
    font-size: 10px;
    line-height: 1;
    z-index: 2;
}

.tooltip-enterprise-label {
    font-size: 11px;
    font-weight: 500;
    margin-top: 2px;
    display: inline-block;
}

/* Enterprise Status Radio Cards (wizard / manage) */
.wizard-status-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wizard-status-option input[type="radio"] {
    display: none;
}

.wizard-status-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.wizard-status-card:hover {
    border-color: var(--text-secondary);
}

.wizard-status-option input:checked + .wizard-status-card {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.06);
}

.wizard-status-icon {
    font-size: 18px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

.wizard-status-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.wizard-status-info strong {
    font-size: 13px;
    color: var(--text-primary);
}

.wizard-status-info span {
    font-size: 12px;
    color: var(--text-muted);
}

/* Radar Chart Polygon Legend */
.radar-polygon-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.radar-polygon-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

/* Radar Legend Compare Score */
.radar-legend-compare {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-left: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-secondary);
}

/* ===== Process View ===== */

/* Viewport: the visible clipping area */
#proces {
    position: relative;
    height: calc(100vh - 100px);
    margin: -16px -20px -20px;
}

/* ============================================================
   FLOW BUILDER — inline edit mode
   ============================================================ */

/* Sub-header bar below the top header */
#view-subheader {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    z-index: 1040;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    background: var(--subheader-bg);
    color: #e2e8f0;
    height: 0;
    overflow: hidden;
    opacity: 0;
    transition: height 0.3s ease, opacity 0.25s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
#view-subheader.open {
    height: 44px;
    opacity: 1;
}
.subheader-title {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
#fb-toolbar-controls {
    display: none;
    align-items: center;
    gap: 8px;
    flex: 1;
}
#fb-toolbar-controls.visible {
    display: flex;
}
.fb-toolbar-sep {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.15);
    margin: 0 4px;
    flex-shrink: 0;
}
.fb-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    background: transparent;
    color: #e2e8f0;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.fb-btn:hover { background: rgba(255,255,255,0.1); }
.fb-btn.primary { background: #3b82f6; border-color: #3b82f6; }
.fb-btn.primary:hover { background: #2563eb; }
.fb-btn.green { background: #10b981; border-color: #10b981; }
.fb-btn.green:hover { background: #059669; }
.fb-btn-outline { background: transparent !important; border: 1.5px solid #475569 !important; color: #cbd5e1 !important; }
.fb-btn-outline:hover { border-color: #94a3b8 !important; background: rgba(148,163,184,0.1) !important; }
.fb-btn.danger { border-color: #ef4444; color: #fca5a5; }
.fb-btn.danger:hover { background: #ef4444; color: #fff; }
.fb-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.fb-toolbar-spacer { flex: 1; }

/* Edit-only toolbar buttons (hidden in view mode) */
.fb-edit-only { display: none !important; }
#view-subheader.fb-editing .fb-edit-only { display: flex !important; }
#view-subheader.fb-editing .fb-edit-only.fb-hidden { display: none !important; }

/* View-only toolbar buttons (hidden in edit mode) */
.fb-view-only { display: flex; }
#view-subheader.fb-editing .fb-view-only { display: none !important; }

/* Editing indicator label */
.fb-editing-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #fbbf24;
    padding: 4px 10px;
    background: rgba(251,191,36,0.15);
    border-radius: 4px;
    white-space: nowrap;
}

/* Close/back button in toolbar */
.fb-close-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: #e2e8f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.15s;
}
.fb-close-btn:hover { background: rgba(255,255,255,0.1); }
.fb-close-btn svg { width: 14px; height: 14px; }

/* Flow builder canvas wrapper — fills the proces area (always visible) */
#fb-canvasWrapper {
    position: absolute;
    top: 0; left: 0; right: 0;
    bottom: 0;
    overflow: hidden;
    cursor: default;
    background: var(--bg-primary);
    z-index: 10;
}
#fb-canvasWrapper.grabbing { cursor: grabbing; }
.fb-mode-edit #fb-canvasWrapper.connecting { cursor: crosshair; }

#fb-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 8000px;
    height: 8000px;
    transform-origin: 0 0;
}
.fb-canvas-grid {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.fb-mode-edit .fb-canvas-grid {
    background-image:
        linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}

#fb-lines-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}
#fb-lines-svg path, #fb-lines-svg polygon {
    pointer-events: stroke;
    cursor: pointer;
}
.fb-arrow-path {
    animation: fb-dash-flow 0.6s linear infinite;
}
@keyframes fb-dash-flow {
    to { stroke-dashoffset: -12; }
}

/* ===== Domain blocks (dashed containers) ===== */
.fb-domain {
    position: absolute;
    border: 2px dashed #cbd5e1;
    border-radius: 14px;
    background: #f8fafc;
    z-index: 2;
    box-sizing: border-box;
}
.fb-domain.selected {
    outline: 2px solid #3b82f6;
    outline-offset: 3px;
}
.fb-mode-edit .fb-domain {
    cursor: grab;
}
.fb-domain-label {
    position: absolute;
    top: 10px;
    left: 16px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #94a3b8;
    user-select: none;
}
.fb-domain-body {
    position: absolute;
    top: 36px;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px;
}

/* ===== Subdomain blocks (cards inside domains) ===== */
.fb-subdomain {
    position: absolute;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    border: 1px solid #e2e8f0;
    min-width: 160px;
    min-height: 100px;
    z-index: 3;
}
.fb-subdomain.selected {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
.fb-mode-edit .fb-subdomain {
    cursor: grab;
}
.fb-subdomain-header {
    background: #1e293b;
    color: #fff;
    padding: 10px 14px;
    border-radius: 11px 11px 0 0;
    font-size: 14px;
    font-weight: 600;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.fb-subdomain-header:hover {
    background: #334155;
}
.fb-subdomain-header.fb-no-tools {
    background: #991b1b;
}
.fb-subdomain-header.fb-no-tools:hover {
    background: #7f1d1d;
}
.fb-subdomain-header-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.fb-subdomain-header:hover .fb-subdomain-header-text {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}
.fb-process-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    line-height: 1;
    padding: 0 6px;
    margin-left: auto;
}
.fb-subdomain-body {
    padding: 8px 10px;
    min-height: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-content: flex-start;
}
.fb-tool-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--tool-border, #e2e8f0);
    padding: 4px;
}
.fb-tool-icon img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}



/* ===== Score Popover (view-mode quick-edit) ===== */
.fb-score-popover {
    position: fixed;
    z-index: 10000;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 1.5px 6px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    min-width: 220px;
    max-width: 300px;
    padding: 6px;
    animation: fbPopIn 0.12s ease-out;
}
@keyframes fbPopIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fb-score-popover-question {
    padding: 8px 10px 6px;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 4px;
    line-height: 1.4;
}
.fb-score-popover-desc {
    padding: 6px 10px 8px;
    font-size: 11px;
    color: #64748b;
    border-top: 1px solid #f1f5f9;
    margin-top: 4px;
    line-height: 1.4;
}
.fb-score-popover-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s;
    font-size: 13px;
}
.fb-score-popover-item:hover {
    background: #f1f5f9;
}
.fb-score-popover-item.active {
    background: #eff6ff;
    font-weight: 600;
}
.fb-score-popover-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}
.fb-score-popover-label {
    flex: 1;
    color: #1e293b;
}
.fb-score-popover-value {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
    min-width: 14px;
    text-align: right;
}

/* Dark theme */\n[data-theme=\"dark\"] .fb-score-popover {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
[data-theme="dark"] .fb-score-popover-question {
    color: #e2e8f0;
    border-bottom-color: #334155;
}
[data-theme="dark"] .fb-score-popover-desc {
    color: #94a3b8;
    border-top-color: #334155;
}
[data-theme="dark"] .fb-score-popover-item:hover {
    background: #273548;
}
[data-theme="dark"] .fb-score-popover-item.active {
    background: #1e3a5f;
}
[data-theme="dark"] .fb-score-popover-label {
    color: #e2e8f0;
}

/* ===== Process Score Selector in edit modal ===== */
.fb-process-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}
.fb-process-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: #fff;
}
.fb-process-option:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}
.fb-process-option.selected {
    border-color: #3b82f6;
    background: #eff6ff;
}
.fb-process-option-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}
.fb-process-option-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.fb-process-option-label {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}
.fb-process-option-score {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

/* Dark theme overrides for process options */\n[data-theme=\"dark\"] .fb-process-option {
    background: #1e293b;
    border-color: #334155;
}
[data-theme="dark"] .fb-process-option:hover {
    border-color: #64748b;
    background: #273548;
}
[data-theme="dark"] .fb-process-option.selected {
    border-color: #3b82f6;
    background: #1e3a5f;
}
[data-theme="dark"] .fb-process-option-label {
    color: #e2e8f0;
}
[data-theme="dark"] .fb-process-option-score {
    color: #94a3b8;
}

/* ===== Edge handles ===== */
.fb-edge {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #94a3b8;
    border: 2px solid #fff;
    z-index: 10;
    cursor: pointer;
    display: none;
    transition: width 0.15s, height 0.15s, margin 0.15s, background 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.fb-mode-edit .fb-edge { display: block; }
.fb-edge:hover {
    width: 20px;
    height: 20px;
    background: #3b82f6;
}
.fb-edge::after {
    content: '+';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
}
.fb-edge:hover::after {
    opacity: 1;
}
/* Subdomain edges (left/right) */
.fb-subdomain .fb-edge-left  { left: -6px; top: 50%; margin-top: -6px; }
.fb-subdomain .fb-edge-right { right: -6px; top: 50%; margin-top: -6px; }
.fb-subdomain .fb-edge-top    { top: -6px; left: 50%; margin-left: -6px; }
.fb-subdomain .fb-edge-bottom { bottom: -6px; left: 50%; margin-left: -6px; }
.fb-subdomain .fb-edge-left:hover  { left: -10px; margin-top: -10px; }
.fb-subdomain .fb-edge-right:hover { right: -10px; margin-top: -10px; }
.fb-subdomain .fb-edge-top:hover    { top: -10px; margin-left: -10px; }
.fb-subdomain .fb-edge-bottom:hover { bottom: -10px; margin-left: -10px; }
/* Domain edges (all 4 sides) */
.fb-edge-domain.fb-edge-top    { top: -6px; left: 50%; margin-left: -6px; }
.fb-edge-domain.fb-edge-bottom { bottom: -6px; left: 50%; margin-left: -6px; }
.fb-edge-domain.fb-edge-left   { left: -6px; top: 50%; margin-top: -6px; }
.fb-edge-domain.fb-edge-right  { right: -6px; top: 50%; margin-top: -6px; }
.fb-edge-domain.fb-edge-top:hover    { top: -10px; margin-left: -10px; }
.fb-edge-domain.fb-edge-bottom:hover { bottom: -10px; margin-left: -10px; }
.fb-edge-domain.fb-edge-left:hover   { left: -10px; margin-top: -10px; }
.fb-edge-domain.fb-edge-right:hover  { right: -10px; margin-top: -10px; }

/* ===== Add subdomain button ===== */
.fb-add-sub {
    position: absolute;
    bottom: 10px;
    right: 10px;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.fb-mode-edit .fb-add-sub { display: flex; }
.fb-add-sub:hover { border-color: #3b82f6; color: #3b82f6; background: #f0f4ff; }

/* ===== Resize handles (edges + corners) ===== */
.fb-resize {
    position: absolute;
    display: none;
    z-index: 8;
}
.fb-mode-edit .fb-resize { display: block; }
/* Edges */
.fb-resize-top    { top: -4px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.fb-resize-bottom { bottom: -4px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.fb-resize-left   { left: -4px; top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
.fb-resize-right  { right: -4px; top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
/* Corners */
.fb-resize-top-left     { top: -4px; left: -4px; width: 12px; height: 12px; cursor: nwse-resize; }
.fb-resize-top-right    { top: -4px; right: -4px; width: 12px; height: 12px; cursor: nesw-resize; }
.fb-resize-bottom-left  { bottom: -4px; left: -4px; width: 12px; height: 12px; cursor: nesw-resize; }
.fb-resize-bottom-right { bottom: -4px; right: -4px; width: 12px; height: 12px; cursor: nwse-resize; }

/* ===== Edit-only items ===== */
#fb-canvasWrapper .edit-only { display: none; }
.fb-mode-edit #fb-canvasWrapper .edit-only { display: flex; }

/* Flow builder modals */
.fb-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1500;
    align-items: center;
    justify-content: center;
}
.fb-modal-overlay.open { display: flex; }
.fb-modal {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 420px;
    max-width: 90vw;
    overflow: hidden;
}
.fb-modal-header {
    background: #1e293b;
    color: #fff;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.fb-modal-close {
    background: none; border: none; color: #fff; cursor: pointer;
    font-size: 18px; opacity: 0.7; transition: opacity 0.15s;
}
.fb-modal-close:hover { opacity: 1; }
.fb-modal-body { padding: 20px; }
.fb-modal-body label {
    display: block; font-size: 12px; font-weight: 600;
    color: #1a1a2e; margin-bottom: 6px;
}
.fb-modal-body input,
.fb-modal-body textarea {
    width: 100%; padding: 8px 12px;
    border: 1px solid #d1d5db; border-radius: 6px;
    font-family: inherit; font-size: 13px;
    margin-bottom: 14px; outline: none; transition: border 0.15s;
    box-sizing: border-box;
}
.fb-modal-body input:focus,
.fb-modal-body textarea:focus { border-color: #3b82f6; }
.fb-modal-body textarea { resize: vertical; min-height: 60px; }

/* Subcapability picker */
.fb-caps-tags {
    display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.fb-cap-tag {
    display: inline-flex; align-items: center; gap: 4px;
    background: #e0f2fe; color: #0369a1; padding: 4px 8px;
    border-radius: 6px; font-size: 11px; font-weight: 500;
}
.fb-cap-tag button {
    background: none; border: none; color: #0369a1; cursor: pointer;
    font-size: 14px; line-height: 1; padding: 0 2px; font-weight: 700;
}
.fb-cap-tag button:hover { color: #dc2626; }
.fb-caps-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border: 1px solid #d1d5db; border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12); max-height: 200px;
    overflow-y: auto; z-index: 100; display: none;
}
.fb-caps-option {
    padding: 8px 12px; font-size: 12px; cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}
.fb-caps-option:hover { background: #f0f9ff; }
.fb-caps-option:last-child { border-bottom: none; }

.fb-modal-actions {
    display: flex; gap: 8px; justify-content: flex-end; padding: 0 20px 16px;
}
.fb-modal-actions button {
    padding: 8px 18px; border-radius: 6px; border: 1px solid #d1d5db;
    background: #fff; font-family: inherit; font-size: 12px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.fb-modal-actions .fb-btn-primary { background: #3b82f6; color: #fff; border-color: #3b82f6; }
.fb-modal-actions .fb-btn-primary:hover { background: #2563eb; }

/* Context menus */
.fb-ctx-menu {
    display: none; position: fixed; background: #fff; border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15); z-index: 1600;
    min-width: 180px; padding: 4px 0; font-size: 12px;
}
.fb-ctx-menu.open { display: block; }
.fb-ctx-item {
    padding: 8px 14px; cursor: pointer; display: flex;
    align-items: center; gap: 8px; color: #1a1a2e; transition: background 0.1s;
}
.fb-ctx-item:hover { background: #f0f4ff; }
.fb-ctx-item.danger { color: #ef4444; }
.fb-ctx-item.danger:hover { background: #fef2f2; }
.fb-ctx-sep { height: 1px; background: #e5e7eb; margin: 4px 0; }

/* Toast */
#fb-toast {
    position: fixed; bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #1e293b; color: #fff;
    padding: 10px 20px; border-radius: 8px;
    font-size: 12px; font-weight: 500; z-index: 1900;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
#fb-toast.show { transform: translateX(-50%) translateY(0); }

/* Zoom controls */
.fb-zoom-indicator {
    position: absolute; bottom: 16px; right: 16px;
    background: #fff; border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 6px 12px; font-size: 11px; font-weight: 600;
    color: #64748b; z-index: 50;
    display: flex; align-items: center; gap: 8px;
}
.fb-zoom-btn {
    background: none; border: 1px solid #e2e8f0; border-radius: 4px;
    width: 24px; height: 24px; display: flex; align-items: center;
    justify-content: center; cursor: pointer; font-size: 14px;
    font-weight: 700; color: #1a1a2e;
}
.fb-zoom-btn:hover { background: #f0f4ff; }

/* Help hint */
.fb-help-hint {
    position: absolute; bottom: 16px; left: 16px;
    background: #fff; border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 8px 12px; font-size: 10px; color: #64748b;
    z-index: 50; line-height: 1.6; display: none;
}
.fb-mode-edit .fb-help-hint { display: block; }
.fb-help-hint kbd {
    background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 3px;
    padding: 1px 4px; font-size: 9px; font-family: inherit; font-weight: 600;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
/* When a session exists, hide login and show app immediately to prevent flash */
html[data-has-session] .login-screen { display: none !important; }
html[data-has-session] .top-header { display: flex !important; }
html[data-has-session] .sidebar { display: block !important; }
html[data-has-session] .main { display: block !important; }

.login-screen {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-primary);
    animation: loginFadeIn 0.4s ease;
}
.login-screen.login-exit {
    animation: loginFadeOut 0.3s ease forwards;
}
@keyframes loginFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes loginFadeOut { from { opacity: 1; } to { opacity: 0; } }

.login-card {
    width: 100%; max-width: 420px; padding: 48px 36px;
    text-align: center;
}
.login-logo {
    margin-bottom: 16px; color: var(--accent);
}
.login-title {
    font-size: 24px; font-weight: 700; color: var(--text-primary);
    margin: 0 0 6px;
}
.login-subtitle {
    font-size: 14px; color: var(--text-secondary); margin: 0 0 32px;
}
.login-options {
    display: flex; flex-direction: column; gap: 12px;
}
.login-option {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 18px; border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary, #fff);
    cursor: pointer; text-align: left;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    font-family: inherit; font-size: inherit; color: var(--text-primary);
    text-decoration: none;
}
.login-option:hover:not(.disabled) {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}
.login-option.disabled {
    opacity: 0.45; cursor: not-allowed;
    pointer-events: auto;
}
.login-option-icon {
    flex-shrink: 0; width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px;
    background: var(--accent-light); color: var(--accent);
}
.login-option.disabled .login-option-icon {
    background: var(--border-color); color: var(--text-secondary);
}
.login-option-text {
    flex: 1; display: flex; flex-direction: column; gap: 2px;
}
.login-option-label {
    font-weight: 600; font-size: 15px;
}
.login-option-desc {
    font-size: 12px; color: var(--text-secondary);
}
.login-option-arrow {
    flex-shrink: 0; color: var(--text-secondary);
    transition: transform 0.2s;
}
.login-option:hover:not(.disabled) .login-option-arrow {
    transform: translateX(3px); color: var(--accent);
}
.login-option-badge {
    flex-shrink: 0; font-size: 11px; font-weight: 600;
    padding: 3px 10px; border-radius: 99px;
    background: var(--border-color); color: var(--text-secondary);
}

/* Login - Local Users List */
.login-section-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-secondary);
    margin-bottom: 8px; padding-left: 2px;
}
.login-users {
    margin-bottom: 16px;
}
.login-user-row {
    display: flex; align-items: center; gap: 4px; margin-bottom: 6px;
}
.login-user-delete {
    background: transparent; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 16px; padding: 6px 8px;
    border-radius: 6px; transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}
.login-user-delete:hover {
    color: #ef4444; background: rgba(239,68,68,0.1);
}
.login-user-btn {
    display: flex; align-items: center; gap: 12px; flex: 1;
    padding: 12px 14px; border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary); color: var(--text-primary);
    cursor: pointer; text-align: left; font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.login-user-btn:hover {
    border-color: var(--accent); box-shadow: var(--shadow-sm);
}
.login-user-btn:hover .login-option-arrow {
    transform: translateX(3px); color: var(--accent);
}
.login-user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600; flex-shrink: 0;
}
.login-user-info {
    flex: 1; display: flex; align-items: center; gap: 6px;
}
.login-user-name {
    font-weight: 600; font-size: 14px;
}
.login-user-lock {
    color: var(--text-secondary); flex-shrink: 0;
}

/* Login - Divider */
.login-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 4px 0; color: var(--text-secondary); font-size: 12px;
}
.login-divider::before, .login-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border-color);
}

/* Login - Create Form */
.login-create-form {
    display: flex; flex-direction: column; gap: 10px;
    padding: 16px; border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
.login-input {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary); color: var(--text-primary);
    font-family: inherit; font-size: 14px;
    outline: none; transition: border-color 0.2s;
    box-sizing: border-box;
}
.login-input:focus {
    border-color: var(--accent);
}
.login-input::placeholder {
    color: var(--text-secondary);
}
.login-form-actions {
    display: flex; gap: 8px; justify-content: flex-end;
}
.login-form-btn {
    padding: 8px 16px; border-radius: 8px; border: none;
    font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: background 0.2s;
}
.login-form-btn.primary {
    background: var(--accent); color: #fff;
}
.login-form-btn.primary:hover {
    background: var(--accent-hover);
}
.login-form-btn.cancel {
    background: transparent; color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.login-form-btn.cancel:hover {
    background: var(--border-color);
}

/* Login - Password Prompt */
.login-password-prompt {
    display: flex; flex-direction: column; gap: 12px;
    padding: 20px; border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
.login-password-header {
    font-weight: 600; font-size: 15px; text-align: center;
    color: var(--text-primary);
}
.login-error {
    font-size: 12px; color: #ef4444; text-align: center;
}

/* Login - Guest option subtle style */
.login-option-guest .login-option-icon.guest {
    background: var(--border-color); color: var(--text-secondary);
}
