/* ============================================ */
/* MARESTE SYSTEM - CONSOLIDATED STYLES        */
/* Versão: 1.0                                  */
/* ============================================ */

/* --- 1. VARIÁVEIS GLOBAIS --- */
:root {
    /* Cores principais */
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --success: #10b981;
    --warning: #f39c12;
    --danger: #ef4444;
    --info: #3498db;

    /* Gradiente Mareste — azul do logo */
    --grad-main: linear-gradient(135deg, #1a6fb5 0%, #1a9fd4 100%);
    --grad-main-hover: linear-gradient(135deg, #155e9e 0%, #1588b5 100%);

    /* Cores de fundo */
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-dark: #1a1a1a;
    --bg-card-dark: #2d2d2d;

    /* Cores de texto */
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-light: #ffffff;

    /* Bordas */
    --border-color: #e2e8f0;
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;
    --border-radius-xl: 16px;

    /* Espaçamentos */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.15);
}

/* --- 2. ESTRUTURA BASE --- */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
}

* {
    box-sizing: border-box;
}

/* Compensa o topbar fixo de 60px */
body {
    padding-top: 60px;
}

.app-body {
    display: flex;
    min-height: calc(100vh - 60px);
    width: 100%;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 60px);
    background-color: var(--bg-page);
}

.content-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-lg);
    width: 100%;
}

/* --- 3. HEADER / TOPBAR --- */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 0 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    z-index: 200;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.topbar img {
    height: 30px;
}

