/* ============================================================
   CoreDesk — Main Stylesheet
   Design: Professional dark sidebar + clean content area
   ============================================================ */

:root {
  --color-primary:       #1e3a5f;
  --color-secondary:     #2563eb;
  --color-accent:        #3b82f6;
  --color-sidebar-bg:    #0f2440;
  --color-sidebar-text:  #c8d8ee;
  --color-sidebar-hover: rgba(59,130,246,0.15);
  --color-sidebar-active:#2563eb;
  --color-bg:            #f1f5fb;
  --color-white:         #ffffff;
  --color-border:        #dde3ef;
  --color-text:          #1e293b;
  --color-text-muted:    #64748b;
  --color-danger:        #dc2626;
  --color-success:       #16a34a;
  --color-warning:       #d97706;
  --color-info:          #0891b2;
  --sidebar-width:       260px;
  --header-height:       60px;
  --radius:              8px;
  --shadow-sm:           0 1px 3px rgba(0,0,0,.08);
  --shadow-md:           0 4px 12px rgba(0,0,0,.1);
  --shadow-lg:           0 8px 24px rgba(0,0,0,.14);
  --font-body:           'Segoe UI', system-ui, sans-serif;
  --font-mono:           'Consolas', 'Courier New', monospace;
  --transition:          .18s ease;
}

/* ── RESET ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body { font-family: var(--font-body); background: var(--color-bg);
       color: var(--color-text); min-height: 100vh; overflow-x: hidden; }
a { color: var(--color-secondary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── LOGIN ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-primary) 0%, #0a1628 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
.login-card {
  background: var(--color-white);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo img { max-height: 70px; }
.login-logo h1 { font-size: 1.6rem; color: var(--color-primary); font-weight: 700; margin-top: .5rem; }
.login-logo p  { color: var(--color-text-muted); font-size: .9rem; }
.login-card .form-group { margin-bottom: 1.1rem; }
.login-card label { display: block; font-size: .82rem; font-weight: 600;
                    color: var(--color-text-muted); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.login-card input { width: 100%; padding: .7rem 1rem; border: 1.5px solid var(--color-border);
                    border-radius: var(--radius); font-size: .95rem; transition: border-color var(--transition); }
.login-card input:focus { outline: none; border-color: var(--color-secondary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.login-card .btn-login { width: 100%; padding: .8rem; background: var(--color-secondary);
                          color: #fff; border: none; border-radius: var(--radius);
                          font-size: 1rem; font-weight: 600; cursor: pointer;
                          transition: background var(--transition), transform .1s; margin-top: .5rem; }
.login-card .btn-login:hover   { background: #1d4ed8; }
.login-card .btn-login:active  { transform: translateY(1px); }
.alert { padding: .7rem 1rem; border-radius: var(--radius); font-size: .88rem; margin-bottom: 1rem; }
.alert-danger  { background: #fef2f2; color: var(--color-danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--color-success); border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: var(--color-warning); border: 1px solid #fde68a; }
.alert-info    { background: #ecfeff; color: var(--color-info);    border: 1px solid #a5f3fc; }

/* ── LAYOUT ─────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto; overflow-x: hidden;
}
.sidebar-header {
  padding: 1.2rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: .75rem;
}
.sidebar-logo img { height: 36px; }
.sidebar-logo-text { font-size: 1.15rem; font-weight: 700; color: #fff; letter-spacing: -.01em; }
.sidebar-logo-sub  { font-size: .72rem; color: var(--color-sidebar-text); opacity: .65; }

.sidebar-nav { flex: 1; padding: .75rem 0; }
.nav-section-title {
  font-size: .68rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: rgba(200,216,238,.4);
  padding: .9rem 1.25rem .35rem;
}
.nav-item { display: flex; }
.nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1.25rem; width: 100%;
  color: var(--color-sidebar-text);
  border-radius: 0; font-size: .88rem;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.nav-link:hover { background: var(--color-sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active {
  background: var(--color-sidebar-active);
  color: #fff;
}
.nav-link.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: #93c5fd; border-radius: 0 2px 2px 0;
}
.nav-link .nav-icon { width: 18px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--color-danger);
  color: #fff; font-size: .7rem; padding: .1rem .45rem;
  border-radius: 999px; font-weight: 700; min-width: 20px; text-align: center;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: .8rem; color: rgba(200,216,238,.5);
}

/* MAIN CONTENT */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}

