@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --primary-light: #eff6ff;
    --accent:        #06b6d4;
    --bg:            #f8fafc;
    --sidebar-bg:    #0f172a;
    --sidebar-text:  #94a3b8;
    --sidebar-active:#2563eb;
    --white:         #ffffff;
    --border:        #e2e8f0;
    --text:          #0f172a;
    --sub:           #64748b;
    --success:       #10b981;
    --warning:       #f59e0b;
    --danger:        #ef4444;
    --info:          #3b82f6;
    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 1px 3px 0 rgb(0 0 0/.1), 0 1px 2px -1px rgb(0 0 0/.1);
    --shadow-md:     0 4px 6px -1px rgb(0 0 0/.1), 0 2px 4px -2px rgb(0 0 0/.1);
    --shadow-lg:     0 10px 15px -3px rgb(0 0 0/.1), 0 4px 6px -4px rgb(0 0 0/.1);
    --sidebar-w:     260px;
    --header-h:      64px;
    --transition:    0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Sora', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    padding: 14px 22px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(16px);
    transition: all 0.3s cubic-bezier(.34,1.56,.64,1);
    pointer-events: none;
    max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast-success { background: var(--success); color: #fff; }
.toast-error   { background: var(--danger);  color: #fff; }
.toast-info    { background: var(--info);    color: #fff; }

/* ── MODAL ── */
.modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(15,23,42,.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeOverlay .2s ease;
}
@keyframes fadeOverlay { from{opacity:0} to{opacity:1} }

.modal-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes slideUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }

.modal-box h3 { font-size: 1.1rem; margin-bottom: 16px; color: var(--text); }

/* ── AUTH ── */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.auth-container::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37,99,235,.15) 0%, transparent 70%);
    top: -200px; right: -200px;
}
.auth-container::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(6,182,212,.1) 0%, transparent 70%);
    bottom: -100px; left: -100px;
}

.auth-card {
    background: var(--white);
    padding: 40px 44px;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,.5);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    text-align: center;
    animation: slideUp .4s ease;
}

.auth-card .logo-img {
    width: 160px;
    margin-bottom: 8px;
}

.brand-sub {
    color: var(--sub);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    margin-bottom: 28px;
    text-transform: uppercase;
}

.forgot-link {
    display: block;
    margin-top: 16px;
    color: var(--primary);
    font-size: 0.82rem;
    text-decoration: none;
    transition: color var(--transition);
}
.forgot-link:hover { color: var(--primary-dark); text-decoration: underline; }

.msg-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.82rem;
    margin-bottom: 12px;
    text-align: left;
}

/* ── APP LAYOUT ── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform var(--transition);
    overflow-y: auto;
}

.sidebar-logo-wrap {
    padding: 24px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo {
    width: 140px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.sidebar-logo-text {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    letter-spacing: -0.02em;
    display: none;
}

.nav-section-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(148,163,184,.5);
    padding: 20px 20px 8px;
}

.nav-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding-bottom: 16px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    margin: 2px 10px;
    transition: all var(--transition);
    position: relative;
}
.nav-item i { width: 18px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.logout-link { color: #f87171 !important; margin-top: auto; }
.logout-link:hover { background: rgba(239,68,68,.12) !important; color: #fca5a5 !important; }

/* mobile sidebar toggle */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ── MAIN CONTAINER ── */
.main-container {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── HEADER ── */
header {
    height: var(--header-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sub);
    font-size: 1.2rem;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.menu-toggle:hover { background: var(--bg); }

.breadcrumb {
    font-size: 0.8rem;
    color: var(--sub);
    display: flex;
    align-items: center;
    gap: 6px;
}
.breadcrumb strong { color: var(--text); }

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

#user-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text);
    display: block;
}

#user-role {
    font-size: 0.72rem;
    color: var(--sub);
    display: block;
    text-transform: capitalize;
}

