:root {
    --ies-primary: #2059c9;
    --ies-primary-dark: #133372;
    --ies-navy: #132340;
    --ies-accent: #17bca6;
    --ies-bg: #f4f7fc;
    --ies-card: #ffffff;
    --ies-border: #e7edf6;
    --ies-text: #17284d;
    --ies-muted: #687694;
    --sidebar-w: 112px;
    --submenu-w: 238px;
    --topbar-h: 68px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--ies-bg); color: var(--ies-text); font-family: "Segoe UI", Arial, sans-serif; font-size: 14px; }
a { text-decoration: none; color: inherit; }

/* Top navigation */
.app-topbar { height: var(--topbar-h); position: fixed; z-index: 20; top: 0; left: 0; right: 0; background: #fff; border-top: 5px solid #081426; border-bottom: 1px solid #e9eef6; display: flex; align-items: center; padding: 0 24px; gap: 26px; }
.brand-area { width: 285px; display: flex; align-items: center; gap: 28px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: #164a59; min-width: 126px; }
.brand-mark { width: 29px; height: 29px; border-radius: 50%; border: 3px dotted #12afaa; display: block; position: relative; }
.brand-mark::after { content: ""; width: 8px; height: 8px; border-radius: 50%; position: absolute; right: -5px; bottom: 2px; background: #12afaa; }
.brand strong { display: block; font-weight: 700; font-size: 15px; letter-spacing: -.02em; }
.brand small { display: block; font-size: 9px; color: #687694; font-weight: 600; }
.sidebar-toggle { border: 0; background: none; font-size: 25px; color: #253a60; padding: 0; }
.topbar-context { display: flex; align-items: center; gap: 18px; color: #63718e; font-size: 13px; flex: 1; }
.topbar-context .bi-chevron-down { font-size: 10px; margin-left: 5px; }
.company-chip { color: #08a891; border: 1px solid #16c4ad; padding: 8px 14px; border-radius: 5px; font-weight: 600; background: #fff; }
.topbar-tools { display: flex; gap: 13px; align-items: center; color: #2762cd; }
.topbar-tools button { border: 0; background: transparent; color: #2564dc; height: 38px; min-width: 34px; font-size: 17px; position: relative; }
.topbar-tools .notify span { position: absolute; top: 1px; right: 0; background: #ec4451; color: #fff; font-size: 9px; border-radius: 50%; width: 16px; height: 16px; line-height: 16px; font-weight: 700; }
.user-pill { display: flex; align-items: center; gap: 10px; margin-left: 7px; color: var(--ies-navy); }
.user-pill .avatar { width: 34px; height: 34px; background: #e4edff; color: var(--ies-primary); display: grid; place-items: center; border-radius: 50%; font-weight: 700; }
.user-pill strong { display: block; font-size: 12px; }
.user-pill small { display: block; color: #7b88a1; font-size: 11px; }
.logout-btn { margin-left: 4px; color: #8592ab !important; }

/* App shell and navigation */
.app-shell { min-height: 100vh; padding-top: var(--topbar-h); display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.module-sidebar { position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); border-right: 1px solid var(--ies-border); background: #fff; padding: 15px 6px; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.module-link { width: 100%; border: 0; background: transparent; min-height: 59px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #66728a; border-radius: 6px; gap: 5px; text-align: center; font-size: 12px; transition: .18s ease; }
.module-link i { font-size: 18px; }
.module-link:hover { background: #f0f5ff; color: #2765dc; }
.module-link.active { background: #3275e4; color: #fff; box-shadow: 0 4px 15px rgba(50,117,228,.22); font-weight: 600; }
.submenu-panel { position: fixed; z-index: 120; left: var(--sidebar-w); top: var(--topbar-h); width: var(--submenu-w); height: calc(100vh - var(--topbar-h)); background: #fff; border-right: 1px solid var(--ies-border); overflow-y: auto; padding: 25px 18px 24px; box-shadow: 11px 0 24px rgba(20,43,78,.10); opacity: 0; visibility: hidden; pointer-events: none; transform: translateX(-9px); transition: opacity .16s ease, transform .16s ease, visibility .16s ease; }
.submenu-panel.open { opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(0); }
.submenu-group { display: none; }
.submenu-group.visible { display: block; }
.submenu-title { color: #677696; font-size: 11px; font-weight: 700; margin: 0 0 16px 8px; letter-spacing: .04em; }
.submenu-panel a { display: flex; align-items: center; gap: 12px; min-height: 39px; color: #556586; font-size: 13px; padding: 9px 10px; border-left: 2px solid transparent; transition: .15s ease; }
.submenu-panel a i { color: #7187b2; width: 16px; font-size: 14px; }
.submenu-panel a:hover, .submenu-panel a.selected { color: #195ed0; background: #f2f7ff; border-left-color: #2368da; font-weight: 500; }
.submenu-panel a:hover i, .submenu-panel a.selected i { color: #2368da; }
.content-area { min-width: 0; padding: 25px 28px 18px; background: var(--ies-bg); }

/* General page and dashboard */
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.breadcrumb-lite { color: #5574b2; font-size: 11px; font-weight: 700; margin-bottom: 7px; letter-spacing: .05em; }
.page-heading h1 { color: #152c55; font-size: 27px; font-weight: 650; margin: 0 0 4px; letter-spacing: -.03em; }
.page-heading p { margin: 0; color: var(--ies-muted); }
.heading-actions { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.date-filter, .btn-primary-soft { display: inline-flex; height: 42px; align-items: center; gap: 10px; border: 1px solid #dbe5f3; border-radius: 7px; background: #fff; padding: 0 15px; color: #667390; font-weight: 500; }
.btn-primary-soft { background: var(--ies-primary); color: #fff; border-color: var(--ies-primary); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(190px, 1fr)); gap: 15px; margin-bottom: 16px; }
.kpi-card { background: #fff; border: 1px solid #e7edf6; min-height: 101px; border-radius: 9px; display: flex; justify-content: space-between; align-items: center; padding: 19px 20px; box-shadow: 0 4px 15px rgba(22,40,73,.035); }
.kpi-value { font-size: 19px; color: #172d58; font-weight: 700; margin-bottom: 7px; white-space: nowrap; }
.kpi-label { color: #647391; font-size: 13px; }
.kpi-icon { height: 50px; width: 50px; border-radius: 5px; display: grid; place-items: center; font-size: 23px; }
.kpi-icon.blue { background: #d8e5ff; color: #2866e4; }
.kpi-icon.amber { background: #ffebc4; color: #f2a208; }
.kpi-icon.rose { background: #ffdce2; color: #ef6175; }
.kpi-icon.mint { background: #cdf2ec; color: #19ae9d; }
.kpi-icon.outline { color: #657a9b; border: 1px solid #edf1f8; }
.kpi-card.emphasis-blue { color: white; background: linear-gradient(115deg, #2769df, #55a5ed); border: none; }
.kpi-card.emphasis-purple { color: white; background: linear-gradient(115deg, #883fc2, #ba69d6); border: none; }
.kpi-card.emphasis-blue .kpi-label, .kpi-card.emphasis-blue .kpi-value, .kpi-card.emphasis-purple .kpi-label, .kpi-card.emphasis-purple .kpi-value { color: #fff; }
.kpi-icon.transparent { color: #fff; background: rgba(255,255,255,.08); }
.quick-actions-panel { background: #fff; border: 1px solid var(--ies-border); border-radius: 9px; padding: 14px 17px; display: flex; gap: 12px; align-items: center; margin: 16px 0; }
.quick-actions-panel strong { margin-right: 8px; color: #192d55; }
.quick-actions-panel form { margin: 0; }
.quick-action { min-width: 132px; height: 39px; border: 1px solid #e2eaf7; background: #fff; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; color: #3e5380; font-size: 13px; }
.quick-action i { color: #2469df; font-size: 16px; }
.quick-action:hover { border-color: #cbdcfa; background: #f5f9ff; color: #1e5bc6; }
.dashboard-panels { display: grid; grid-template-columns: repeat(3, minmax(250px, 1fr)); gap: 15px; }
.dashboard-panel { background: #fff; border: 1px solid var(--ies-border); border-radius: 8px; overflow: hidden; min-height: 220px; box-shadow: 0 3px 12px rgba(20,43,78,.025); }
.dashboard-panel.panel-wide { grid-column: span 2; min-height: 232px; }
.panel-head { height: 47px; background: #163f94; color: #fff; display: flex; justify-content: space-between; align-items: center; padding: 0 17px; font-weight: 600; }
.panel-head i { margin-right: 8px; }
.panel-head a { color: #fff; border: 1px solid rgba(255,255,255,.4); padding: 5px 12px; font-size: 12px; border-radius: 5px; font-weight: 500; }
.panel-head .period-pill { font-size: 12px; background: rgba(255,255,255,.13); padding: 6px 11px; border-radius: 4px; }
.dash-table { font-size: 12px; color: #4b5874; }
.dash-table thead th { color: #5b6c8c; background: #f6f8fb; font-weight: 600; border-bottom: 1px solid #e8edf5; white-space: nowrap; }
.dash-table td, .dash-table th { padding: .53rem .74rem; border-color: #edf2f8; }
.dash-table td:first-child a { color: #2267df; font-weight: 600; }
.empty-row { color: #8491a8 !important; text-align: center; padding: 38px 12px !important; }
.status-pill { border-radius: 12px; padding: 4px 9px; font-size: 11px; font-weight: 600; display: inline-flex; }
.status-pill.pending { background: #fff0d7; color: #e3921f; }
.status-pill.paid { background: #dff5e7; color: #1b9c5b; }
.implementation-grid { padding: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.implementation-grid > div { position: relative; padding-left: 29px; }
.implementation-grid strong { display: block; font-size: 13px; }
.implementation-grid small { display: block; color: #77859c; margin-top: 3px; }
.progress-dot { position: absolute; left: 0; top: 4px; width: 15px; height: 15px; border-radius: 50%; }
.progress-dot.done { background: #21b57c; box-shadow: 0 0 0 4px #ddf6ec; }
.progress-dot.ready { background: #3377e4; box-shadow: 0 0 0 4px #e1ebff; }
.progress-dot.next { background: #d4dbe8; box-shadow: 0 0 0 4px #f2f4f7; }
.summary-chart { display: flex; gap: 14px; height: 174px; padding: 16px; }
.summary-values { min-width: 130px; display: flex; flex-direction: column; gap: 4px; }
.summary-values small { color: #7585a1; margin-top: 3px; }
.summary-values strong { font-size: 16px; color: #192e58; }
.summary-values .danger { color: #eb4b51; }
.bars { flex: 1; height: 112px; align-self: end; border-bottom: 1px solid #dce4f0; display: flex; align-items: end; justify-content: space-evenly; gap: 10px; background: repeating-linear-gradient(to top, transparent 0 27px, #f0f3f8 28px); }
.bars span { width: 18px; background: linear-gradient(to top, #2870e5, #60a6ee); border-radius: 4px 4px 0 0; }
.future-list { padding: 14px 16px; }
.future-list a { display: flex; align-items: center; gap: 11px; padding: 12px 0; border-bottom: 1px solid #eef2f7; color: #435471; }
.future-list i { color: #2868da; font-size: 16px; }
.future-list span { margin-left: auto; font-size: 11px; border-radius: 12px; padding: 4px 8px; background: #e8efff; color: #2a67d8; }
.dashboard-footer { color: #7e8ba2; font-size: 12px; margin: 20px 0 5px; display: flex; justify-content: space-between; }

/* Existing list/detail pages */
.content-area h2 { color: #172e58; font-size: 25px; font-weight: 650; letter-spacing: -.03em; }
.form-control, .form-select { border-color: #dde6f1; border-radius: 7px; }
.btn-primary { background: var(--ies-primary); border-color: var(--ies-primary); }
.section-card, .app-table { background: #fff; border: 1px solid #e6edf6; border-radius: 9px; overflow: hidden; box-shadow: 0 3px 12px rgba(22,45,75,.03); }
.app-table thead th { background: #f4f7fb; color: #52617e; font-size: .9rem; white-space: nowrap; }
.qty { width: 78px; }
.price-level { width: 78px; }
.empty-module-card { margin-top: 40px; max-width: 640px; padding: 48px 40px; text-align: center; background: #fff; border: 1px solid var(--ies-border); border-radius: 12px; }
.empty-module-icon { height: 68px; width: 68px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 50%; background: #edf4ff; color: var(--ies-primary); font-size: 31px; }
.empty-module-card h3 { color: #172e58; font-size: 22px; }
.empty-module-card p { color: #697992; margin: 13px auto 28px; max-width: 480px; }
.print-sheet { background: #fff; padding: 2.5rem; max-width: 850px; margin: auto; border-radius: 10px; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: linear-gradient(120deg, #f0f5fd, #fff); }
.login-shell { width: 100%; display: grid; place-items: center; }
.login-card { width: min(430px, 100%); background: #fff; padding: 2.7rem; border-radius: 18px; border: 1px solid #e9eef7; }
.brand-title { font-size: 1.85rem; font-weight: 700; color: var(--ies-primary-dark); }
.brand-title span { color: #16aeaa; }

@media (max-width: 1250px) {
    :root { --submenu-w: 210px; }
    .brand-area { width: 245px; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
    .dashboard-panels { grid-template-columns: repeat(2, minmax(250px, 1fr)); }
    .dashboard-panel.panel-wide { grid-column: span 2; }
    .topbar-context { display: none; }
}
@media (max-width: 800px) {
    :root { --sidebar-w: 74px; --submenu-w: 0px; }
    .brand-area { width: auto; flex: 1; }
    .user-pill div, .topbar-tools button:not(.logout-btn), .submenu-panel { display: none !important; }
    .module-link span { display: none; }
    .module-link { min-height: 52px; }
    .content-area { padding: 18px 13px; }
    .kpi-grid, .dashboard-panels { display: block; }
    .kpi-card, .dashboard-panel { margin-bottom: 13px; }
    .heading-actions, .quick-actions-panel { flex-wrap: wrap; }
}
@media print {
    .app-topbar, .module-sidebar, .submenu-panel { display: none !important; }
    .app-shell { display: block; padding-top: 0; }
    body { background: white; }
    .content-area { padding: 0; }
    .print-sheet { padding: 0; max-width: none; }
}

/* Clientes: ficha simplificada, GPS y mapa de rutas */
.ies-page-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:18px; margin-bottom:21px; }
.ies-page-heading .breadcrumb-text { display:block; color:#2567d9; font-size:11px; font-weight:700; letter-spacing:.06em; margin-bottom:8px; }
.ies-page-heading h2 { margin:0 0 4px; }
.ies-page-heading p { color:#71819a; margin:0; }
.client-search-bar { background:#fff; border:1px solid #e6edf6; border-radius:10px; display:flex; padding:14px; gap:10px; margin-bottom:16px; }
.search-input-wrap { position:relative; width:min(520px,100%); }
.search-input-wrap i { position:absolute; left:14px; top:10px; color:#7c8ba2; }
.search-input-wrap .form-control { padding-left:39px; }
.client-list-card td { vertical-align:middle; }
.code-pill { display:inline-flex; background:#eaf1ff; color:#2267df; padding:5px 10px; border-radius:15px; font-weight:600; }
.route-ready { display:inline-flex; align-items:center; gap:4px; background:#e0f5e9; color:#1c965a; padding:5px 9px; border-radius:14px; font-size:12px; font-weight:600; }
.route-pending { background:#f1f3f7; color:#77859c; padding:5px 9px; border-radius:14px; font-size:12px; }
.client-form-card { background:#fff; border:1px solid #e5edf7; box-shadow:0 3px 16px rgba(22,45,75,.04); border-radius:11px; overflow:hidden; }
.client-tabs { display:flex; gap:3px; border-bottom:1px solid #e6edf6; padding:0 21px; background:#fafbfd; }
.client-tabs button { background:transparent; border:0; color:#667794; font-weight:600; padding:17px 19px 14px; border-bottom:3px solid transparent; display:flex; gap:8px; align-items:center; }
.client-tabs button.active { color:#2267df; border-bottom-color:#2267df; background:#fff; }
.client-tab-panel { display:none; padding:23px; }
.client-tab-panel.active { display:block; }
.client-form-columns { display:grid; grid-template-columns:minmax(420px, 2.2fr) minmax(245px, 1fr); gap:20px; }
.form-section { border:1px solid #edf2f8; border-radius:9px; padding:18px; }
.form-section h3 { color:#1b3057; font-size:15px; margin:0 0 17px; font-weight:650; }
.form-label { color:#52617d; font-size:13px; font-weight:500; margin-bottom:5px; }
.form-label.required::after { content:' *'; color:#e54b55; }
.read-only-summary { border-top:1px dashed #e3e9f3; margin-top:22px; padding-top:18px; }
.read-only-summary div { display:flex; justify-content:space-between; gap:8px; padding:8px 0; color:#77859c; font-size:13px; }
.read-only-summary strong { color:#192e58; }
.route-box { border:1px solid #dce8fa; background:#f8fbff; border-radius:10px; padding:19px; margin-top:20px; }
.route-box-head { display:flex; justify-content:space-between; align-items:center; gap:15px; margin-bottom:18px; }
.route-box-head h3 { color:#173260; font-size:16px; margin:0 0 5px; }
.route-box-head h3 i { color:#2267df; margin-right:7px; }
.route-box-head p { margin:0; color:#71819a; font-size:13px; }
.gps-input { background:#fff !important; color:#243859; }
.gps-status { margin-top:15px; color:#687a95; font-size:13px; }
.gps-status i { margin-right:5px; }
.facturar-grid { display:grid; grid-template-columns:minmax(520px, 2.4fr) minmax(260px, 1fr); gap:20px; }
.commercial-controls .form-check { background:#f7f9fc; border:1px solid #edf2f7; padding:13px 13px 13px 48px; border-radius:8px; margin-bottom:12px; }
.information-note { border-radius:9px; background:#eef5ff; color:#566985; padding:15px; display:flex; gap:12px; margin-top:20px; }
.information-note i { font-size:20px; color:#2267df; }
.information-note p { margin:0; font-size:13px; }
.route-report-toolbar { display:flex; justify-content:space-between; align-items:end; background:#fff; border:1px solid #e6edf6; border-radius:10px; padding:14px 18px; margin-bottom:15px; }
.route-count { display:flex; flex-direction:column; text-align:right; color:#72829b; }
.route-count strong { font-size:28px; line-height:1; color:#173260; }
.map-key-warning { display:flex; align-items:center; gap:15px; }
.map-key-warning i { font-size:27px; }
.route-layout { display:grid; grid-template-columns:350px minmax(480px, 1fr); gap:14px; min-height:600px; }
.route-list { overflow:hidden; border:1px solid #e6edf6; }
.route-list-head { height:48px; background:#163f94; color:#fff; padding:14px 17px; font-weight:600; }
.route-client { display:flex; gap:13px; border-bottom:1px solid #edf2f8; padding:13px; color:#253957; text-decoration:none; }
.route-client:hover { background:#f5f9ff; color:#253957; }
.route-client small { display:block; color:#7a88a0; font-size:12px; margin-top:2px; }
.route-order { width:33px; height:33px; background:#2267df; color:#fff; border-radius:50%; display:grid; place-items:center; font-weight:700; flex:none; }
.clients-map { border-radius:10px; overflow:hidden; min-height:600px; background:#eef3fa; border:1px solid #e2eaf5; }
.map-placeholder { height:100%; min-height:600px; display:grid; place-items:center; align-content:center; gap:8px; color:#7890b0; font-weight:600; }
.map-placeholder i { font-size:44px; }
.map-popup { max-width:260px; color:#263852; line-height:1.55; }
@media (max-width: 1050px) {
    .client-form-columns, .facturar-grid, .route-layout { display:block; }
    .form-section.compact, .clients-map { margin-top:15px; }
    .route-box-head, .route-report-toolbar, .ies-page-heading { flex-direction:column; align-items:stretch; }
    .route-list { margin-bottom:14px; }
}

/* ===========================================================
   Responsive / Mobile-first enhancements - IES WEB 2027
   Target devices: teléfonos, tabletas, iPad/macOS y desktop.
   =========================================================== */
.mobile-nav-head,
.mobile-submenu-back,
.mobile-save-bar,
.menu-backdrop { display: none; }
.lock-scroll { overflow: hidden; }
.sidebar-toggle { min-width: 44px; min-height: 44px; touch-action: manipulation; }
.form-control, .form-select, .btn { min-height: 42px; }
.module-link, .submenu-panel a { touch-action: manipulation; }

@media (max-width: 1199.98px) {
    .content-area { padding: 19px 18px 20px; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
    .dashboard-panels { grid-template-columns: repeat(2, minmax(260px, 1fr)); }
    .dashboard-panel.panel-wide { grid-column: span 2; }
    .quick-actions-panel { flex-wrap: wrap; }
    .page-heading h1 { font-size: 24px; }
    .topbar-context .company-chip { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* Tablet: conserva barra lateral compacta y submenú flotante */
@media (min-width: 768px) and (max-width: 1024px) {
    :root { --sidebar-w: 82px; --submenu-w: 275px; --topbar-h: 62px; }
    .brand span:last-child { display: none; }
    .brand-area { width: var(--sidebar-w); justify-content: center; }
    .brand { display: none; }
    .topbar-context { margin-left: 12px; }
    .topbar-tools .user-pill div { display: none; }
    .topbar-tools { gap: 7px; }
    .module-link { min-height: 74px; padding: 12px 3px; font-size: 11px; }
    .module-link span { line-height: 1.15; text-align: center; }
    .submenu-panel { left: var(--sidebar-w); }
    .client-form-columns { grid-template-columns: 1fr; }
    .route-layout { grid-template-columns: 300px minmax(360px, 1fr); min-height: 520px; }
    .clients-map { min-height: 520px; }
}

/* Teléfono: canvas completo, menú tipo drawer y formularios táctiles */
@media (max-width: 767.98px) {
    :root { --topbar-h: 58px; --sidebar-w: 0px; --submenu-w: min(88vw, 340px); }
    body { font-size: 14px; }
    .app-topbar { height: var(--topbar-h); padding: 0 10px; gap: 6px; }
    .brand-area { width: auto; gap: 6px; }
    .brand { width: 38px; overflow: hidden; }
    .brand span:last-child { display: none; }
    .brand-mark { flex: none; }
    .sidebar-toggle { display: inline-grid; place-items: center; margin-left: 0; background: transparent; border: 0; color: #263a61; font-size: 24px; }
    .topbar-context { margin-left: auto; gap: 0; }
    .topbar-context > span:first-child { display: none; }
    .topbar-context .company-chip { font-size: 10px; padding: 7px 8px; max-width: 132px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-tools { gap: 3px; }
    .topbar-tools > button:not(.notify), .topbar-tools .notify, .user-pill { display: none; }
    .logout-btn { width: 42px; height: 42px; }
    .app-shell { display: block; padding-top: var(--topbar-h); min-height: 100vh; }
    .content-area { padding: 16px 12px 84px; min-height: calc(100vh - var(--topbar-h)); }

    .module-sidebar { display: flex !important; position: fixed; z-index: 125; top: 0; left: 0; bottom: 0; width: min(86vw, 318px); background: #fff; padding-top: 0; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 16px 0 34px rgba(16,36,70,.18); overflow-y: auto; }
    body.mobile-nav-open .module-sidebar { transform: translateX(0); }
    .mobile-nav-head { display: flex; flex: none; height: var(--topbar-h); align-items: center; justify-content: space-between; padding: 0 15px 0 18px; color: #172d58; border-bottom: 1px solid #e6edf6; }
    .mobile-nav-head button { border: 0; background: transparent; min-height: 44px; min-width: 44px; color: #5a6b88; font-size: 20px; }
    .module-link { width: 100%; min-height: 54px; flex-direction: row; justify-content: flex-start; gap: 16px; padding: 0 20px; font-size: 14px; border-left: 4px solid transparent; }
    .module-link i { font-size: 19px; }
    .module-link.active { border-left-color: #1457cb; }
    .module-link span { display: inline; }

    .submenu-panel { display: block !important; top: 0; left: 0; height: 100vh; width: min(90vw, 345px); z-index: 130; padding: 0 12px 18px; transform: translateX(-102%); opacity: 1; visibility: visible; pointer-events: none; box-shadow: 16px 0 34px rgba(16,36,70,.2); transition: transform .22s ease; }
    .submenu-panel.open { transform: translateX(0); pointer-events: auto; }
    .mobile-submenu-back { display: flex; width: 100%; height: var(--topbar-h); border: 0; background: #fff; border-bottom: 1px solid #e8edf5; align-items: center; gap: 12px; padding: 0 8px; font-weight: 600; color: #20375f; margin-bottom: 17px; }
    .mobile-submenu-back i { font-size: 18px; }
    .submenu-title { margin-left: 12px; }
    .submenu-panel a { min-height: 48px; padding: 11px 12px; font-size: 14px; }
    .menu-backdrop { display: block; position: fixed; inset: 0; z-index: 115; background: rgba(12,25,49,.42); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s ease, visibility .2s ease; }
    .menu-backdrop.show { opacity: 1; visibility: visible; pointer-events: auto; }

    .page-heading, .ies-page-heading { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
    .page-heading h1, .ies-page-heading h2 { font-size: 22px; }
    .heading-actions { width: 100%; margin-top: 0; gap: 8px; }
    .date-filter, .btn-primary-soft { flex: 1; padding: 0 10px; justify-content: center; font-size: 12px; }
    .btn-primary-soft span { display: none; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi-card { min-height: 94px; padding: 13px 12px; }
    .kpi-value { font-size: 16px; line-height: 1.15; white-space: normal; }
    .kpi-label { font-size: 12px; }
    .kpi-icon { height: 40px; width: 40px; font-size: 19px; flex: none; }
    .quick-actions-panel { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 12px; gap: 8px; scrollbar-width: none; }
    .quick-actions-panel::-webkit-scrollbar { display: none; }
    .quick-actions-panel strong { min-width: 102px; }
    .quick-action { min-width: 122px; height: 44px; }
    .dashboard-panels { display: block; }
    .dashboard-panel, .dashboard-panel.panel-wide { margin-bottom: 12px; min-height: auto; }
    .panel-head { height: auto; min-height: 48px; padding: 11px 12px; font-size: 13px; }
    .dash-table td, .dash-table th { padding: .56rem .62rem; }
    .summary-chart { padding: 14px; }
    .dashboard-footer { flex-direction: column; gap: 4px; text-align: center; padding-bottom: 15px; }

    /* Listado de clientes convertido a tarjetas, sin scroll horizontal incómodo */
    .client-search-bar { flex-direction: column; padding: 12px; }
    .client-search-bar .btn { width: 100%; }
    .mobile-card-table thead { display: none; }
    .mobile-card-table, .mobile-card-table tbody, .mobile-card-table tr, .mobile-card-table td { display: block; width: 100%; }
    .mobile-card-table tr { border-bottom: 1px solid #e8edf5; padding: 12px 12px 8px; }
    .mobile-card-table td { border: 0; padding: 5px 0; text-align: left !important; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
    .mobile-card-table td::before { content: attr(data-label); color: #71819a; font-size: 12px; font-weight: 600; flex: 0 0 84px; }
    .mobile-card-table td:nth-child(2) { display: block; padding-bottom: 9px; }
    .mobile-card-table td:nth-child(2)::before { display: none; }
    .mobile-card-table .table-action { display: block; padding-top: 10px; }
    .mobile-card-table .table-action::before { display: none; }
    .mobile-card-table .table-action .btn { width: 100%; }

    /* Ficha de clientes */
    .client-desktop-actions { display: none !important; }
    .client-form-card { border-radius: 10px; }
    .client-tabs { overflow-x: auto; white-space: nowrap; padding: 0 8px; position: sticky; top: var(--topbar-h); z-index: 3; }
    .client-tabs button { min-height: 52px; padding: 14px 12px; }
    .client-tab-panel { padding: 13px; }
    .client-form-columns, .facturar-grid { display: block; }
    .form-section { padding: 14px; margin-bottom: 12px; }
    .form-section h3 { font-size: 16px; }
    .route-box { margin-top: 12px; padding: 13px; }
    .route-box-head { display: block; margin-bottom: 14px; }
    .route-box-head .btn { display: none; }
    .gps-status { font-size: 13px; }
    .mobile-save-bar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 90; background: #fff; border-top: 1px solid #dfe7f3; box-shadow: 0 -7px 18px rgba(19,43,79,.09); padding: 8px 10px max(8px, env(safe-area-inset-bottom)); gap: 8px; }
    .mobile-save-bar .btn { min-height: 46px; }

    /* Reporte de mapa */
    .route-report-toolbar { display: block; padding: 12px; }
    .route-filter-form { flex-direction: column; align-items: stretch !important; }
    .route-filter-form > div, .route-filter-form .btn { width: 100%; }
    .route-count { margin-top: 12px; flex-direction: row; align-items: center; justify-content: space-between; text-align: left; padding-top: 10px; border-top: 1px solid #e8edf5; }
    .route-count strong { font-size: 24px; }
    .route-layout { display: flex; flex-direction: column; min-height: 0; gap: 12px; }
    .clients-map { min-height: 50vh; height: 50vh; order: 1; border-radius: 10px; }
    .route-list { order: 2; max-height: 40vh; overflow-y: auto; }
    .route-client { min-height: 57px; }
}

@media (max-width: 390px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .company-chip { display: none !important; }
    .content-area { padding-left: 10px; padding-right: 10px; }
}

/* Mapa de visitas sin API Key: Leaflet + OpenStreetMap */
.map-source-note { display:flex; gap:9px; align-items:center; margin: 0 0 12px; padding:10px 13px; border:1px solid #deebf9; border-radius:10px; background:#f5f9ff; color:#5f7190; font-size:13px; }
#clientesMap.leaflet-container { background:#e8edf4; font-family: inherit; }
.visit-div-icon { background: transparent; border: 0; }
.visit-div-icon span { display:flex; align-items:center; justify-content:center; width:34px; height:34px; border-radius:50% 50% 50% 0; transform:rotate(-45deg); background:#2267df; border:2px solid #fff; box-shadow:0 4px 12px rgba(22,72,156,.35); color:#fff; font-weight:700; font-size:13px; }
.visit-div-icon span b { display:block; transform:rotate(45deg); font:inherit; line-height:1; }
.route-client { width:100%; border:0; background:#fff; text-align:left; cursor:pointer; }
.route-client:hover, .route-client:focus-visible { background:#eef5ff; outline:none; }
.leaflet-popup-content-wrapper { border-radius:10px; }
.map-popup strong { display:block; color:#1b315c; margin-bottom:5px; }
.map-popup p { margin:0 0 6px; color:#63728a; }
.map-popup a { display:inline-block; margin-top:7px; color:#2267df; font-weight:600; text-decoration:none; }
@media (max-width: 767px) { .map-source-note { font-size:12px; align-items:flex-start; } }


/* Ajustes clientes web limitado */
.limited-client-form .form-section { margin-bottom: 0; }
.gps-help { background: #fff3cd; border: 1px solid #ffe08a; border-radius: 12px; padding: 12px 14px; color: #7a4c00 !important; }
.gps-input { font-family: Consolas, monospace; }
@media (max-width: 768px) {
  .client-page-header .page-actions { flex-wrap: wrap; }
  .limited-client-form .form-section { padding: 16px; }
  .route-box-head { gap: 12px; }
}