/* TOPBAR */
.topbar {
  height: var(--header-height);
  background: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-title { font-size: 1.05rem; font-weight: 600; color: var(--color-text); }
.breadcrumb { display: flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--color-text-muted); }
.breadcrumb a { color: var(--color-secondary); }
.breadcrumb-sep { color: var(--color-border); }

.topbar-right { display: flex; align-items: center; gap: 1rem; }
.user-menu { display: flex; align-items: center; gap: .6rem; cursor: pointer; position: relative; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--color-secondary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
}
.user-name { font-size: .85rem; font-weight: 500; }
.user-role { font-size: .75rem; color: var(--color-text-muted); }

/* PAGE CONTENT */
.page-content { padding: 1.75rem; flex: 1; }

/* CARDS */
.card {
  background: var(--color-white);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--color-text); }
.card-body { padding: 1.25rem; }

/* DASHBOARD STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--color-white);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: flex-start; gap: 1rem;
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon.blue    { background: #eff6ff; color: var(--color-secondary); }
.stat-icon.green   { background: #f0fdf4; color: var(--color-success); }
.stat-icon.orange  { background: #fffbeb; color: var(--color-warning); }
.stat-icon.red     { background: #fef2f2; color: var(--color-danger); }
.stat-icon.purple  { background: #faf5ff; color: #7c3aed; }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; color: var(--color-text); }
.stat-label { font-size: .8rem; color: var(--color-text-muted); margin-top: .2rem; }

/* TABLES */
.table-wrapper { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table thead th {
  background: #f8fafd; text-align: left;
  padding: .7rem 1rem; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--color-text-muted); border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid var(--color-border); transition: background var(--transition); }
