/* ═══════════════════════════════════════════
   SistemaPro — Estilos principales
   ═══════════════════════════════════════════ */
:root {
  --ink: #0D1117; --ink2: #1C2333; --ink3: #2D3748;
  --muted: #64748B; --muted2: #94A3B8;
  --border: #E2E8F0; --border2: rgba(0,0,0,0.06);
  --surface: #FFFFFF; --surface2: #F8FAFC; --surface3: #F1F5F9;
  --accent: #2563EB; --accent2: #1D4ED8; --accent3: #DBEAFE; --accent4: #EFF6FF;
  --green: #10B981; --green2: #D1FAE5;
  --red: #EF4444; --red2: #FEE2E2;
  --amber: #F59E0B; --amber2: #FEF3C7;
  --purple: #8B5CF6; --purple2: #EDE9FE;
  --sidebar-w: 240px; --header-h: 60px;
  --radius: 10px; --radius2: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow2: 0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06);
  --font-heading: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}
[data-theme="dark"] {
  --ink: #F1F5F9; --ink2: #E2E8F0; --ink3: #CBD5E1;
  --muted: #94A3B8; --muted2: #64748B;
  --border: #2D3748; --border2: rgba(255,255,255,0.06);
  --surface: #0F1923; --surface2: #161F2E; --surface3: #1E2A3B;
  --accent3: rgba(37,99,235,0.2); --accent4: rgba(37,99,235,0.1);
  --green2: rgba(16,185,129,0.15); --red2: rgba(239,68,68,0.15);
  --amber2: rgba(245,158,11,0.15); --purple2: rgba(139,92,246,0.15);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font-body); background: var(--surface2); color: var(--ink); min-height: 100vh; overflow: hidden; transition: background 0.2s, color 0.2s; }
.screen { display: none; width: 100%; height: 100vh; }
.screen.active { display: flex; }

/* LOGIN */
#loginScreen { align-items: center; justify-content: center; background: var(--surface2); position: relative; overflow: hidden; }
.login-bg { position: absolute; inset: 0; background: linear-gradient(135deg, #0D1117 0%, #1C2333 40%, #0F3460 100%); }
.login-bg::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 30% 50%, rgba(37,99,235,0.25) 0%, transparent 60%), radial-gradient(ellipse at 75% 20%, rgba(139,92,246,0.15) 0%, transparent 50%); }
.login-grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px); background-size: 40px 40px; }
.login-card { position: relative; z-index: 2; background: rgba(255,255,255,0.04); backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.1); border-radius: 20px; padding: 44px 48px; width: 440px; box-shadow: 0 24px 80px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08); animation: fadeUp 0.5s ease forwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.login-logo { width: 52px; height: 52px; background: var(--accent); border-radius: 14px; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--font-heading); font-size: 22px; font-weight: 800; margin-bottom: 20px; }
.login-card h1 { font-family: var(--font-heading); font-size: 26px; font-weight: 800; color: #fff; margin-bottom: 6px; }
.login-card > p { font-size: 14px; color: rgba(255,255,255,0.5); margin-bottom: 28px; }
.login-error { display: none; background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #FCA5A5; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 18px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,0.5); margin-bottom: 8px; }
.form-group input { width: 100%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; padding: 12px 14px; color: #fff; font-size: 14px; font-family: var(--font-body); transition: border-color 0.15s; }
.form-group input:focus { outline: none; border-color: var(--accent); background: rgba(37,99,235,0.1); }
.login-btn { width: 100%; background: var(--accent); color: #fff; border: none; border-radius: 10px; padding: 13px; font-size: 15px; font-weight: 600; font-family: var(--font-heading); cursor: pointer; margin-top: 8px; transition: background 0.15s, transform 0.1s; }
.login-btn:hover { background: var(--accent2); transform: translateY(-1px); }

/* APP LAYOUT */
#appScreen { flex-direction: row; }
.sidebar { width: var(--sidebar-w); min-height: 100vh; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; transition: background 0.2s; }
.sidebar-brand { height: var(--header-h); display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.brand-icon { width: 32px; height: 32px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--font-heading); font-size: 14px; font-weight: 800; }
.brand-name { font-family: var(--font-heading); font-size: 16px; font-weight: 700; color: var(--ink); }
.brand-name span { color: var(--accent); }
.sidebar-section { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted2); padding: 18px 18px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 14px; margin: 1px 8px; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--muted); transition: all 0.12s; user-select: none; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface3); color: var(--ink); }
.nav-item.active { background: var(--accent3); color: var(--accent); font-weight: 600; }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center; }
.nav-badge.green { background: var(--green); }
.sidebar-footer { border-top: 1px solid var(--border); padding: 12px; }
.user-pill { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface2); }
.user-avatar { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--muted); }
.logout-btn { background: none; border: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; display: flex; align-items: center; transition: color 0.12s; }
.logout-btn:hover { color: var(--red); }
.logout-btn svg { width: 16px; height: 16px; }
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0; }
.topbar-title { font-family: var(--font-heading); font-size: 16px; font-weight: 700; color: var(--ink); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: none; border: 1px solid var(--border); border-radius: 8px; width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); transition: all 0.12s; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 16px; height: 16px; }
.content-area { flex: 1; overflow-y: auto; padding: 24px; }
.view { display: none; }
.view.active { display: block; }
.page-header { margin-bottom: 20px; }
.page-header h2 { font-family: var(--font-heading); font-size: 22px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.page-header p { font-size: 13px; color: var(--muted); }
.toolbar-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted2); pointer-events: none; }
.search-input { width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--surface); color: var(--ink); font-family: var(--font-body); }
.search-input:focus { outline: none; border-color: var(--accent); }
.filter-select { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--surface); color: var(--ink); cursor: pointer; }