.topbar-brand {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.topbar-title {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.topbar-version {
    font-size: 0.6rem;
    color: var(--text-muted, #94a3b8);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.topbar span {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.avatar {
    background: var(--bg-hover);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: var(--text-secondary);
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* ── Dropdown de usuário no topbar ─────────────────────────── */
.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background .15s;
    user-select: none;
}
.topbar-user:hover,
.topbar-user.active { background: var(--bg-hover); }

.topbar-user-name { color: var(--text-secondary); font-weight: 600; font-size: 0.9rem; }
.topbar-user-arrow { color: var(--text-muted, #94a3b8); font-size: 10px; }

.topbar-user-menu {
    display: none;
    position: fixed;
    top: 60px;
    right: 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    min-width: 220px;
    z-index: 300;
    overflow: hidden;
}
.topbar-user-menu.open { display: block; }

.tum-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
}
.tum-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a6fb5, #1a9fd4);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.tum-name    { font-weight: 600; font-size: 13px; color: #1e293b; }
.tum-company { font-size: 11px; color: #94a3b8; margin-top: 1px; }

.tum-divider { height: 1px; background: #f1f5f9; margin: 0; }

.tum-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 13px;
    color: #374151;
    text-decoration: none;
    transition: background .12s;
}
.tum-item:hover { background: #f8fafc; }
.tum-item-danger { color: #dc2626; }
.tum-item-danger:hover { background: #fef2f2; }

/* --- 4. SIDEBAR --- */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    height: calc(100vh - 60px);
    position: sticky;
    top: 0;
    align-self: flex-start;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    text-decoration: none;
    color: #475569;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
    gap: 12px;
}

.nav-item:hover {
    background-color: var(--bg-hover);
    color: var(--primary);
}

.nav-item.active {
    background-color: #f0f9ff;
    color: var(--primary);
    border-left-color: var(--primary);
}

.nav-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-label {
    flex: 1;
}

/* Dropdown Navigation */
.nav-dropdown {
    position: relative;
}

.dropdown-trigger {
    cursor: pointer;
}

.dropdown-arrow {
    transition: transform 0.3s;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.nav-dropdown:has(.dropdown-menu.open) .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: var(--bg-hover);
    z-index: 1000;
}

.dropdown-menu.open {
    max-height: 400px;
    overflow-y: auto;
}

.dropdown-item {
    display: block;
    padding: 10px 20px 10px 52px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 4px solid transparent;
}

.dropdown-item:hover {
    background: rgba(14, 165, 233, 0.1);
    color: var(--primary);
    padding-left: 56px;
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 16px 20px;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #94a3b8;
    padding: 16px 16px 4px;
    user-select: none;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid var(--border-color);
}

.sidebar-footer .nav-item {
    color: var(--danger);
    justify-content: center;
    border-radius: var(--border-radius-md);
    border-left: none;
}

.sidebar-footer .nav-item:hover {
    background: #fee2e2;
    color: #b91c1c;
}

/* --- 5. TIPOGRAFIA --- */
h1 {
    font-size: 1.875rem;
    font-weight: 600;
    margin-top: 0;
    line-height: 1.5;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.5;
}

h3 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.5;
}

p, button, input, label {
    font-size: 1rem;
    line-height: 1.5;
}

.page-title {
    font-size: 2rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 10px;
}

.page-subtitle {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.section-title, .card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--bg-hover);
}

/* --- 6. CARDS --- */
.card, .report-card, .device-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 25px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 25px;
}

.card-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    font-weight: 700;
}

.card-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- 7. DASHBOARD --- */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stat-card.alert {
    border-left: 4px solid var(--warning);
}

.stat-card.success {
    border-left: 4px solid var(--success);
}

.stat-card.danger {
    border-left: 4px solid var(--danger);
}

/* --- 8. KPIs --- */
.kpi-grid, .kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.kpi-box {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.kpi-label, .kpi-lbl {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

.kpi-value, .kpi-val {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 5px;
}

/* --- 9. FORMS & FILTERS --- */
.filters-container, .report-filter-box {
    background: var(--bg-card);
    padding: 25px;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 20px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
    min-width: 180px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #cbd5e1;
    border-radius: var(--border-radius-md);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

/* --- 10. BOTÕES --- */

/* Botão principal — azul gradiente */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #1a6fb5 0%, #1a9fd4 100%);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(26,111,181,0.35);
}
.btn-primary:active  { transform: translateY(0); box-shadow: none; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Botão secundário — branco com borda */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: #374151;
    border: 1.5px solid #d1d5db;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-secondary:hover  { background: #f3f4f6; border-color: #9ca3af; }
.btn-secondary:active { background: #e5e7eb; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Botão de perigo — vermelho */
.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-danger:hover    { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(220,38,38,0.35); }
.btn-danger:active   { transform: translateY(0); box-shadow: none; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Modificadores de tamanho */
.btn-sm  { padding: 7px 14px !important; font-size: 13px !important; }
.btn-xs  { padding: 4px 10px !important; font-size: 12px !important; border-radius: 6px !important; }

/* ── Botões de ação em tabelas (padrão global de CRUDs) ──────────
   Usar sempre dentro de <div class="td-actions">
   ─────────────────────────────────────────────────────────────── */
.td-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
}

.btn-table-edit,
.btn-edit {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s;
}
.btn-table-edit:hover,
.btn-edit:hover { background: #e2e8f0; border-color: #cbd5e1; }

.btn-table-status,
.btn-deactivate {
    background: #fef9ec;
    color: #b45309;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.btn-table-status:hover,
.btn-deactivate:hover { background: #fef3c7; }

.btn-table-activate,
.btn-activate {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.btn-table-activate:hover,
.btn-activate:hover { background: #dcfce7; }

.btn-table-delete,
.btn-delete {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.btn-table-delete:hover,
.btn-delete:hover { background: #fee2e2; border-color: #f87171; }

.btn-generate, .btn-action {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    height: auto;
}

.btn-generate:hover, .btn-action:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.btn-generate:disabled, .btn-action:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.btn-sync {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--grad-main);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(26, 111, 181, 0.3);
}

.btn-sync:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(26, 111, 181, 0.4);
}

.btn-sync:active {
    transform: translateY(0);
}

.btn-sync:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-sync::before {
    content: "🔄";
    font-size: 1.2rem;
}

/* Botão pequeno para ações em tabelas */
.btn-action.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* --- 11. TABELAS --- */
.table-responsive {
    overflow-x: auto;
    background: var(--bg-card);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-hover);
    border-bottom: 2px solid var(--border-color);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

/* --- 12. REPORTS PAGE --- */
.reports-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px;
}

.chart-container, .chart-box {
    width: 100%;
    min-height: 300px;
    height: 350px;
    margin-top: 20px;
}

.chart-container canvas,
.chart-box canvas {
    max-width: 100%;
    height: auto !important;
    max-height: 250px;
}

.loading-state {
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
}

.loading-state p {
    font-size: 1.1rem;
    margin-top: 15px;
}

/* --- 13. ZABBIX PAGE --- */
.zabbix-page {
    padding: var(--spacing-lg);
    background: var(--bg-page);
    min-height: 100vh;
    color: var(--text-primary);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-xl);
    padding: var(--spacing-lg);
    background: var(--grad-main);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    color: white;
    flex-wrap: wrap;
    gap: var(--spacing-md);
}

.page-title {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
}

.page-icon {
    font-size: 3rem;
    margin-right: var(--spacing-md);
    flex-shrink: 0;
}

.page-title h1 {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    margin: 0;
    letter-spacing: 1px;
}

.page-title h2 {
    font-size: 1.2rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    margin: 0.5rem 0 0 0;
}

.page-coords {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.coord-item {
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.15);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--border-radius-md);
    backdrop-filter: blur(10px);
    min-width: 140px;
}

.coord-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.coord-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    margin-top: 0.25rem;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: var(--spacing-lg);
}

.device-section {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    min-width: 0;
}

.device-section:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.device-header {
    display: flex;
    align-items: center;
    padding: var(--spacing-md);
    background: var(--grad-main);
    color: white;
}

.device-icon {
    font-size: 1.8rem;
    margin-right: var(--spacing-sm);
}

.device-header h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
    color: white;
}

.device-subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
}

.device-body {
    padding: var(--spacing-lg);
    overflow: visible;
}

/* Tracking Status */
.tracking-status {
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.tracking-badge {
    display: inline-block;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--border-radius-xl);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.tracking-badge.tracking {
    background: var(--success);
    color: white;
}

.tracking-badge.not-tracking {
    background: var(--danger);
    color: white;
}

/* Satellite Info */
.sat-info {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}

.sat-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    padding: var(--spacing-sm);
    border-radius: var(--border-radius-md);
    display: inline-block;
}

/* Hex Grid */
.hex-grid {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.hex-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
}

.hex-item {
    background: rgba(0, 0, 0, 0.02);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md);
    text-align: center;
    transition: all 0.3s;
}

.hex-item:hover {
    background: rgba(14, 165, 233, 0.05);
    border-color: var(--primary);
    transform: scale(1.05);
}

.hex-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.hex-value, .kpi-val {
    word-break: break-word;
    overflow-wrap: break-word;
}

.modem-hex-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.modem-hex-grid .hex-item {
    background: linear-gradient(135deg, rgba(26, 111, 181, 0.1) 0%, rgba(26, 159, 212, 0.1) 100%);
}

/* Uptime */
.modem-uptime, .router-uptime {
    text-align: center;
    padding: var(--spacing-md);
    background: rgba(39, 174, 96, 0.1);
    border-radius: var(--border-radius-md);
    margin-bottom: var(--spacing-lg);
}

.uptime-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
}

.uptime-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    display: block;
}

/* Charts */
.modem-charts, .router-charts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
}

.chart-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chart-legend {
    text-align: center;
    font-size: 0.7rem;
    color: #999;
    margin-top: 8px;
    padding: 5px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Router Status */
.router-status-main {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--border-radius-md);
}

.ping-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.ping-icon {
    font-size: 2rem;
}

.ping-label {
    font-size: 1rem;
    color: var(--text-primary);
}

.ping-status.online .ping-label {
    color: var(--success);
}

.ping-status.offline .ping-label {
    color: var(--danger);
}

.latency-box {
    text-align: center;
    padding: var(--spacing-sm);
    background: rgba(33, 150, 243, 0.1);
    border-radius: var(--border-radius-md);
}

.latency-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--info);
}