.data-table tbody tr:hover { background: #f8fafd; }
.data-table tbody td { padding: .65rem 1rem; vertical-align: middle; }
.data-table tbody tr:last-child { border-bottom: none; }

/* BADGES */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600;
}
.badge-blue    { background: #eff6ff; color: #1d4ed8; }
.badge-green   { background: #f0fdf4; color: #15803d; }
.badge-orange  { background: #fffbeb; color: #b45309; }
.badge-red     { background: #fef2f2; color: #b91c1c; }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-purple  { background: #faf5ff; color: #6d28d9; }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem 1rem; border-radius: var(--radius);
  font-size: .88rem; font-weight: 500; cursor: pointer;
  border: 1.5px solid transparent; transition: all var(--transition);
  white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .9; }
.btn:active { transform: translateY(1px); }
.btn-primary   { background: var(--color-secondary); color: #fff; border-color: var(--color-secondary); }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-secondary { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-danger    { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-success   { background: var(--color-success); color: #fff; border-color: var(--color-success); }
.btn-warning   { background: var(--color-warning); color: #fff; border-color: var(--color-warning); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-xs { padding: .2rem .5rem; font-size: .75rem; }
.btn-icon { padding: .5rem; }

/* FORMS */
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: .82rem; font-weight: 600;
                    color: var(--color-text-muted); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.form-group label .required { color: var(--color-danger); margin-left: .2rem; }
.form-control {
  width: 100%; padding: .6rem .9rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius); font-size: .9rem;
  background: var(--color-white); color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: var(--font-body);
}
.form-control:focus { outline: none; border-color: var(--color-secondary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.form-control.is-invalid { border-color: var(--color-danger); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-text { font-size: .78rem; color: var(--color-text-muted); margin-top: .3rem; }
.invalid-feedback { font-size: .78rem; color: var(--color-danger); margin-top: .25rem; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.form-section-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
                       color: var(--color-text-muted); border-bottom: 1px solid var(--color-border);
                       padding-bottom: .5rem; margin-bottom: 1rem; margin-top: 1.5rem; }
.form-actions { display: flex; gap: .75rem; align-items: center; padding-top: 1rem; border-top: 1px solid var(--color-border); margin-top: 1rem; }

/* SEARCH BAR */
.search-bar { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap .search-icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); pointer-events: none; }
.search-input-wrap input { padding-left: 2.2rem; }

/* PAGINATION */
.pagination { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 .4rem;
  border-radius: var(--radius); font-size: .85rem; border: 1px solid var(--color-border);
}
.pagination a { color: var(--color-text); transition: all var(--transition); }
.pagination a:hover { background: #f1f5f9; text-decoration: none; }
.pagination .active { background: var(--color-secondary); color: #fff; border-color: var(--color-secondary); }
.pagination .disabled { color: var(--color-text-muted); cursor: default; opacity: .5; }

/* PASSWORD FIELD */
.password-field { position: relative; }
.password-field input { padding-right: 2.5rem; font-family: var(--font-mono); }
.password-toggle { position: absolute; right: .65rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--color-text-muted); padding: .2rem; }

/* RESOURCE TYPE ICONS */
.tipo-credencial { color: #1d4ed8; }
.tipo-smb        { color: #15803d; }
.tipo-ssh        { color: #7c3aed; }
.tipo-rdp        { color: #b45309; }
.tipo-ftp        { color: #0891b2; }
.tipo-api        { color: #dc2626; }
.tipo-web        { color: #0369a1; }
.tipo-otro       { color: #64748b; }

/* DETAIL VIEW */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.25rem; }
.detail-item { }
.detail-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--color-text-muted); margin-bottom: .3rem; }
.detail-value { font-size: .95rem; color: var(--color-text); }
.detail-value.mono { font-family: var(--font-mono); background: #f8fafd; padding: .3rem .6rem; border-radius: 4px; border: 1px solid var(--color-border); display: inline-block; }

/* TABS */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--color-border); margin-bottom: 1.25rem; }
.tab-btn { padding: .65rem 1.2rem; font-size: .88rem; font-weight: 500; cursor: pointer; border: none; background: none; color: var(--color-text-muted); transition: all var(--transition); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab-btn:hover { color: var(--color-secondary); }
.tab-btn.active { color: var(--color-secondary); border-bottom-color: var(--color-secondary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--color-text-muted); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }
.empty-state p { font-size: .95rem; }

/* MOBILE SIDEBAR TOGGLE */
.sidebar-toggle { display: none; background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--color-text); padding: .25rem; }

/* MODAL */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--color-white); border-radius: 12px; width: 100%; max-width: 480px; box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-header { padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--color-border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-weight: 600; font-size: 1rem; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--color-text-muted); padding: .2rem .4rem; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: .75rem; }

/* AUDIT TABLE */
.audit-accion { font-size: .78rem; font-family: var(--font-mono); padding: .15rem .45rem; border-radius: 3px; background: #f1f5f9; }

/* RESPONSIVE */

/* ── RICH EDITOR ────────────────────────────────────────── */
.rich-editor { border:1.5px solid var(--color-border); border-radius:var(--radius); overflow:hidden; }
.rich-editor:focus-within { border-color:var(--color-secondary); box-shadow:0 0 0 3px rgba(37,99,235,.12); }
.re-toolbar { display:flex; align-items:center; gap:2px; padding:6px 8px; background:#f8fafd; border-bottom:1px solid var(--color-border); flex-wrap:wrap; }
.re-toolbar button { background:none; border:1px solid transparent; border-radius:4px; cursor:pointer; padding:3px 7px; font-size:.85rem; color:var(--color-text); min-width:28px; }
.re-toolbar button:hover { background:var(--color-border); border-color:var(--color-border); }
.re-toolbar select { border:1px solid var(--color-border); border-radius:4px; padding:3px 6px; font-size:.82rem; background:#fff; cursor:pointer; }
.re-sep { width:1px; height:20px; background:var(--color-border); margin:0 4px; }
.re-body { min-height:120px; max-height:400px; overflow-y:auto; padding:10px 12px; outline:none; font-size:.9rem; line-height:1.6; }
.re-body ul, .re-body ol { padding-left:1.5rem; }

/* ═══════════════════════════════════════════════════════════
   MODO OSCURO
   Se activa con: <html data-theme="dark">
   También respeta prefers-color-scheme si tema = "auto"
═══════════════════════════════════════════════════════════ */

/* Variables del tema oscuro */
[data-theme="dark"] {
  --color-primary:       #3b82f6;
  --color-secondary:     #60a5fa;
  --color-accent:        #93c5fd;
  --color-sidebar-bg:    #0f1f3d;
  --color-sidebar-text:  #cbd5e1;
  --color-sidebar-hover: rgba(96,165,250,0.15);
  --color-sidebar-active:#3b82f6;
  --color-bg:            #0f172a;
  --color-white:         #1e293b;
  --color-surface:       #1e293b;
  --color-border:        #334155;
  --color-text:          #e2e8f0;
  --color-text-muted:    #94a3b8;
  --color-danger:        #f87171;
  --color-success:       #4ade80;
  --color-warning:       #fbbf24;
  --color-info:          #38bdf8;
}

/* Si el sistema es oscuro y tema = auto (no tiene data-theme explícito) */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) {
    --color-primary:       #3b82f6;
    --color-secondary:     #60a5fa;
    --color-accent:        #93c5fd;
    --color-sidebar-bg:    #0f1f3d;
    --color-sidebar-text:  #cbd5e1;
    --color-sidebar-hover: rgba(96,165,250,0.15);
    --color-sidebar-active:#3b82f6;
    --color-bg:            #0f172a;
    --color-white:         #1e293b;
    --color-surface:       #1e293b;
    --color-border:        #334155;
    --color-text:          #e2e8f0;
    --color-text-muted:    #94a3b8;
    --color-danger:        #f87171;
    --color-success:       #4ade80;
    --color-warning:       #fbbf24;
    --color-info:          #38bdf8;
  }
}

/* Reglas de componentes en modo oscuro */
[data-theme="dark"] body,
@media (prefers-color-scheme: dark) { html:not([data-theme="light"]) body {
  background: var(--color-bg);
  color: var(--color-text);
}}

[data-theme="dark"] .card { background: var(--color-white); border-color: var(--color-border); }
[data-theme="dark"] .card-header { background: var(--color-white); border-color: var(--color-border); }
[data-theme="dark"] .form-control {
  background: #0f172a;
  color: var(--color-text);
  border-color: var(--color-border);
}
[data-theme="dark"] .form-control::placeholder { color: var(--color-text-muted); }
[data-theme="dark"] .form-control:focus { border-color: var(--color-secondary); }
[data-theme="dark"] .data-table th { background: #0f172a; color: var(--color-text); border-color: var(--color-border); }
[data-theme="dark"] .data-table td { color: var(--color-text); border-color: #1e293b; }
[data-theme="dark"] .data-table tr:hover td { background: #1e293b; }
[data-theme="dark"] .stat-card { background: var(--color-white); border-color: var(--color-border); }
[data-theme="dark"] .stat-value { color: var(--color-text); }
[data-theme="dark"] .stat-label { color: var(--color-text-muted); }
[data-theme="dark"] .modal { background: #1e293b; border-color: var(--color-border); }
[data-theme="dark"] .modal-header { background: #0f172a; border-color: var(--color-border); }
[data-theme="dark"] .btn-secondary { background: #334155; color: var(--color-text); border-color: var(--color-border); }
[data-theme="dark"] .btn-secondary:hover { background: #475569; }
[data-theme="dark"] .topbar { background: #0f172a; border-color: var(--color-border); }
[data-theme="dark"] .page-content { background: var(--color-bg); }
[data-theme="dark"] .alert-info    { background: #1e3a5f; color: #93c5fd; border-color: #1d4ed8; }
[data-theme="dark"] .alert-success { background: #14532d; color: #86efac; border-color: #166534; }
[data-theme="dark"] .alert-warning { background: #451a03; color: #fde68a; border-color: #92400e; }
[data-theme="dark"] .alert-danger  { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .badge-gray    { background: #334155; color: #cbd5e1; border-color: #475569; }
[data-theme="dark"] .re-toolbar    { background: #0f172a; border-color: var(--color-border); }
[data-theme="dark"] .re-toolbar button { color: var(--color-text); }
[data-theme="dark"] .re-body       { background: #1e293b; color: var(--color-text); }
[data-theme="dark"] select option  { background: #1e293b; color: var(--color-text); }
[data-theme="dark"] .tab-btn       { color: var(--color-text-muted); border-color: var(--color-border); }
[data-theme="dark"] .tab-btn.active { color: var(--color-secondary); border-color: var(--color-secondary); }
[data-theme="dark"] .detail-label  { color: var(--color-text-muted); }
[data-theme="dark"] .detail-value  { color: var(--color-text); }
[data-theme="dark"] .empty-state   { color: var(--color-text-muted); }
[data-theme="dark"] a              { color: var(--color-secondary); }
[data-theme="dark"] .nav-link:hover { background: var(--color-sidebar-hover); }
[data-theme="dark"] .table-wrapper { background: var(--color-white); }
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] textarea { color-scheme: dark; }

/* ═══════════════════════════════════════════════════════════
   MEJORAS PWA / APP MÓVIL
   Navegación inferior, touch, safe areas, instalación
═══════════════════════════════════════════════════════════ */

/* Safe area para iPhone con notch/Dynamic Island */
:root {
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);
}

/* Evitar selección de texto en elementos de UI táctiles */
.sidebar, .nav-item, .btn, .badge, .card-header {
  -webkit-user-select: none;
  user-select: none;
}

/* Touch highlight más sutil */
* { -webkit-tap-highlight-color: rgba(37,99,235,.12); }

/* Barra de navegación inferior — solo en móvil */
.bottom-nav {
  display: none;
}


/* Tema oscuro para bottom nav */
[data-theme="dark"] .bottom-nav {
  background: var(--color-white);
  border-top-color: var(--color-border);
  box-shadow: 0 -2px 12px rgba(0,0,0,.3);
}

/* Animación de entrada de la app (modo standalone) */
@media (display-mode: standalone) {
  body {
    animation: fadeInApp .2s ease;
  }
  @keyframes fadeInApp {
    from { opacity: .7; }
    to   { opacity: 1; }
  }
}

/* ── HOVER CARDS (tooltip enriquecido) ───────────────────────────────────── */
/* Solo escritorio — en móvil no se muestran (media query) */
.hc-trigger { cursor: default; }

#hover-card-global {
  display: none;
  position: fixed;
  z-index: 9990;
  /* Valores hardcoded para garantizar estética sin depender de variables CSS */
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.08);
  padding: 1rem;
  width: 300px;
  font-size: .8rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  pointer-events: none;
  color: #1e293b;
  line-height: 1.5;
}
#hover-card-global .hc-title {
  font-weight: 800;
  font-size: .9rem;
  color: #0f172a;
  margin-bottom: .25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#hover-card-global .hc-sub {
  color: #64748b;
  font-size: .72rem;
  margin-bottom: .6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#hover-card-global .hc-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .2rem .75rem;
}
#hover-card-global .hc-label { color: #64748b; white-space: nowrap; font-size: .78rem; }
#hover-card-global .hc-value { font-weight: 600; color: #1e293b; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#hover-card-global .hc-divider {
  border: none; border-top: 1px solid #e2e8f0;
  margin: .6rem 0;
}
#hover-card-global .hc-badge {
  display: inline-block;
  padding: .1rem .45rem;
  border-radius: 10px;
  font-size: .7rem;
  font-weight: 700;
}
#hover-card-global .hc-warn { color: #ca8a04; }
#hover-card-global .hc-ok   { color: #16a34a; }
#hover-card-global .hc-err  { color: #dc2626; }
/* Clase activa — el JS añade/quita esta clase */
#hover-card-global.hc-visible {
  display: block !important;
}

/* En móvil/tablet: NUNCA mostrar hover cards */
@media (max-width: 768px) {
  #hover-card-global { display: none !important; }
  .hc-trigger { cursor: pointer; }
}