.avatar {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

/* ── CONTENT ── */
.content-area {
    padding: 32px;
    overflow-y: auto;
    flex: 1;
}

/* ── PAGE HEADER ── */
.page-header {
    margin-bottom: 28px;
}
.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}
.page-header p {
    color: var(--sub);
    font-size: 0.85rem;
    margin-top: 4px;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}
.header-row h2 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }

/* ── CARDS ── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 18px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-title i { color: var(--primary); }

/* ── STATS GRID ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.stat-icon.blue   { background: #eff6ff; color: var(--primary); }
.stat-icon.green  { background: #ecfdf5; color: var(--success); }
.stat-icon.yellow { background: #fffbeb; color: var(--warning); }
.stat-icon.cyan   { background: #ecfeff; color: var(--accent); }

.stat-info small {
    font-size: 0.72rem;
    color: var(--sub);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    display: block;
}
.stat-info h3 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-top: 4px;
    font-family: 'JetBrains Mono', monospace;
}

/* ── FORMS ── */
.group { margin-bottom: 18px; }

label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--sub);
    text-transform: uppercase;
    letter-spacing: .04em;
}

input, select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 90px; }
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled)   { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-secondary { background: var(--bg); color: var(--sub); border: 1.5px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #f1f5f9; color: var(--text); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled)   { background: #059669; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled)    { background: #dc2626; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled)   { background: #d97706; }
.btn-info      { background: var(--info); color: #fff; }
.btn-info:hover:not(:disabled)      { background: #2563eb; }
.btn-block { width: 100%; margin-top: 6px; padding: 12px; }
.btn-sm { padding: 6px 10px; font-size: 0.78rem; }

.btn-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── BADGES ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: .02em;
}
.badge-success { background: #ecfdf5; color: #059669; }
.badge-warning { background: #fffbeb; color: #d97706; }
.badge-danger  { background: #fef2f2; color: #dc2626; }
.badge-info    { background: #eff6ff; color: #2563eb; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}
th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--sub);
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1.5px solid var(--border);
    background: var(--bg);
}
td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    white-space: normal;
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

code {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.82rem;
    color: var(--primary);
    font-weight: 600;
}

/* ── EMPTY STATE ── */
.empty-msg {
    text-align: center;
    color: var(--sub);
    padding: 32px 20px;
    font-size: 0.875rem;
}
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 48px 20px;
    color: var(--sub);
}
.empty-state i { font-size: 2.5rem; opacity: .3; }
.empty-state p { font-size: 0.9rem; }

/* ── TABS ── */
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn .25s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ── FILTROS CARD ── */
.filtros-card { padding: 18px 24px; }
.filtros-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filtros-row .group { margin: 0; flex: 1; min-width: 140px; }

/* ── EXPORT ROW ── */
.export-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.export-row h3 { font-size: 1rem; font-weight: 600; }
.export-row p  { font-size: 0.82rem; color: var(--sub); margin-top: 4px; }

/* ── COMENTÁRIO ── */
.comentario {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 10px;
    background: var(--bg);
}
.comentario-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.comentario-header strong { font-size: 0.85rem; }
.comentario-header small  { font-size: 0.72rem; color: var(--sub); }
.comentario p { font-size: 0.85rem; color: var(--text); }

/* ── FORM SECTION TITLE ── */
.form-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.form-section-title i { color: var(--primary); }

/* ── SIDEBAR LOGO FALLBACK ── */
.sidebar-brand {
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── MOBILE HAMBURGER ── */
@media (max-width: 768px) {
    :root { --sidebar-w: 260px; }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .main-container { margin-left: 0; }

    .menu-toggle { display: flex; }

    .content-area { padding: 20px 16px; }

    header { padding: 0 16px; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .grid-2, .grid-3 { grid-template-columns: 1fr; }

    .header-row { flex-direction: column; align-items: flex-start; }

    .export-row { flex-direction: column; }
    .export-row .btn-group { width: 100%; }
    .export-row .btn { flex: 1; justify-content: center; }

    .filtros-row { flex-direction: column; gap: 12px; }
    .filtros-row .group { width: 100%; }

    table { font-size: 0.82rem; }
    th, td { padding: 10px 12px; }

    .btn-group { flex-wrap: nowrap; overflow-x: auto; }

    .modal-box { padding: 24px 20px; }

    .auth-card { padding: 32px 24px; }

    #user-name, #user-role { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 14px; gap: 12px; }
    .stat-info h3 { font-size: 1.6rem; }
    .stat-icon { width: 40px; height: 40px; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    :root { --sidebar-w: 220px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .content-area { padding: 24px; }
}

/* ── LOADING STATE ── */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}
@keyframes shimmer { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

/* ── MERMAID ── */
#mermaid-container { overflow: auto; }
#mermaid-container svg { max-width: 100%; height: auto; }
/* ══════════════════════════════════════════════════════════════════════════
   DIAGRAMS ATTACH MODULE
   Adicionado ao fim do arquivo — maior especificidade sem alterar nada acima
   ══════════════════════════════════════════════════════════════════════════ */

/* ── DROPZONE ── */
.diagrams-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 36px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    background: var(--bg);
    position: relative;
    user-select: none;
}
.diagrams-dropzone:hover,
.diagrams-dropzone:focus,
.diagrams-dropzone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
    outline: none;
}
.diagrams-dz-icon {
    font-size: 2.2rem;
    color: var(--primary);
    opacity: .6;
    display: block;
    margin-bottom: 10px;
    pointer-events: none;
}
.diagrams-dz-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    pointer-events: none;
}
.diagrams-dz-hint {
    font-size: 0.78rem;
    color: var(--sub);
    pointer-events: none;
}
.diagrams-dz-hint code {
    margin: 0 2px;
}

/* ── LISTA DE ANEXOS ── */
.diagrams-list {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.diagrams-list-empty {
    color: var(--sub);
    font-size: 0.85rem;
    text-align: center;
    padding: 16px 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.diagrams-list-empty i { opacity: .4; font-size: 1rem; }

/* ── ITEM DE DIAGRAMA ── */
.diagram-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition);
    animation: fadeIn .2s ease;
}
.diagram-item:hover { box-shadow: var(--shadow-md); }

/* Ícone por tipo */
.diagram-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.diagram-item-icon.type-drawio { background: #fff7ed; color: #ea580c; }
.diagram-item-icon.type-svg    { background: #f0fdf4; color: #16a34a; }
.diagram-item-icon.type-image  { background: #eff6ff; color: var(--primary); }
.diagram-item-icon.type-pdf    { background: #fef2f2; color: var(--danger); }
.diagram-item-icon.type-xml    { background: #faf5ff; color: #7c3aed; }
.diagram-item-icon.type-other  { background: var(--bg); color: var(--sub); }

/* Metadados */
.diagram-item-meta {
    flex: 1;
    min-width: 0;
}
.diagram-item-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.diagram-item-size {
    font-size: 0.72rem;
    color: var(--sub);
    margin-top: 2px;
    font-family: 'JetBrains Mono', monospace;
}

/* Ações */
.diagram-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* Preview inline */
.diagram-preview-wrap {
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg);
    max-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.diagram-preview-wrap img,
.diagram-preview-wrap iframe {
    max-width: 100%;
    max-height: 320px;
    object-fit: contain;
    border: none;
}

/* ── RESPONSIVO ── */
@media (max-width: 768px) {
    .diagrams-dropzone { padding: 24px 16px; }
    .diagram-item { flex-wrap: wrap; gap: 10px; }
    .diagram-item-actions { width: 100%; justify-content: flex-end; }
}
/* /DIAGRAMS ATTACH MODULE */

/* ══════════════════════════════════════════════════════════════════════════
   PERFIL DRAWER MODULE
   ══════════════════════════════════════════════════════════════════════════ */

/* Botão avatar clicável */
.avatar-btn {
    cursor: pointer;
    border: 2px solid transparent;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    padding: 0;
}
.avatar-btn:hover {
    border-color: rgba(37,99,235,.35);
    box-shadow: 0 0 0 4px rgba(37,99,235,.12);
    transform: scale(1.06);
}
.avatar-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

/* Overlay escurecido */
.perfil-overlay {
    position: fixed;
    inset: 0;
    z-index: 290;
    background: rgba(15,23,42,.45);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}
.perfil-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Drawer lateral */
.perfil-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 300;
    width: 360px;
    max-width: 100vw;
    background: var(--white);
    box-shadow: -8px 0 32px rgba(15,23,42,.12);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.34,1.2,.64,1);
}
.perfil-drawer.open {
    transform: translateX(0);
}

/* Cabeçalho do drawer */
.perfil-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}
.perfil-drawer-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .95rem;
    font-weight: 700;
    color: var(--text);
}
.perfil-drawer-title i {
    color: var(--primary);
    font-size: 1rem;
}
.perfil-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--sub);
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    font-size: .9rem;
    transition: background var(--transition), color var(--transition);
}
.perfil-close-btn:hover {
    background: var(--border);
    color: var(--text);
}

/* Corpo do drawer */
.perfil-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Avatar grande + info */
.perfil-avatar-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.perfil-avatar-big {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 1.4rem;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(37,99,235,.25);
}
.perfil-avatar-name {
    font-weight: 700;
    font-size: .95rem;
    color: var(--text);
}
.perfil-avatar-role {
    font-size: .75rem;
    color: var(--sub);
    text-transform: capitalize;
    margin-top: 2px;
}

/* Divisor */
.perfil-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0 0 20px;
}

/* Label de secção interna */
.perfil-section-label {
    font-size: .78rem;
    font-weight: 700;
    color: var(--sub);
    text-transform: uppercase;
    letter-spacing: .06em;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}
.perfil-section-label i { color: var(--primary); }
.perfil-optional {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--sub);
    font-size: .72rem;
    margin-left: 4px;
    opacity: .75;
}

/* Mensagem de sucesso */
.msg-success {
    background: #ecfdf5;
    color: var(--success);
    border: 1px solid #a7f3d0;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: .82rem;
    margin-bottom: 12px;
    text-align: left;
}

/* Campo de password com botão de visibilidade */
.input-password-wrap {
    position: relative;
}
.input-password-wrap input {
    padding-right: 42px;
}
.toggle-pw-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sub);
    font-size: .85rem;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition);
}
.toggle-pw-btn:hover { color: var(--primary); }