.latency-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* --- 14. ALERTAS --- */
.alert {
    padding: var(--spacing-md);
    border-radius: var(--border-radius-md);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.alert-danger {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-info {
    background: rgba(52, 152, 219, 0.1);
    border: 1px solid var(--info);
    color: var(--info);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

/* --- 15. BADGES --- */
.badge {
    padding: 4px 8px;
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
}

.badge.success {
    background: #d4edda;
    color: #155724;
}

.badge.danger {
    background: #f8d7da;
    color: #721c24;
}

/* --- 16. UTILITÁRIOS --- */
.text-blue { color: var(--primary); }
.text-green { color: var(--success); }
.text-red { color: var(--danger); }
.text-orange { color: var(--warning); }

/* --- 17. SCROLLBAR --- */
.content-scroll-area::-webkit-scrollbar,
.dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.content-scroll-area::-webkit-scrollbar-track,
.dropdown-menu::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.content-scroll-area::-webkit-scrollbar-thumb,
.dropdown-menu::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.content-scroll-area::-webkit-scrollbar-thumb:hover,
.dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* --- 18. ANIMAÇÕES --- */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.tracking-badge.tracking {
    animation: pulse 2s infinite;
}

/* Lista de Eventos (Dashboard) */
.events-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.event-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    background: var(--bg-hover);
    border-left: 4px solid transparent;
}

.event-item.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: var(--danger);
}

.event-item.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: var(--success);
}