/* CARDS */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius2); overflow: hidden; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border2); }
.card-title { font-family: var(--font-heading); font-size: 14px; font-weight: 700; color: var(--ink); }
.card-body { padding: 20px; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius2); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.stat-card.green { border-left: 3px solid var(--green); }
.stat-card.amber { border-left: 3px solid var(--amber); }
.stat-card.purple { border-left: 3px solid var(--purple); }
.stat-icon { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.blue { background: var(--accent3); color: var(--accent); }
.stat-icon.green { background: var(--green2); color: var(--green); }
.stat-icon.amber { background: var(--amber2); color: var(--amber); }
.stat-icon.purple { background: var(--purple2); color: var(--purple); }
.stat-num { font-family: var(--font-heading); font-size: 28px; font-weight: 800; color: var(--ink); line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* TOOL CARDS */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tool-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius2); padding: 18px; cursor: pointer; transition: all 0.15s; position: relative; display: flex; flex-direction: column; gap: 10px; }
.tool-card:hover { border-color: var(--accent); box-shadow: 0 4px 20px rgba(37,99,235,0.1); transform: translateY(-1px); }
.tool-card-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--accent3); color: var(--accent); font-size: 20px; }
.tool-card-name { font-family: var(--font-heading); font-size: 14px; font-weight: 600; color: var(--ink); }
.tool-card-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }
.tool-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; flex-wrap: wrap; gap: 4px; }
.tool-card .corner-actions { position: absolute; top: 10px; right: 10px; display: none; gap: 4px; }
.tool-card:hover .corner-actions { display: flex; }

/* TOOL VIEWER */
#toolViewer { position: fixed; inset: 0; z-index: 50; background: var(--surface2); display: none; flex-direction: column; }
#toolViewer.open { display: flex; }
.viewer-topbar { height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 18px; flex-shrink: 0; }
.viewer-topbar .tool-title { font-family: var(--font-heading); font-size: 15px; font-weight: 600; color: var(--ink); }
.viewer-iframe { flex: 1; border: none; width: 100%; }

/* TABLE */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface2); }
th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
td { padding: 12px 16px; font-size: 13px; color: var(--ink); border-bottom: 1px solid var(--border2); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* BADGES */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-blue { background: var(--accent3); color: var(--accent); }
.badge-green { background: var(--green2); color: var(--green); }
.badge-red { background: var(--red2); color: var(--red); }
.badge-purple { background: var(--purple2); color: var(--purple); }
.badge-amber { background: var(--amber2); color: var(--amber); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; font-family: var(--font-body); transition: all 0.12s; white-space: nowrap; }
.btn svg { width: 14px; height: 14px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--surface2); color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface3); }
.btn-danger { background: var(--red2); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success { background: var(--green2); color: var(--green); }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-sm svg { width: 12px; height: 12px; }

/* MODALS */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius2); width: 480px; max-width: 95vw; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow2); animation: modalIn 0.2s ease; }
@keyframes modalIn { from { opacity:0; transform: scale(0.95) translateY(-10px); } to { opacity:1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-family: var(--font-heading); font-size: 16px; font-weight: 700; color: var(--ink); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--red); }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--surface); color: var(--ink); font-family: var(--font-body); }
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 80px; }

/* TOGGLE */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: var(--border); border-radius: 22px; transition: background 0.2s; }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle input:checked + .toggle-slider { background: var(--green); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* UPLOAD */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius2); padding: 40px 24px; text-align: center; cursor: pointer; transition: all 0.15s; background: var(--surface2); }
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: var(--accent4); }
.upload-zone svg { width: 40px; height: 40px; color: var(--muted2); margin-bottom: 12px; }
.upload-zone p { font-size: 14px; color: var(--muted); }
.upload-zone strong { color: var(--accent); }
.upload-zone input { display: none; }
.preview-iframe { width: 100%; height: 280px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface2); }

/* PERMISSIONS */
.perm-grid { display: flex; flex-direction: column; gap: 8px; }
.perm-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--surface2); border-radius: 8px; border: 1px solid var(--border2); }
.perm-name { font-size: 13px; color: var(--ink); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.perm-icon { width: 26px; height: 26px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 14px; background: var(--accent3); }

/* CHECKBOX PILL */
.checkbox-group { display: flex; gap: 8px; flex-wrap: wrap; }
.checkbox-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px; font-size: 12px; cursor: pointer; transition: all 0.12s; user-select: none; }
.checkbox-pill input { display: none; }
.checkbox-pill.checked { background: var(--accent3); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* AUDIT */
.audit-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border2); }
.audit-item:last-child { border-bottom: none; }
.audit-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.audit-dot.green { background: var(--green); }
.audit-dot.red { background: var(--red); }
.audit-dot.amber { background: var(--amber); }
.audit-text { font-size: 13px; color: var(--ink); line-height: 1.5; }
.audit-time { font-size: 11px; color: var(--muted2); margin-top: 2px; }

/* TOAST */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--ink2); color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow2); display: flex; align-items: center; gap: 10px; animation: toastIn 0.25s ease; max-width: 320px; pointer-events: auto; border-left: 3px solid var(--accent); }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
@keyframes toastIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* EMPTY STATE */
.empty-state { padding: 60px 20px; text-align: center; }
.empty-state svg { width: 48px; height: 48px; color: var(--muted2); margin-bottom: 12px; }
.empty-state p { font-size: 14px; color: var(--muted); }

/* SCROLLBAR */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

/* FOLDER HEADER */
.folder-header { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.folder-section { margin-bottom: 24px; }

@media (max-width: 700px) { .sidebar { width: 200px; } :root { --sidebar-w: 200px; } }

/* LOADING OVERLAY */
#loadingOverlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.35); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
.loading-spinner {
  background: var(--surface); border-radius: 16px; padding: 28px 36px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  box-shadow: var(--shadow2);
}
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; color: var(--muted); font-weight: 500; }
