/* Carlitrans Gestión — basado en el diseño de CRM Visitas (UIkit 3 + Inter) */
:root {
    --accent: #0f766e;
    --accent-dark: #115e59;
    --accent-soft: #e6f4f2;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --border: #e5e9f2;
    --text: #1f2937;
    --text-muted: #6b7280;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 20px rgba(15, 23, 42, .05);
    --sidebar-w: 240px;
}

html { overflow-x: hidden; }

body {
    background: var(--bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
}

a { color: var(--accent); }

/* ---------- Estructura: barra lateral fija + contenido ---------- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 10;
}

.app-sidebar-brand {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
}

.app-logo { max-width: 100%; height: auto; max-height: 64px; display: block; }

.app-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-sidebar-section-title {
    font-size: .7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    margin: 14px 12px 6px;
}

.app-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: var(--text-muted) !important;
    text-decoration: none !important;
    font-size: .92rem;
    font-weight: 600;
    transition: background .15s ease, color .15s ease;
}

.app-nav-link:hover { background: var(--accent-soft); color: var(--accent-dark) !important; }
.app-nav-link.active { background: var(--accent); color: #fff !important; }

.app-sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); }
.app-user { font-size: .85rem; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0; /* deja que la tabla haga scroll dentro, en vez de desbordar la página */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-topbar {
    padding: 18px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    gap: 16px;
    flex-wrap: wrap;
}

.app-topbar h1 { font-size: 1.35rem; margin: 0; font-weight: 800; }

.app-content { padding: 24px 32px; flex: 1; }

/* ---------- Pantalla de acceso ---------- */
.public-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.public-card-wrap { max-width: 480px; width: 100%; }
.public-brand { display: flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.public-logo { height: auto; max-width: 280px; display: block; }

/* ---------- Componentes ---------- */
.section-heading { font-size: 1.1rem; font-weight: 800; margin: 0 0 12px; }

.uk-card { border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.uk-card-title { font-weight: 800; }

.uk-button { border-radius: 10px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.uk-button-primary { background-color: var(--accent); }
.uk-button-primary:hover { background-color: var(--accent-dark); }
.uk-button-default { background: var(--surface); border-color: var(--border); color: var(--text); }

.uk-input, .uk-select, .uk-textarea { border-radius: 10px; border-color: var(--border); background: var(--surface); }
.uk-input:focus, .uk-select:focus, .uk-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.uk-form-label { font-weight: 600; font-size: .85rem; color: var(--text); margin-bottom: 4px; display: block; }

.metric-card {
    border-radius: var(--radius);
    padding: 18px 20px;
    background: var(--surface);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-decoration: none !important;
    color: var(--text) !important;
}
a.metric-card:hover { border-color: var(--accent); }
.metric-card .metric-value { font-size: 1.7rem; font-weight: 800; line-height: 1; }
.metric-card .metric-label { color: var(--text-muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge-propio { background: #dbeafe; color: #1e40af; }
.badge-externo { background: #fef3c7; color: #92400e; }
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-off { background: #fee2e2; color: #991b1b; }
.badge-aviso { background: #ffedd5; color: #9a3412; }

.readonly-note { font-size: .8rem; color: var(--text-muted); }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; font-weight: 600; text-decoration: none; }

/* ---------- Filtros ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters .filters-search { flex: 1 1 320px; max-width: 460px; }
.filters .uk-input { width: 100%; }
.filters .uk-select { width: auto; min-width: 150px; }

/* ---------- Tablas ---------- */
.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.table-wrap .uk-table { margin: 0; }
.uk-table { background: var(--surface); }
.uk-table th {
    color: var(--text-muted);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    font-weight: 700;
    white-space: nowrap;
    background: #f9fafc;
}
.uk-table td, .uk-table th { border-bottom: 1px solid var(--border); }
.uk-table td { vertical-align: middle; font-size: .9rem; white-space: nowrap; }
.uk-table-hover tbody tr:hover, .uk-table tbody tr.clickable:hover { background: var(--accent-soft); }
.uk-table td.col-main { font-weight: 700; min-width: 220px; white-space: normal; }
.uk-table td.col-main a { color: var(--text); text-decoration: none; }
.uk-table tr:hover td.col-main a { color: var(--accent-dark); }
tr.clickable { cursor: pointer; }

.data-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.data-list dt { color: var(--text-muted); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.data-list dd { margin: 0; }

/* ---------- Pantallas estrechas: barra lateral arriba ---------- */
@media (max-width: 960px) {
    .app-shell { flex-direction: column; }
    .app-sidebar { position: static; width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 6px 16px; }
    .app-sidebar-brand { border-bottom: none; padding: 8px 0; width: 100%; justify-content: flex-start; }
    .app-logo { max-height: 40px; }
    .app-sidebar-nav { flex: 1 1 100%; flex-direction: row; flex-wrap: nowrap; padding: 4px 0 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .app-nav-link { white-space: nowrap; flex-shrink: 0; }
    .app-sidebar-section-title { display: none; }
    .app-sidebar-footer { border-top: none; display: flex; align-items: center; gap: 8px; padding: 8px 0; }
    .app-sidebar-footer .uk-button { width: auto !important; margin: 0 !important; }
    .app-user { margin-bottom: 0; }
    .app-main { margin-left: 0; }
    .app-topbar, .app-content { padding-left: 16px; padding-right: 16px; }
    .filters .filters-search { max-width: none; }
}

/* ---------- Pestañas ---------- */
.uk-tab > * > a { font-weight: 700; text-transform: none; font-size: .95rem; color: var(--text-muted); }
.uk-tab > .uk-active > a { color: var(--accent-dark); border-color: var(--accent); }
.uk-switcher { margin-top: 16px; }
.uk-table td.col-wrap { white-space: normal; min-width: 160px; }
.badge-neutro { background: #eef1f6; color: var(--text-muted); }
a.status-badge { text-decoration: none; }
