/* ── FP Construcciones App v3 — Diseño Premium ───────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=DM+Serif+Display&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:        #185959;
  --green-dark:   #0d3535;
  --green-mid:    #1e6f6f;
  --green-light:  #e6f3f3;
  --green-glow:   rgba(24,89,89,0.15);
  --accent:       #00c49a;
  --accent-soft:  #e0faf4;
  --amber:        #f59e0b;
  --amber-soft:   #fffbeb;
  --red:          #ef4444;
  --red-soft:     #fef2f2;
  --blue:         #3b82f6;
  --blue-soft:    #eff6ff;
  --gray-50:      #f8fafc;
  --gray-100:     #f1f5f9;
  --gray-200:     #e2e8f0;
  --gray-400:     #94a3b8;
  --gray-500:     #64748b;
  --gray-700:     #334155;
  --gray-900:     #0f172a;
  --white:        #ffffff;
  --shadow-xs:    0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:    0 1px 8px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow-md:    0 4px 20px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg:    0 10px 40px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
  --shadow-green: 0 4px 20px rgba(24,89,89,.25);
  --r-sm:  10px;
  --r-md:  16px;
  --r-lg:  20px;
  --r-xl:  28px;
  --r-2xl: 36px;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

input, select, textarea, button { font-family: inherit; }

/* ── APP LAYOUT ─────────────────────────────────────────────────────────── */
#screen-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ── SIDEBAR (contenedor para desktop) ─────────────────────────────── */
#sidebar {
  display: contents; /* En móvil: invisible, topbar y nav actúan independiente */
}
/* En móvil: forzar nav al final usando order */
.bottom-nav { order: 99; }
.main-content { order: 1; }

/* ── TOPBAR ─────────────────────────────────────────────────────────────── */
.topbar {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 60%, var(--green-mid) 100%);
  padding: 44px 18px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.topbar::before {
  content: '';
  position: absolute;
  top: -30px; right: -20px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.topbar::after {
  content: '';
  position: absolute;
  bottom: -40px; left: 30%;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(0,196,154,.08);
}
.topbar-left { display: flex; align-items: center; gap: 11px; z-index:1; }
.logo-sm {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: rgba(255,255,255,.2);
  backdrop-filter: blur(10px);
  color: white;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: -.5px;
  border: 1px solid rgba(255,255,255,.25);
}
.page-title { font-size: 18px; font-weight: 700; color: white; line-height: 1.2; font-family: 'DM Serif Display', serif; }
.page-sub   { font-size: 11px; color: rgba(255,255,255,.55); margin-top: 1px; }
.topbar-right { display: flex; gap: 8px; z-index:1; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  background: rgba(255,255,255,.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.2);
  color: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  transition: background .15s, transform .1s;
}
.icon-btn:active { background: rgba(255,255,255,.28); transform: scale(.95); }
.notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  border-radius: 50%; background: #ff6b6b;
  border: 2px solid rgba(255,255,255,.5);
  display: none;
}
.notif-dot.show { display: block; }

/* ── MAIN CONTENT ─────────────────────────────────────────────────────── */
.main-content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 84px;
  background: var(--gray-50);
}
.page { display: none; }
.page.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:none} }

/* ── BOTTOM NAV ─────────────────────────────────────────────────────────── */
.bottom-nav {
  display: flex;
  background: white;
  border-top: 1px solid var(--gray-200);
  padding: 6px 0 env(safe-area-inset-bottom);
  flex-shrink: 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,.06);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px; padding: 6px 4px;
  background: none; border: none; cursor: pointer;
  color: var(--gray-400); font-size: 10px; font-weight: 500;
  transition: color .15s;
  position: relative;
}
.nav-item::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 0; height: 3px;
  background: var(--green);
  border-radius: 0 0 4px 4px;
  transition: width .2s;
}
.nav-item.active { color: var(--green); }
.nav-item.active::before { width: 24px; }
.nav-item svg { transition: transform .15s; }
.nav-item.active svg { transform: scale(1.1); }

