:root {
    --primary: #0f172a; /* Slate 900 */
    --secondary: #1e293b; /* Slate 800 */
    --accent: #3b82f6; /* Blue 500 */
    --accent-hover: #2563eb; /* Blue 600 */
    --bg-main: #f1f5f9; /* Slate 100 */
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --font-main: 'Montserrat', sans-serif;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; }
body { font-family: var(--font-main); background-color: var(--bg-main); color: var(--text-main); font-size: 14px; overflow: hidden; height: 100vh; }

/* LOGIN */
.login-container { display: flex; justify-content: center; align-items: center; height: 100vh; background-color: var(--primary); }
.login-card { background: var(--bg-card); padding: 40px; border-radius: 16px; width: 400px; box-shadow: var(--shadow-md); text-align: center; }
.login-header i { font-size: 40px; color: var(--accent); margin-bottom: 15px; }
.login-header h1 { font-weight: 700; color: var(--primary); font-size: 22px; margin-bottom: 5px; }
.login-header p { color: var(--text-muted); margin-bottom: 30px; font-size: 13px; }
.btn-login { background: var(--accent); color: white; border: none; padding: 12px; border-radius: 8px; font-weight: 600; cursor: pointer; width: 100%; transition: background 0.2s; margin-top: 20px; }
.btn-login:hover { background: var(--accent-hover); }

/* LAYOUT MAIN */
.dashboard-container { display: flex; height: 100vh; }

/* SIDEBAR & FOOTER APPSTACK */
.sidebar { width: 260px; background-color: var(--primary); color: white; display: flex; flex-direction: column; padding: 20px; flex-shrink: 0; }
.sidebar-header { display: flex; align-items: center; gap: 10px; margin-bottom: 40px; }
.sidebar-header i { font-size: 24px; color: var(--accent); }
.sidebar-header h2 { font-weight: 700; font-size: 18px; line-height: 1.2; }
.menu { list-style: none; flex-grow: 1; }
.menu li { padding: 12px 15px; border-radius: 8px; cursor: pointer; color: #94a3b8; transition: all 0.2s; display: flex; align-items: center; gap: 12px; margin-bottom: 5px; }
.menu li:hover { background-color: var(--secondary); color: white; }
.menu li.active { background-color: var(--accent); color: white; font-weight: 600; }
.sidebar-footer { border-top: 1px solid var(--secondary); padding-top: 20px; display: flex; flex-direction: column; gap: 15px; }
.btn-logout { background: none; border: 1px solid var(--secondary); color: #94a3b8; padding: 10px; border-radius: 8px; cursor: pointer; width: 100%; text-align: center; transition: all 0.2s; }
.btn-logout:hover { background-color: #ef444433; color: #ef4444; border-color: #ef4444; }

.app-footer { background: #0b1121; padding: 12px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: #64748b; border: 1px solid #1e293b; }
.app-footer strong { color: #e2e8f0; font-weight: 600; }
.version-badge { background: #3b82f633; color: #60a5fa; padding: 3px 6px; border-radius: 4px; font-weight: 700; font-size: 10px; letter-spacing: 0.5px; }

/* MAIN CONTENT */
.main-content { flex-grow: 1; padding: 30px; overflow-y: auto; background-color: var(--bg-main); }
.header-main { margin-bottom: 30px; }
.header-main h1 { font-weight: 700; font-size: 24px; color: var(--primary); }
.header-main p { color: var(--text-muted); }
.flex-header { display: flex; justify-content: space-between; align-items: center; }

/* BUSCADOR Y PAGINACIÓN EMPRESAS */
.search-input { padding: 10px 15px; border: 1px solid var(--border); border-radius: 8px; font-family: var(--font-main); outline: none; transition: border-color 0.2s; width: 280px; font-size: 13px; }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #3b82f61a; }
.pagination-controls { display: flex; justify-content: center; gap: 8px; padding: 15px 0; margin-top: 10px; }
.btn-page { background: var(--bg-card); border: 1px solid var(--border); padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--text-main); font-weight: 600; transition: all 0.2s; }
.btn-page:hover { border-color: var(--accent); color: var(--accent); }
.btn-page.active { background: var(--accent); color: white; border-color: var(--accent); }

/* STATS GRID */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 30px; }
.stat-card { background: var(--bg-card); padding: 20px; border-radius: 12px; display: flex; align-items: center; gap: 15px; box-shadow: var(--shadow-sm); border: 1px solid #e2e8f000; transition: border-color 0.2s; }
.stat-card:hover { border-color: var(--accent); }
.stat-card i { font-size: 28px; background: #3b82f61a; padding: 12px; border-radius: 12px; }
.stat-card .icon-emp { color: var(--accent); }
.stat-card .icon-op { color: var(--warning); background: #f59e0b1a; }
.stat-card .icon-dev { color: var(--success); background: #10b9811a; }
.stat-info h3 { font-size: 24px; font-weight: 700; color: var(--primary); }
.stat-info p { color: var(--text-muted); margin-top: -2px; }

/* TABLAS */
.table-container { background: var(--bg-card); border-radius: 12px; box-shadow: var(--shadow-sm); overflow: hidden; padding: 5px; }
.admin-table { width: 100%; border-collapse: collapse; text-align: left; }
.admin-table thead { background-color: #f8fafc; }
.admin-table th { padding: 15px; color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 15px; border-bottom: 1px solid var(--border); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background-color: #f8fafc; }
.admin-table strong { color: var(--primary); font-weight: 600; }

/* BADGES */
.badge { display: inline-block; padding: 4px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; background-color: #f1f5f9; color: #475569; }
.badge.activo { background-color: #10b9811a; color: #10b981; }
.badge.offline { background-color: #ef44441a; color: #ef4444; }
.badge.suspendido { background-color: #f59e0b1a; color: #f59e0b; }
.badge.en-instalacion { background-color: #3b82f61a; color: #3b82f6; } /* Nuevo color para En Instalación */

/* BOTONES */
.btn-main { background-color: var(--accent); color: white; border: none; padding: 10px 18px; border-radius: 8px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: background 0.2s; }
.btn-main:hover { background-color: var(--accent-hover); }
.btn-sec { background-color: white; color: var(--primary); border: 1px solid #cbd5e1; padding: 10px 18px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-sec:hover { background-color: #f1f5f9; border-color: #94a3b8; }
.btn-action { background: none; border: none; font-size: 16px; padding: 6px; cursor: pointer; border-radius: 6px; transition: all 0.2s; }
.btn-config { color: var(--accent); }
.btn-config:hover { background-color: #3b82f61a; }
.btn-edit { color: var(--text-muted); }
.btn-edit:hover { background-color: #e2e8f0; color: var(--primary); }
.btn-kill { color: var(--danger); }
.btn-kill:hover { background-color: #ef44441a; }

/* MODALES */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #00000080; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: all 0.2s; z-index: 1000; }
.modal.active { opacity: 1; visibility: visible; }
.modal-content { background: var(--bg-card); border-radius: 16px; width: 500px; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-md); transform: scale(0.9); transition: transform 0.2s; }
.modal.active .modal-content { transform: scale(1); }
.large-modal { width: 750px; }
.modal-header { padding: 15px 25px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-weight: 700; font-size: 18px; color: var(--primary); }
.btn-close-modal { background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; }
.btn-close-modal:hover { color: var(--danger); }
.modal-body { padding: 25px; overflow-y: auto; }
.modal-footer { padding: 15px 25px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; background-color: #f8fafc; }

/* FORMULARIOS */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-weight: 500; color: var(--text-main); margin-bottom: 6px; font-size: 13px; }
.form-group input, .form-group select { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-family: var(--font-main); transition: border-color 0.2s; }
.form-group input:focus, .form-group select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #3b82f61a; }
.form-group small { color: var(--text-muted); font-size: 11px; margin-top: 4px; display: block; }
.form-group input:disabled, .form-group select:disabled { background-color: #f1f5f9; cursor: not-allowed; color: #475569; border-color: transparent; font-weight: 500;}

.form-group-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-section-title { font-weight: 600; color: var(--primary); margin: 20px 0 10px 0; padding-bottom: 5px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.form-section-title:first-child { margin-top: 0; }
.form-section-title i { color: var(--accent); }

.hw-assign-section { background: #f8fafc; border: 1px solid #e2e8f0; padding: 15px; border-radius: 12px; margin-bottom: 20px; }

/* CHECK LIST OPERADORES */
.check-list { border: 1px solid var(--border); border-radius: 8px; padding: 10px; max-height: 150px; overflow-y: auto; background-color: #f8fafc; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.check-item input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* HUÉRFANOS TARJETAS */
.huerfanos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.huerfanos-panel { background: var(--bg-card); padding: 20px; border-radius: 12px; box-shadow: var(--shadow-sm); }
.huerfanos-panel h3 { margin-bottom: 15px; font-weight: 600; color: var(--primary); font-size: 16px; }
.huerfanos-grid-mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 15px; }

.huerfano-card { background: #f8fafc; border: 1px solid var(--border); padding: 15px; border-radius: 10px; display: flex; align-items: center; gap: 12px; }
.huerfano-icon i { font-size: 20px; color: var(--text-muted); background: white; padding: 10px; border-radius: 50%; border: 1px solid var(--border); }
.huerfano-info h4 { font-weight: 600; color: var(--primary); font-size: 13px; margin-bottom: 2px;}
.huerfano-badges { display: flex; gap: 5px; margin-top: 4px; }
.badge-ready { color: var(--success); font-weight: 600; font-size: 11px; }
.empty-huerfanos { text-align: center; color: var(--text-muted); padding: 20px; grid-column: 1 / -1; }
.empty-huerfanos i { font-size: 30px; margin-bottom: 10px; opacity: 0.5; }

/* CONFIGURACIÓN HARDWARE */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.config-card { background: #ffffff; border: 1px solid var(--border); padding: 20px; border-radius: 12px; box-shadow: var(--shadow-sm);}
.config-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.config-card-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--primary); }
.btn-test { background: var(--secondary); color: white; border: none; padding: 8px; border-radius: 6px; width: 100%; font-weight: 600; cursor: pointer; transition: background 0.2s; margin-top: 10px; }
.btn-test:hover { background: #000; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--success); }
input:focus + .slider { box-shadow: 0 0 1px var(--success); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 24px; }
.slider.round:before { border-radius: 50%; }

.error-text { color: var(--danger); font-weight: 600; margin-top: 10px; font-size: 12px; }
/* === NUEVAS CAJITAS DASHBOARD INSTALACIONES === */
.dashboard-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
.panel { background: var(--bg-card); padding: 20px; border-radius: 12px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.panel h3 { font-size: 16px; color: var(--primary); margin-bottom: 15px; display: flex; align-items: center; gap: 8px; font-weight: 700;}
.panel h3 i { color: var(--accent); }

.inst-grid { display: flex; flex-direction: column; gap: 12px; }
.inst-card { background: #f8fafc; border: 1px solid var(--border); padding: 15px; border-radius: 10px; transition: 0.2s; }
.inst-card:hover { border-color: var(--accent); }
.inst-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.inst-card-title { font-weight: 700; color: var(--primary); font-size: 14px; }
.inst-card-subtitle { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; margin-top: 6px; }

.inst-empty { text-align: center; padding: 30px 20px; color: var(--text-muted); font-size: 13px; font-style: italic; background: #f8fafc; border-radius: 10px; border: 1px dashed var(--border);}