:root {
  --navy: #123b67;
  --blue: #1769aa;
  --blue-soft: #eaf3fb;
  --green: #2f8f46;
  --green-soft: #e9f6ec;
  --orange: #c96b14;
  --red: #b42318;
  --gray-900: #17202a;
  --gray-700: #44505c;
  --gray-500: #74808c;
  --gray-300: #ccd4dc;
  --gray-200: #e4e9ee;
  --gray-100: #f5f7f9;
  --white: #fff;
  --shadow: 0 8px 24px rgba(18, 59, 103, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--gray-100);
  color: var(--gray-900);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 28px;
  color: var(--white);
  background: linear-gradient(110deg, var(--navy), #0d5687);
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--white); color: var(--navy); font-weight: 900; font-size: 17px;
}
.brand strong { display: block; font-size: 18px; }
.brand span { display: block; font-size: 12px; opacity: .86; margin-top: 2px; }
.main-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.main-nav a { color: var(--white); padding: 9px 10px; border-radius: 8px; font-weight: 700; font-size: 13px; }
.main-nav a:hover { background: rgba(255,255,255,.13); text-decoration: none; }
.nav-logout { border: 1px solid rgba(255,255,255,.38); }
.menu-button { display: none; background: transparent; border: 0; color: white; font-size: 27px; }
.container { width: min(1440px, calc(100% - 32px)); margin: 24px auto 42px; }
.user-strip { display: flex; justify-content: flex-end; align-items: center; gap: 10px; color: var(--gray-700); margin-bottom: 14px; font-size: 13px; }
.page-header { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.page-header h1 { margin: 0; color: var(--navy); font-size: 28px; }
.page-header p { margin: 6px 0 0; color: var(--gray-700); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 9px 14px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer; font: inherit; font-weight: 750;
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn-primary { background: var(--blue); color: var(--white); }
.btn-success { background: var(--green); color: var(--white); }
.btn-secondary { background: var(--white); color: var(--navy); border-color: var(--gray-300); }
.btn-danger { background: #fff2f0; color: var(--red); border-color: #ffc9c3; }
.btn-sm { min-height: 32px; padding: 5px 9px; font-size: 12px; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.card, .panel {
  background: var(--white); border: 1px solid var(--gray-200); border-radius: 12px; box-shadow: var(--shadow);
}
.card { padding: 18px; }
.card-label { color: var(--gray-700); font-size: 13px; font-weight: 700; }
.card-value { color: var(--navy); font-size: 32px; font-weight: 850; margin-top: 4px; }
.card-note { color: var(--gray-500); font-size: 12px; margin-top: 4px; }
.panel { margin-bottom: 18px; overflow: hidden; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 15px 18px; background: #f9fbfd; border-bottom: 1px solid var(--gray-200); }
.panel-header h2 { margin: 0; font-size: 17px; color: var(--navy); }
.panel-body { padding: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--gray-200); vertical-align: top; text-align: left; }
th { color: var(--white); background: #377fb7; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
tbody tr:hover { background: #f8fbfd; }
.text-muted { color: var(--gray-500); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge-success { background: var(--green-soft); color: #226c35; }
.badge-warning { background: #fff5df; color: #8a4b08; }
.badge-danger { background: #fff0ed; color: var(--red); }
.badge-neutral { background: #edf1f5; color: #45515d; }
.badge-blue { background: var(--blue-soft); color: #135a91; }
.alert { padding: 12px 15px; border-radius: 8px; margin-bottom: 14px; font-weight: 650; }
.alert-success { background: var(--green-soft); color: #226c35; border: 1px solid #bce2c5; }
.alert-error { background: #fff0ed; color: var(--red); border: 1px solid #ffc9c3; }
.alert-warning { background: #fff6df; color: #80520b; border: 1px solid #f3d28f; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.field { grid-column: span 4; }
.field-wide { grid-column: span 6; }
.field-full { grid-column: 1 / -1; }
label { display: block; margin-bottom: 6px; color: var(--gray-700); font-size: 13px; font-weight: 750; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 10px; border: 1px solid #aebac5; border-radius: 7px;
  background: var(--white); color: var(--gray-900); font: inherit;
}
textarea { min-height: 105px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(23,105,170,.15); border-color: var(--blue); }
.help-text { color: var(--gray-500); font-size: 12px; margin-top: 5px; }
.form-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; border-top: 1px solid var(--gray-200); padding-top: 16px; }
.progress { height: 9px; background: #e7edf2; border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); border-radius: inherit; }
.progress-label { font-size: 11px; color: var(--gray-700); margin-top: 4px; }
.filters { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; align-items: end; }
.filters .field { grid-column: span 1; }
.login-shell { width: min(520px, calc(100% - 30px)); margin: 70px auto; }
.login-card { background: white; border-radius: 14px; box-shadow: 0 16px 45px rgba(18,59,103,.18); overflow: hidden; }
.login-title { background: linear-gradient(110deg, var(--navy), #0d5687); color: white; padding: 26px; }
.login-title h1 { margin: 0; font-size: 25px; }
.login-title p { margin: 8px 0 0; opacity: .85; }
.login-body { padding: 26px; }
.empty { text-align: center; padding: 34px 18px; color: var(--gray-500); }
.grid-two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stat-list { display: grid; gap: 10px; }
.stat-row { display: grid; grid-template-columns: 1fr 90px 130px; align-items: center; gap: 10px; }
.footer { display: flex; justify-content: space-between; gap: 12px; padding: 18px 28px; background: #e8edf2; color: var(--gray-700); font-size: 12px; }
.code-box { background: #101820; color: #e7f1f8; border-radius: 8px; padding: 12px; overflow-x: auto; }

@media (max-width: 1050px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field { grid-column: span 6; }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 15px; align-items: flex-start; }
  .brand span { display: none; }
  .menu-button { display: block; }
  .main-nav { display: none; position: absolute; top: 68px; left: 12px; right: 12px; background: var(--navy); padding: 10px; border-radius: 10px; box-shadow: var(--shadow); }
  .main-nav.is-open { display: grid; }
  .main-nav a { padding: 11px; }
  .container { width: min(100% - 20px, 1440px); margin-top: 16px; }
  .page-header { display: block; }
  .page-header .actions { margin-top: 12px; }
  .cards { grid-template-columns: 1fr; }
  .form-grid, .filters, .grid-two { grid-template-columns: 1fr; }
  .field, .field-wide, .field-full, .filters .field { grid-column: 1; }
  .panel-body { padding: 13px; }
  .stat-row { grid-template-columns: 1fr 65px; }
  .stat-row .progress { grid-column: 1 / -1; }
  .footer { display: block; text-align: center; }
  table.responsive-table thead { display: none; }
  table.responsive-table, table.responsive-table tbody, table.responsive-table tr, table.responsive-table td { display: block; width: 100%; }
  table.responsive-table tr { border: 1px solid var(--gray-200); border-radius: 8px; margin-bottom: 10px; padding: 8px; }
  table.responsive-table td { border: 0; padding: 6px 4px; }
  table.responsive-table td::before { content: attr(data-label); display: block; color: var(--gray-500); font-size: 10px; font-weight: 800; text-transform: uppercase; }
}

@media print {
  .topbar, .user-strip, .actions, .filters, .footer, .no-print { display: none !important; }
  body { background: white; font-size: 11px; }
  .container { width: 100%; margin: 0; }
  .panel, .card { box-shadow: none; border-color: #aaa; }
}

.filters-wide { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.filters-wide .field { grid-column: span 1; }
@media (max-width: 1200px) { .filters-wide { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .filters-wide { grid-template-columns: 1fr; } .filters-wide .field { grid-column: 1; } }

/* Seguimiento Instalaciones v1.2.0 — PWA y experiencia móvil */
html { min-height: 100%; background: var(--gray-100); }
body { min-height: 100vh; min-height: 100dvh; padding-top: env(safe-area-inset-top); }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.brand-logo { width: 44px; height: 44px; border-radius: 12px; flex: 0 0 auto; box-shadow: 0 2px 8px rgba(0,0,0,.16); }
.topbar-actions { display: flex; align-items: center; gap: 8px; order: 3; }
.main-nav { order: 2; margin-left: auto; }
.main-nav a.is-active { background: rgba(255,255,255,.17); }
.install-button {
  min-height: 36px; padding: 8px 12px; border: 1px solid rgba(255,255,255,.5); border-radius: 9px;
  background: rgba(255,255,255,.12); color: white; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer;
}
.install-button:hover { background: rgba(255,255,255,.22); }
.network-status {
  display: inline-flex; align-items: center; gap: 6px; color: rgba(255,255,255,.92); font-size: 11px; font-weight: 800; white-space: nowrap;
}
.network-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #70df86; box-shadow: 0 0 0 3px rgba(112,223,134,.15); }
.network-status.is-offline::before { background: #ffb25b; box-shadow: 0 0 0 3px rgba(255,178,91,.15); }
.login-pwa-tools { position: fixed; z-index: 10; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); display: flex; align-items: center; gap: 10px; }
.login-pwa-tools .network-status { color: var(--navy); }
.login-pwa-tools .install-button { color: var(--navy); border-color: #b9cbda; background: rgba(255,255,255,.92); box-shadow: var(--shadow); }
.mobile-bottom-nav { display: none; }

.install-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.install-modal-backdrop { position: absolute; inset: 0; background: rgba(8,24,40,.58); backdrop-filter: blur(3px); }
.install-modal-card {
  position: relative; z-index: 1; width: min(430px, 100%); padding: 26px; border-radius: 18px; background: white;
  box-shadow: 0 24px 70px rgba(8,24,40,.30); text-align: center;
}
.install-modal-card img { border-radius: 18px; box-shadow: var(--shadow); }
.install-modal-card h2 { margin: 14px 0 10px; color: var(--navy); font-size: 21px; }
.install-modal-card p { color: var(--gray-700); line-height: 1.55; }
.install-modal-close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #edf2f6; color: var(--gray-700); font-size: 24px; cursor: pointer; }
.modal-open { overflow: hidden; }
.app-toast { position: fixed; z-index: 120; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: min(92vw, 560px); padding: 12px 16px; border-radius: 10px; background: #102e4d; color: white; box-shadow: 0 14px 38px rgba(0,0,0,.25); font-weight: 750; font-size: 13px; text-align: center; }
.offline-page { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px; background: linear-gradient(145deg, #edf4fa, #f8fafc); }
.offline-card { width: min(520px, 100%); padding: 34px; border: 1px solid var(--gray-200); border-radius: 18px; background: white; box-shadow: var(--shadow); text-align: center; }
.offline-card img { border-radius: 20px; }
.offline-card h1 { color: var(--navy); }
.offline-card p { color: var(--gray-700); line-height: 1.6; }

@media (display-mode: standalone) {
  .install-button { display: none !important; }
  .topbar { padding-top: calc(12px + env(safe-area-inset-top)); }
}

@media (max-width: 760px) {
  body { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .topbar { min-height: 64px; padding: 9px 12px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); align-items: center; }
  .brand-logo { width: 40px; height: 40px; border-radius: 10px; }
  .brand strong { font-size: 15px; }
  .topbar-actions { margin-left: auto; }
  .topbar-actions .network-status, .topbar-actions .install-button { display: none !important; }
  .menu-button { min-width: 42px; min-height: 42px; display: grid; place-items: center; border-radius: 10px; }
  .main-nav { top: calc(64px + env(safe-area-inset-top)); left: 8px; right: 8px; max-height: calc(100dvh - 88px); overflow-y: auto; }
  .container { width: calc(100% - 16px); margin: 12px auto 26px; }
  .user-strip { justify-content: space-between; margin-bottom: 10px; }
  .page-header h1 { font-size: 23px; }
  .page-header p { font-size: 13px; }
  .actions .btn, .form-footer .btn { flex: 1 1 auto; }
  .form-footer { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 6; margin-left: -13px; margin-right: -13px; margin-bottom: -13px; padding: 12px 13px; background: rgba(255,255,255,.96); box-shadow: 0 -8px 18px rgba(18,59,103,.08); }
  input, select, textarea { min-height: 46px; font-size: 16px; }
  textarea { min-height: 120px; }
  .mobile-bottom-nav {
    position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; height: calc(66px + env(safe-area-inset-bottom)); padding: 6px max(6px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(6px, env(safe-area-inset-right));
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; background: rgba(255,255,255,.96); border-top: 1px solid var(--gray-200); box-shadow: 0 -8px 24px rgba(18,59,103,.12); backdrop-filter: blur(12px);
  }
  .mobile-bottom-nav a { min-width: 0; height: 54px; display: grid; place-items: center; align-content: center; gap: 1px; color: var(--gray-500); border-radius: 10px; font-weight: 800; }
  .mobile-bottom-nav a:hover { text-decoration: none; }
  .mobile-bottom-nav a span { font-size: 20px; line-height: 1; }
  .mobile-bottom-nav a small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 9px; white-space: nowrap; }
  .mobile-bottom-nav a.is-active { color: var(--blue); background: var(--blue-soft); }
  .mobile-bottom-nav .mobile-new { position: relative; color: white; }
  .mobile-bottom-nav .mobile-new span { width: 46px; height: 46px; margin-top: -20px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(145deg, var(--blue), var(--navy)); box-shadow: 0 8px 18px rgba(23,105,170,.34); font-size: 27px; }
  .mobile-bottom-nav .mobile-new small { color: var(--blue); }
  .footer { display: none; }
  .login-pwa-tools { top: auto; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .login-pwa-tools .network-status { display: none; }
  .login-shell { margin: 32px auto 90px; }
  .login-card { border-radius: 16px; }
  .login-title { padding: 22px; }
  .login-body { padding: 22px; }
  .install-modal { align-items: end; padding: 0; }
  .install-modal-card { width: 100%; border-radius: 20px 20px 0 0; padding: 28px 22px calc(24px + env(safe-area-inset-bottom)); }
  .table-wrap { margin-left: -13px; margin-right: -13px; padding: 0 13px; }
}