/* ── HERO BANNER (INICIO) ─────────────────────────────────────────────── */
.hero-banner {
  position: relative;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 50%, var(--green-mid) 100%);
  padding: 24px 20px 60px;
  overflow: hidden;
}
.hero-banner::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero-greeting { font-size: 13px; color: rgba(255,255,255,.65); font-weight: 400; }
.hero-name     { font-size: 28px; font-weight: 700; color: white; margin-top: 2px; font-family: 'DM Serif Display', serif; letter-spacing: -.5px; }
.hero-date     { font-size: 12px; color: rgba(255,255,255,.5); text-align: right; line-height: 1.7; }

/* ── METRICS FLOAT OVER HERO ─────────────────────────────────────────── */
.metrics-float {
  margin: -36px 14px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  position: relative;
  z-index: 2;
}
.metric-card {
  background: white;
  border-radius: var(--r-lg);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(0,0,0,.04);
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.metric-card:active { transform: scale(.98); }
.metric-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  border-radius: 0 var(--r-lg) 0 60px;
  opacity: .06;
}
.metric-card.green::after { background: var(--accent); }
.metric-card.warn::after  { background: var(--amber); }
.metric-card.blue::after  { background: var(--blue); }
.metric-card.gray::after  { background: var(--gray-500); }
.metric-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; margin-bottom: 10px;
}
.metric-icon.green { background: var(--accent-soft); }
.metric-icon.warn  { background: var(--amber-soft); }
.metric-icon.blue  { background: var(--blue-soft); }
.metric-icon.gray  { background: var(--gray-100); }
.metric-label { font-size: 11px; color: var(--gray-500); font-weight: 500; letter-spacing: .02em; }
.metric-value { font-size: 20px; font-weight: 700; color: var(--gray-900); margin-top: 4px; line-height: 1; }
.metric-value.green { color: var(--accent); }
.metric-value.warn  { color: var(--amber); }
.metric-value.blue  { color: var(--blue); }

/* ── SECTION HEADERS ─────────────────────────────────────────────────── */
.section-header {
  font-size: 12px; font-weight: 700; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 20px 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.section-header a { font-size: 12px; color: var(--green); font-weight: 600; text-decoration: none; }

/* ── BALANCE BAR (CAJA) ──────────────────────────────────────────────── */
.balance-bar {
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  padding: 20px 20px 16px;
  display: flex; justify-content: space-between;
  gap: 10px;
  position: relative; overflow: hidden;
}
.balance-bar::before {
  content: '';
  position: absolute; top: -20px; right: -20px;
  width: 100px; height: 100px; border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.bal-item { text-align: center; flex: 1; }
.bal-label  { font-size: 10px; color: rgba(255,255,255,.55); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.bal-amount { font-size: 17px; font-weight: 700; color: white; margin-top: 4px; }
.bal-amount.warn { color: #fde68a; }
.bal-amount.green-bright { color: #6ee7b7; }
.bal-divider { width: 1px; background: rgba(255,255,255,.15); }

.prog-container {
  padding: 10px 16px 6px;
  display: flex; align-items: center; gap: 10px;
}
.prog-track {
  flex: 1; height: 6px; background: var(--gray-200);
  border-radius: 3px; overflow: hidden;
}
.prog-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); border-radius: 3px; transition: width .6s cubic-bezier(.34,1.56,.64,1); }
.prog-fill.warn { background: linear-gradient(90deg, var(--amber), #f97316); }
.prog-container span { font-size: 12px; font-weight: 700; color: var(--gray-600, #4b5563); min-width: 36px; text-align: right; }

/* ── LIST ITEMS ──────────────────────────────────────────────────────── */
.list-container { padding: 0 14px; display: flex; flex-direction: column; gap: 8px; }
.list-item {
  background: white;
  border-radius: var(--r-md);
  border: 1px solid var(--gray-200);
  padding: 13px 14px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  box-shadow: var(--shadow-xs);
}
.list-item:active { box-shadow: var(--shadow-sm); transform: scale(.99); }
.item-icon {
  width: 42px; height: 42px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.item-body { flex: 1; min-width: 0; }
.item-title { font-size: 14px; font-weight: 600; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub   { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.item-right { text-align: right; flex-shrink: 0; }
.item-amount { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.item-date   { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* ── BADGES ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 10px;
  border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-amber  { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gray   { background: var(--gray-100); color: var(--gray-500); }

/* ── FILTER CHIPS ─────────────────────────────────────────────────── */
.filter-chips {
  display: flex; gap: 8px;
  padding: 10px 14px;
  overflow-x: auto; scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 7px 16px; border-radius: 24px;
  font-size: 12px; font-weight: 600;
  border: 1.5px solid var(--gray-200);
  background: white; color: var(--gray-500);
  cursor: pointer; white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
}
.chip.active {
  background: var(--green);
  color: white;
  border-color: var(--green);
  box-shadow: 0 2px 8px rgba(24,89,89,.3);
}

/* ── BODEGA ──────────────────────────────────────────────────────────── */
.scanner-zone {
  background: linear-gradient(135deg, #0a1f1f, #0d3535);
  padding: 20px 16px;
  display: none; flex-direction: column; align-items: center; gap: 14px;
  border-radius: 0 0 24px 24px;
  margin-bottom: 12px;
}
.scanner-zone.open { display: flex; }
.scanner-frame {
  width: 200px; height: 130px; position: relative;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; overflow: hidden;
  background: rgba(0,0,0,.3);
}
.scan-corner {
  position: absolute; width: 24px; height: 24px;
  border-color: var(--accent); border-style: solid;
}
.scan-corner.tl { top:0; left:0;  border-width:3px 0 0 3px; border-radius:8px 0 0 0; }
.scan-corner.tr { top:0; right:0; border-width:3px 3px 0 0; border-radius:0 8px 0 0; }
.scan-corner.bl { bottom:0; left:0;  border-width:0 0 3px 3px; border-radius:0 0 0 8px; }
.scan-corner.br { bottom:0; right:0; border-width:0 3px 3px 0; border-radius:0 0 8px 0; }
.scan-laser {
  position: absolute; left: 6px; right: 6px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  top: 50%; animation: scanMove 1.5s ease-in-out infinite;
}
@keyframes scanMove { 0%,100%{top:15%} 50%{top:82%} }
.scanner-label { font-size: 13px; color: rgba(255,255,255,.65); }

/* ── UPLOAD ZONE (BOLETAS) ───────────────────────────────────────────── */
.upload-zone {
  margin: 16px 14px;
  background: white;
  border: 2px dashed var(--green-mid);
  border-radius: var(--r-xl);
  padding: 32px 20px; text-align: center; cursor: pointer;
  transition: all .2s;
  box-shadow: var(--shadow-xs);
  position: relative; overflow: hidden;
}
.upload-zone::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, var(--green-light) 0%, rgba(230,243,243,0) 60%);
  opacity: 0; transition: opacity .2s;
}
.upload-zone:active::before { opacity: 1; }
.upload-icon { color: var(--green); margin-bottom: 12px; display: flex; justify-content: center; }
.upload-title { font-size: 16px; font-weight: 700; color: var(--green-dark); font-family: 'DM Serif Display', serif; }
.upload-sub   { font-size: 13px; color: var(--green-mid); margin-top: 6px; }
.ocr-status {
  margin: 0 14px 12px;
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--r-sm);
  padding: 12px; font-size: 13px; color: #92400e; text-align: center;
}

/* ── FORMS ───────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 11px; font-weight: 700;
  color: var(--gray-500); letter-spacing: .06em;
  text-transform: uppercase; margin-bottom: 7px;
}
input[type="text"], input[type="number"], input[type="date"],
input[type="search"], input[type="email"], input[type="password"],
select, textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r-sm);
  font-size: 14px; color: var(--gray-900);
  background: var(--gray-50); outline: none;
  transition: all .15s; -webkit-appearance: none;
  font-family: 'DM Sans', system-ui, sans-serif;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  background: white;
  box-shadow: 0 0 0 4px var(--green-glow);
}
textarea { resize: vertical; }

/* ── BUTTONS ─────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%; padding: 15px;
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  color: white;
  border: none; border-radius: var(--r-sm);
  font-size: 15px; font-weight: 700; cursor: pointer;
  transition: all .15s; letter-spacing: .2px;
  box-shadow: var(--shadow-green);
}
.btn-primary:active { transform: scale(.99); opacity: .9; }
.btn-secondary {
  padding: 13px 20px;
  background: var(--gray-100); color: var(--gray-700);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s;
}
.btn-secondary:active { background: var(--gray-200); }
.btn-icon-green {
  padding: 11px 13px; background: var(--green-light);
  color: var(--green); border: none; border-radius: var(--r-sm);
  cursor: pointer; display: flex; align-items: center;
  transition: background .15s;
}
.btn-icon-green:active { background: #c5dede; }
.btn-danger {
  padding: 10px 14px; background: var(--red-soft);
  color: var(--red); border: none; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-scan {
  padding: 10px 20px;
  background: var(--green); color: white;
  border: none; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-scan-out { background: var(--red); }
.btn-scan-neutral { background: rgba(255,255,255,.15); }

/* ── FAB ─────────────────────────────────────────────────────────────── */
.fab {
  position: fixed; bottom: calc(env(safe-area-inset-bottom, 0px) + 76px); right: 16px;
  width: 52px; height: 52px; border-radius: 16px;
  background: linear-gradient(135deg, var(--green-dark), var(--green));
  color: white; border: none;
  box-shadow: 0 6px 20px rgba(24,89,89,.4);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .2s;
  z-index: 90;
}
.fab:active { transform: scale(.94); }
#page-caja, #page-bodega { position: relative; min-height: calc(100vh - 160px); }

/* ── PRINT BUTTON ─────────────────────────────────────────────────── */
.print-btn {
  display: inline-flex; align-items: center; gap: 7px;
  margin: 8px 16px 0;
  padding: 9px 16px; background: white;
  border: 1.5px solid var(--gray-200); border-radius: var(--r-sm);
  font-size: 13px; font-weight: 600; color: var(--gray-500);
  cursor: pointer; transition: all .15s;
}
.print-btn:active { background: var(--gray-100); }

/* ── MODALES ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.55); backdrop-filter: blur(6px);
  z-index: 1000; display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: 28px 28px 0 0;
  padding: 24px 20px calc(28px + env(safe-area-inset-bottom));
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  display: none; animation: slideUp .28s cubic-bezier(.25,.46,.45,.94);
}
.modal.open { display: block; }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-handle {
  width: 40px; height: 4px; background: var(--gray-200);
  border-radius: 2px; margin: 0 auto 20px;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 20px; font-weight: 700; color: var(--gray-900); font-family: 'DM Serif Display', serif; }
.modal-close {
  background: var(--gray-100); border: none; border-radius: 50%;
  width: 32px; height: 32px; font-size: 14px; cursor: pointer;
  color: var(--gray-500); display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

/* ── SYNC STATUS ─────────────────────────────────────────────────────── */
.sync-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  background: #f0fdf4;
  font-size: 12px; color: #166534; font-weight: 500;
  border-bottom: 1px solid #bbf7d0;
}
.sync-bar.error   { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.sync-bar.syncing { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #16a34a; flex-shrink: 0; }
.sync-dot.syncing { animation: pulse .8s ease infinite; background: var(--amber); }
.sync-dot.error   { background: var(--red); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ── EMPTY STATES ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 16px;
  color: var(--gray-400);
}
.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: .5; }
.empty-state p { font-size: 14px; font-weight: 500; }
.empty-state small { font-size: 12px; color: var(--gray-400); margin-top: 4px; display: block; }

/* ── SPINNER ─────────────────────────────────────────────────────────── */
.spinner-lg {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST ───────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--gray-900); color: white;
  padding: 12px 24px; border-radius: 28px;
  font-size: 14px; font-weight: 600;
  opacity: 0; transition: opacity .2s, transform .2s; z-index: 2000;
  white-space: nowrap; max-width: 88vw;
  overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.success { background: linear-gradient(135deg, var(--green-dark), var(--green)); }
.toast.error   { background: var(--red); }

/* ── PRODUCT INFO BOX ─────────────────────────────────────────────── */
.product-info-box {
  background: var(--green-light); border-radius: var(--r-sm);
  border: 1.5px solid rgba(24,89,89,.15);
  padding: 13px; margin-bottom: 14px;
  font-size: 13px; color: var(--green-dark); line-height: 1.6;
  font-weight: 500;
}

/* ── OBRA SELECTOR ───────────────────────────────────────────────────── */
.obra-selector {
  padding: 8px 16px 4px;
  display: flex; align-items: center; gap: 10px;
}
.obra-selector label { font-size: 12px; color: var(--gray-500); font-weight: 600; white-space: nowrap; }
.obra-selector select {
  flex: 1; padding: 8px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r-sm);
  font-size: 13px; color: var(--gray-900);
  background: white; outline: none;
  -webkit-appearance: none;
}
.obra-selector select:focus { border-color: var(--green); }

/* ── INTRANET TABS ─────────────────────────────────────────────────── */
.intranet-tab {
  padding: 8px 14px;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.65);
  border-radius: 99px;
  white-space: nowrap;
  position: relative;
  transition: all .2s;
  flex-shrink: 0;
  letter-spacing: .01em;
  backdrop-filter: blur(8px);
}
.intranet-tab:hover {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
}
.intranet-tab.intranet-tab-active {
  background: rgba(255,255,255,0.22);
  color: white;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

/* ── INTRANET SECTION CARDS ────────────────────────────────────────── */
.int-section-header {
  padding: 16px 16px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.int-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.int-card {
  background: white;
  border-radius: 14px;
  margin: 8px 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  border: 1px solid var(--gray-100);
  overflow: hidden;
  transition: box-shadow .15s, transform .15s;
}
.int-card:active { transform: scale(.98); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.int-card-body { padding: 14px 16px; }
.int-card-title { font-size: 15px; font-weight: 700; color: var(--gray-900); margin-bottom: 4px; }
.int-card-sub { font-size: 12px; color: var(--gray-400); }
.int-card-amount { font-size: 18px; font-weight: 800; color: var(--gray-900); }

/* Barra lateral de estado en cotizaciones */
.cot-row-bar {
  width: 4px;
  border-radius: 4px;
  flex-shrink: 0;
  align-self: stretch;
  min-height: 32px;
}

/* Progress bar de obras */
.obra-progress-track {
  height: 6px;
  background: var(--gray-100);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}
.obra-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #185959, #2e9e9e);
  transition: width .6s ease;
}

/* Avatar personal */
.personal-avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
  margin-bottom: 8px;
}

/* Tabla intranet */
.int-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.int-table thead tr { background: #f8fafc; border-bottom: 2px solid var(--gray-200); }
.int-table th {
  padding: 10px 8px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.int-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background .1s;
}
.int-table tbody tr:hover { background: #f8fafc; }
.int-table td { padding: 11px 8px; vertical-align: middle; }

/* ── RESPONSIVE — TABLET (≥600px) ──────────────────────────────────── */
@media (min-width: 600px) {
  .main-content { max-width: 600px; margin: 0 auto; }
  #screen-app { background: #f0f4f4; }
  .topbar { max-width: 600px; left: 50%; transform: translateX(-50%); border-radius: 0 0 14px 14px; }
  .bottom-nav { max-width: 600px; left: 50%; transform: translateX(-50%); border-radius: 16px 16px 0 0; }
  .modal { max-width: 560px; left: 50%; transform: translateX(-50%) translateY(100%); border-radius: 20px 20px 0 0; }
  .modal.open { transform: translateX(-50%) translateY(0); }
  .fab { right: calc(50% - 284px); bottom: calc(env(safe-area-inset-bottom, 0px) + 76px); }
  .list-item { border-radius: 12px; margin: 0 2px; }
  .sync-bar { max-width: 600px; left: 50%; transform: translateX(-50%); }
}

/* ── RESPONSIVE — DESKTOP (≥900px) ─────────────────────────────────── */
@media (min-width: 900px) {
  body { overflow: hidden; }

  /* ── LAYOUT PRINCIPAL: sidebar | contenido ── */
  #screen-app {
    flex-direction: row !important;
    height: 100vh; height: 100dvh;
    background: #edf1f1;
  }

  /* ── SIDEBAR ── */
  #sidebar {
    display: flex !important;
    width: 220px;
    order: 0; /* reset */
    min-width: 220px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #0c3535 0%, #185959 60%, #1a6565 100%);
    box-shadow: 2px 0 16px rgba(0,0,0,0.18);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
  }

  /* Topbar dentro del sidebar: solo el header de marca */
  #sidebar .topbar {
    position: relative !important;
    top: auto !important; left: auto !important; transform: none !important;
    background: transparent !important;
    padding: 20px 18px 16px !important;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    box-shadow: none !important;
    border-radius: 0 !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    overflow: visible !important;
  }
  #sidebar .topbar::before,
  #sidebar .topbar::after { display: none !important; }
  #sidebar .topbar-left {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px;
    width: 100%;
  }
  #sidebar .topbar-left img { height: 32px !important; margin-bottom: 4px; }
  #sidebar .page-title { font-size: 17px !important; }
  #sidebar .page-sub   { font-size: 11px !important; }
  #sidebar .topbar-right {
    position: static !important;
    width: auto !important;
    margin-top: 10px;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    gap: 4px;
    justify-content: flex-start !important;
  }
  #sync-live-badge { display: inline-block !important; font-size: 10px !important; }
  #sync-bar { display: none !important; }

  /* Nav lateral dentro del sidebar */
  #sidebar .bottom-nav {
    position: static !important;
    transform: none !important;
    flex: 1;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    padding: 10px 10px !important;
    gap: 2px;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    overflow-y: auto;
  }
  #sidebar .nav-item {
    flex-direction: row !important;
    justify-content: flex-start !important;
    gap: 12px !important;
    padding: 11px 14px !important;
    border-radius: 10px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: rgba(255,255,255,0.65) !important;
    background: transparent !important;
    border: none !important;
    flex: none !important;
    cursor: pointer;
    transition: background .15s, color .15s;
    text-align: left;
  }
  #sidebar .nav-item:hover {
    background: rgba(255,255,255,0.1) !important;
    color: rgba(255,255,255,0.9) !important;
  }
  #sidebar .nav-item.active {
    background: rgba(255,255,255,0.16) !important;
    color: white !important;
    font-weight: 700 !important;
  }
  #sidebar .nav-item svg { width: 18px !important; height: 18px !important; flex-shrink: 0; }
  #sidebar .nav-item span { font-size: 13px !important; display: block !important; }

  /* ── CONTENIDO PRINCIPAL ── */
  .main-content {
    flex: 1 !important;
    order: 0 !important; /* reset */
    height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding-bottom: 20px !important;
    background: #f4f6f6 !important;
    max-width: none !important;
    margin: 0 !important;
  }

  /* El topbar del móvil está dentro del sidebar en desktop, no se muestra como barra */

  /* ── FAB ── */
  .fab {
    position: fixed !important;
    right: 28px !important;
    bottom: 28px !important;
  }

  /* ── MODAL centrado en el área de contenido ── */
  .modal {
    left: calc(220px + (100vw - 220px) / 2) !important;
    transform: translateX(-50%) translateY(100%) !important;
    max-width: 520px !important;
    border-radius: 20px !important;
    max-height: 88vh !important;
    overflow-y: auto;
  }
  .modal.open {
    transform: translateX(-50%) translateY(-50%) !important;
    top: 50% !important;
  }
  .modal-overlay.open { background: rgba(0,0,0,0.3) !important; }

  /* ── LISTAS en 2 columnas ── */
  #bodega-list, #caja-list, #ctrl-list {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px;
  }
  .list-item { margin: 0 !important; }

  /* Balance bar más compacta */
  .balance-bar { padding: 14px 20px; }
  .bal-amount { font-size: 20px; }
}

/* ── PRINT ─────────────────────────────────────────────────────────── */
@media print {
  .topbar, .bottom-nav, .fab, .filter-chips, .print-btn,
  .modal-overlay, .toast, .sync-bar { display: none !important; }
  body { background: white !important; }
  .main-content { padding-bottom: 0 !important; overflow: visible !important; }
  .page { display: block !important; }
  #page-home, #page-bodega, #page-boletas, #page-intranet { display: none !important; }
  .list-item { break-inside: avoid; box-shadow: none !important; border: 1px solid #ddd !important; }
}