/* Responsivo */
@media (max-width: 480px) {
    .perfil-drawer { width: 100vw; }
}

/* /PERFIL DRAWER MODULE */

/* ── PROFILE DROPDOWN ── */
.avatar-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.avatar-btn {
    cursor: pointer;
    user-select: none;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 500;
    min-width: 200px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.97);
    transform-origin: top right;
    transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease;
    pointer-events: none;
}

/* Tiny arrow pointing up */
.profile-dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 14px;
    width: 10px;
    height: 10px;
    background: var(--white);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    transform: rotate(45deg);
}

.profile-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.profile-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    text-align: left;
    white-space: nowrap;
}

.profile-dropdown-item i {
    width: 16px;
    text-align: center;
    color: var(--sub);
    font-size: 0.85rem;
    transition: color var(--transition);
}

.profile-dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.profile-dropdown-item:hover i {
    color: var(--primary);
}

.profile-dropdown-item--danger {
    color: var(--danger);
}

.profile-dropdown-item--danger i {
    color: var(--danger);
}

.profile-dropdown-item--danger:hover {
    background: #fef2f2;
    color: var(--danger);
}

.profile-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 6px;
}
/* /PROFILE DROPDOWN */

/* ══════════════════════════════════════════════════════════════════════════
   UML DIAGRAMS MODULE
   ══════════════════════════════════════════════════════════════════════════ */

/* Seletor de projeto */
.uml-project-selector {
    padding: 16px 24px;
    margin-bottom: 20px;
}
.uml-selector-row {
    display: flex;
    align-items: flex-end;
    gap: 14px;
}
.uml-selector-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-bottom: 0;
    align-self: flex-end;
}

/* Tabs de tipo de diagrama */
.uml-type-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.uml-tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    background: var(--white);
    color: var(--sub);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    flex: 1;
    justify-content: center;
    min-width: 140px;
    box-shadow: var(--shadow);
}
.uml-tab-btn i {
    font-size: 1rem;
    transition: transform var(--transition);
}
.uml-tab-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.uml-tab-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(37,99,235,.3);
    transform: translateY(-1px);
}
.uml-tab-btn.active i {
    transform: scale(1.1);
}

/* Card de upload */
.uml-upload-card {
    margin-bottom: 20px;
}
.uml-upload-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    flex-wrap: wrap;
}

/* Badge do tipo de diagrama */
.uml-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: var(--primary);
    color: #fff;
    transition: background var(--transition);
}
.uml-type-badge.badge-classe    { background: #7c3aed; }
.uml-type-badge.badge-sequencia { background: #0891b2; }

/* Dropzone */
.uml-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    transition: border-color var(--transition), background var(--transition);
    overflow: hidden;
}
.uml-dropzone.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}