.event-item.alert-info {
    background: rgba(14, 165, 233, 0.1);
    border-left-color: var(--primary);
}

.event-time {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Animações para notificações */
@keyframes slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(400px); opacity: 0; }
}

/* --- 19. RESPONSIVO --- */
@media (max-width: 1400px) {
    .devices-grid { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .report-filter-box, .filters-container { grid-template-columns: 1fr 1fr; }
    .kpi-row, .kpi-grid { grid-template-columns: 1fr; }
    .modem-charts, .router-charts { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .page-header { flex-direction: column; text-align: center; }
    .page-coords { flex-direction: column; width: 100%; }
    .dashboard-cards, .stats-grid { grid-template-columns: 1fr; }
    .filters-container, .report-filter-box { grid-template-columns: 1fr; }
    .hex-row, .modem-hex-grid { grid-template-columns: repeat(2, 1fr); }
    .page-title { flex-direction: column; }
    .btn-sync { width: 100%; justify-content: center; }
}

/* =========================================================
   CORREÇÃO DO SCROLL DA SIDEBAR (Fim do Scroll Duplo)
   ========================================================= */

/* Liberta o menu de navios para empurrar os itens para baixo */
.sidebar .dropdown-menu.open,
.sidebar .dropdown-menu.show {
    max-height: none !important; 
    overflow-y: visible !important;
}

/* Garante que apenas a barra principal inteira tenha scroll */
.sidebar {
    height: calc(100vh - 60px) !important;
    overflow-y: auto !important;
}

/* --- 3º nível: Empresa (colapsável) --- */
.company-dropdown {
  border-top: 1px solid var(--border-color);
}

.dropdown-company-trigger{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 16px 10px 20px;
  font-weight:700;
  font-size:0.82rem;
  cursor:pointer;
  user-select:none;
  color: var(--text-secondary);
}

.dropdown-company-trigger:hover{
  background: rgba(0,0,0,0.04);
}

.company-arrow{
  transition: transform 0.2s ease;
  font-size: 0.75rem;
  opacity: .8;
}

.company-menu{
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.company-menu.open{
  max-height: 320px; /* ajusta depois */
  overflow-y: auto;
}

/* --- 4º nível: Navio (mais recuado) --- */
.dropdown-item.level-4{
  padding-left: 68px; /* mais recuo que o nível 2 */
}

/* --- Melhor max-height do dropdown geral (para evitar scroll no sidebar inteiro) --- */
.dropdown-menu.open,
.dropdown-menu.show{
  max-height: calc(100vh - 220px); /* deixa o menu respirar sem estourar */
  overflow-y: auto;
}

.company-menu {
  display: none;
}

.company-menu.open {
  display: block;
}

/* ============================================================
   20. UTILITY CLASSES
   ============================================================ */
.u-hidden         { display: none !important; }
.u-monospace      { font-family: monospace; font-size: 12px; }
.u-cursor-pointer { cursor: pointer; }
.u-text-center    { text-align: center; }
.u-overflow-x-auto { overflow-x: auto; }

/* ============================================================
   21. SHARED PAGE SECTION HEADER  (.section-header e .dev-header)
   ============================================================ */
.section-header,
.dev-header {
    background: linear-gradient(135deg, #1a6fb5 0%, #1a9fd4 100%);
    border-radius: 14px;
    padding: 22px 28px;
    color: #fff;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.section-header { justify-content: space-between; }

.section-header-left  { display: flex; align-items: center; gap: 16px; }
.section-header-icon,
.dev-header-icon      { font-size: 32px; line-height: 1; }
.section-header h1,
.dev-header h1        { font-size: 20px; font-weight: 700; margin: 0 0 2px; color: #fff; }
.section-header p,
.dev-header p         { font-size: 13px; opacity: 0.8; margin: 0; }

.btn-header-action {
    background: rgba(255,255,255,.2);
    color: #fff;
    border: 1.5px solid rgba(255,255,255,.4);
    border-radius: 9px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background .15s;
}
.btn-header-action:hover { background: rgba(255,255,255,.3); }

/* ============================================================
   22. SHARED MODAL OVERLAY
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}
.modal-overlay.active { display: flex; }

.modal-box {
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-head-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.modal-head-top h2 {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}
.modal-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.modal-close-btn:hover { color: #475569; }

/* ============================================================
   23. SHARED STAT STRIP
   ============================================================ */
.stat-strip       { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat-strip-item  {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 18px;
    text-align: center;
    min-width: 100px;
    flex: 1;
}
.stat-strip-value { font-size: 22px; font-weight: 700; color: #1e293b; }
.stat-strip-label { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* ============================================================
   24. SHARED FILTER BAR
   ============================================================ */
.filter-bar {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-bar input,
.filter-bar select {
    padding: 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    font-family: inherit;
    background: #fff;
    transition: border-color .2s;
}
.filter-bar input:focus,
.filter-bar select:focus { border-color: #1a6fb5; }
.filter-bar .filter-count {
    font-size: 13px;
    color: #94a3b8;
    margin-left: auto;
    white-space: nowrap;
}

/* ============================================================
   25. SHARED CRUD TABLE
   ============================================================ */
.crud-table-wrap {
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.05);
}
.crud-table          { width: 100%; border-collapse: collapse; font-size: 13px; }
.crud-table thead tr { background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.crud-table th {
    padding: 11px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}
.crud-table tbody tr       { border-bottom: 1px solid #f1f5f9; transition: background .15s; }
.crud-table tbody tr:hover { background: #f8fafc; }
.crud-table td             { padding: 12px 16px; vertical-align: middle; }

/* ============================================================
   26. LOADING CELL & SPINNER
   ============================================================ */
.loading-cell {
    text-align: center;
    padding: 3rem;
    color: #6b7280;
}
.loading-spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid #e2e8f0;
    border-top-color: #1a9fd4;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   27. KPI COLOR VARIANTS
   ============================================================ */
.kpi-green  { background: #dcfce7; color: #16a34a; }
.kpi-red    { background: #fef2f2; color: #dc2626; }
.kpi-yellow { background: #fef9c3; color: #ca8a04; }
.kpi-blue   { background: #dbeafe; color: #2563eb; }

/* ============================================================
   28. TOPBAR TICKETS BADGE
   ============================================================ */
.topbar-tickets-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,.15);
    border: 1.5px solid rgba(255,255,255,.3);
    border-radius: 9px;
    padding: 6px 12px;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
}
.topbar-tickets-badge {
    display: none;
    background: #ef4444;
    color: #fff;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

/* ============================================================
   29. FORM COMPONENTS (shared across CRUD pages)
   ============================================================ */
.form-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}
.form-row       { display: flex; gap: 12px; margin-bottom: 12px; }
.form-row > *   { flex: 1; }
.form-label     { display: block; font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 4px; }
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: #fff;
    transition: border-color .2s;
    box-sizing: border-box;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: #1a6fb5; }

/* ============================================================
   30. BADGE VARIANTS
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gray   { background: #f1f5f9; color: #475569; }

/* ============================================================
   31. ACTION BUTTONS (table row actions)
   ============================================================ */
.btn-action-sm {
    background: none;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    color: #64748b;
    transition: all .15s;
}
.btn-action-sm:hover { border-color: #1a6fb5; color: #1a6fb5; }
.btn-action-sm.danger:hover { border-color: #dc2626; color: #dc2626; }

/* ============================================================
   32. SUBMIT / SAVE BUTTON
   ============================================================ */
.btn-submit {
    background: linear-gradient(135deg, #1a6fb5, #0ea5e9);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity .15s;
}
.btn-submit:hover { opacity: 0.9; }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }