:root {
  --bg: #f0f2f5;
  --sidebar-bg: #1a1a2e;
  --sidebar-text: #c0c0d0;
  --sidebar-active: #16213e;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #16a34a;
  --warning: #ca8a04;
  --card-bg: #fff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* Layout */
.app-layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 240px; background: var(--sidebar-bg); color: var(--sidebar-text); flex-shrink: 0; padding-top: 8px; }
.main-content { flex: 1; padding: 24px; overflow-y: auto; }

/* Navbar */
.navbar { height: 56px; background: var(--card-bg); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; box-shadow: var(--shadow); }
.navbar-brand { font-size: 18px; font-weight: 700; color: var(--primary); }
.navbar-right { display: flex; align-items: center; gap: 16px; }
.navbar-user { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.navbar-role { font-size: 11px; color: var(--text-muted); }

/* Sidebar */
.sidebar-title { padding: 12px 20px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #666; margin-top: 8px; }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: var(--sidebar-text); text-decoration: none; font-size: 14px; transition: background .15s; }
.sidebar a:hover { background: rgba(255,255,255,.05); }
.sidebar a.active { background: var(--sidebar-active); color: #fff; border-left: 3px solid var(--primary); }
.sidebar a i { width: 18px; text-align: center; }
.sidebar .badge { background: var(--primary); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 10px; margin-left: auto; }

/* Cards */
.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h2, .card-header h3 { font-size: 18px; font-weight: 600; }
.card-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--card-bg); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 700; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; font-size: 14px; font-weight: 500; border: none; cursor: pointer; transition: background .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text-muted); }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; transition: border-color .15s; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.input-icon input { padding-left: 36px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 12px; border-bottom: 2px solid var(--border); color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: #f9fafb; }
.table .actions { display: flex; gap: 6px; }

/* Tags */
.tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.tag-active { background: #dcfce7; color: #166534; }
.tag-suspended { background: #fee2e2; color: #991b1b; }
.tag-admin { background: #dbeafe; color: #1e40af; }
.tag-user { background: #f3f4f6; color: #374151; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-overlay.hidden { display: none; }
.modal-box { background: var(--card-bg); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; width: 90%; max-width: 900px; }
.modal-sm { max-width: 480px !important; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Login page */
.login-page-body { background: linear-gradient(135deg, #1a1a2e, #16213e); }
#login-overlay { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--card-bg); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 40px; width: 400px; max-width: 90vw; }
.login-card h1 { text-align: center; margin-bottom: 8px; font-size: 24px; }
.login-card p { text-align: center; color: var(--text-muted); margin-bottom: 24px; font-size: 14px; }
.login-error { background: #fee2e2; color: #991b1b; padding: 10px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }

/* Messages / Buzon */
.buzon-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; transition: box-shadow .15s; }
.buzon-item:hover { box-shadow: var(--shadow); }
.buzon-asunto { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.buzon-meta { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.buzon-files { display: flex; gap: 8px; flex-wrap: wrap; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--bg); border-radius: 6px; font-size: 12px; }
.file-chip a { color: var(--primary); text-decoration: none; }
.file-chip a:hover { text-decoration: underline; }
.file-constancia { border-left: 3px solid #60a5fa; }
.file-documento { border-left: 3px solid #f97316; }

/* Search */
.search-box { position: relative; margin-bottom: 16px; }
.search-box input { padding: 8px 12px 8px 36px; width: 100%; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.filter-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-row select { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert-info { background: #dbeafe; color: #1e40af; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

/* Loading */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { text-align: center; padding: 40px; color: var(--text-muted); }

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