.uml-dropzone-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 40px 24px;
    cursor: pointer;
    user-select: none;
    transition: background var(--transition);
}
.uml-dropzone-inner:hover {
    background: #f1f5f9;
}
.uml-dropzone-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: var(--primary-light);
    color: var(--primary);
    display: grid;
    place-items: center;
    font-size: 1.6rem;
    margin-bottom: 4px;
    transition: transform var(--transition);
}
.uml-dropzone-inner:hover .uml-dropzone-icon {
    transform: scale(1.08);
}
.uml-dropzone-text {
    font-size: 0.9rem;
    color: var(--text);
    font-weight: 500;
}
.uml-dropzone-text strong {
    color: var(--primary);
}
.uml-dropzone-hint {
    font-size: 0.75rem;
    color: var(--sub);
}

/* Preview de imagem selecionada */
.uml-preview-box {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    max-height: 340px;
    margin-bottom: 14px;
}
.uml-preview-box img {
    max-width: 100%;
    max-height: 340px;
    object-fit: contain;
    display: block;
}
.uml-preview-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.uml-preview-filename {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}
.uml-preview-size {
    font-size: 0.75rem;
    color: var(--sub);
    font-family: 'JetBrains Mono', monospace;
}

/* Galeria de diagramas */
.uml-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    min-height: 80px;
}

.uml-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--white);
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
    animation: fadeIn .25s ease;
    cursor: default;
}
.uml-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}
.uml-card-thumb {
    height: 160px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    cursor: zoom-in;
}
.uml-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform .3s ease;
}
.uml-card:hover .uml-card-thumb img {
    transform: scale(1.04);
}
.uml-card-body {
    padding: 10px 12px;
}
.uml-card-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}
.uml-card-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

/* Badge contador */
.uml-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 99px;
    background: var(--primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    margin-left: 4px;
    font-family: 'JetBrains Mono', monospace;
}

/* Responsivo */
@media (max-width: 768px) {
    .uml-type-tabs { gap: 8px; }
    .uml-tab-btn { padding: 10px 14px; font-size: 0.82rem; min-width: 110px; }
    .uml-gallery { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
    .uml-dropzone-inner { padding: 28px 16px; }
    .uml-selector-row { flex-direction: column; align-items: stretch; }
    .uml-selector-icon { display: none; }
    .uml-upload-header { flex-direction: column; align-items: flex-start; }
    .uml-preview-actions { flex-direction: column; align-items: flex-start; }
}

/* /UML DIAGRAMS MODULE */
