/* ===================================================================
   INGEPRO · Control de Obra — hoja de estilos
   Paleta y tipografías derivadas del ADN de Marca INGEPRO.
   =================================================================== */

:root {
  /* — Paleta de marca — */
  --navy:       #0D3B65;
  --navy-ink:   #0B2240;
  --emerald:    #2FAE92;
  --mint:       #4DB89E;
  --mint-soft:  #84CFD6;
  --sand:       #E9E5D6;
  --sand-deep:  #DED8C5;
  --paper:      #F6F8F8;
  --ivory:      #ECE4D0;
  --slate:      #8896A1;
  --ink:        #18222C;
  --ink-muted:  #5C6873;
  --line-light: rgba(13, 59, 101, .14);
  --line-dark:  rgba(255, 255, 255, .12);
  --danger:     #B5524B;
  --danger-soft:#F3E2E0;
  --warn:       #C9921F;

  /* — Tipografía — */
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans:  "Inter", system-ui, -apple-system, sans-serif;

  /* — Layout — */
  --maxw: 1180px;
  --sidebar-w: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(11,34,64,.06), 0 8px 24px rgba(11,34,64,.08);
  --shadow-sm: 0 1px 2px rgba(11,34,64,.08);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--navy-ink); margin: 0; letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--ink-muted); font-size: .9em; }
[hidden] { display: none !important; }

/* — Wordmark INGEPRO — */
.brand-mark {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: .14em;
  font-size: 1.5rem;
  color: var(--navy-ink);
  display: inline-block;
}
.brand-mark.sm { font-size: 1.15rem; color: #fff; }
.brand-sub { display: block; font-size: .72rem; letter-spacing: .04em; color: var(--ink-muted); text-transform: none; }
.brand-sub.sm { color: var(--mint-soft); }

/* ============================ BOTONES ============================ */
.btn {
  font-family: var(--sans);
  font-weight: 600; font-size: .9rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .6em 1.1em; cursor: pointer;
  transition: transform .15s var(--ease), background .15s var(--ease), box-shadow .15s var(--ease);
  display: inline-flex; align-items: center; gap: .5em;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-ink); box-shadow: var(--shadow-sm); }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line-light); }
.btn-ghost:hover { background: var(--sand); }
.btn-sm { padding: .45em .85em; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; margin-top: .4rem; }
.icon-btn { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--navy); padding: .25em .5em; border-radius: 6px; }
.icon-btn:hover { background: var(--sand); }

/* ============================ LOGIN ============================ */
.login-screen {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  position: relative; padding: 24px; overflow: hidden;
}
.login-bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(77,184,158,.22), transparent 60%),
    radial-gradient(700px 500px at 10% 110%, rgba(132,207,214,.16), transparent 55%),
    linear-gradient(160deg, var(--navy-ink), var(--navy) 70%);
}
.login-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: radial-gradient(circle at 70% 30%, #000, transparent 75%);
}
.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 400px;
  background: var(--paper); border-radius: 16px; padding: 34px 32px;
  box-shadow: 0 30px 80px rgba(5,18,36,.5); animation: rise .5s var(--ease);
}
.login-card .brand { margin-bottom: 18px; }
.login-card .brand-mark { font-size: 1.7rem; }
.login-title { font-size: 1.2rem; margin-top: 14px; }
.login-project { color: var(--emerald); font-weight: 600; font-size: .9rem; margin: 2px 0 18px; letter-spacing: .02em; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .8rem; font-weight: 600; color: var(--ink-muted); margin-bottom: 5px; }
.field > span em { font-weight: 400; color: var(--slate); }
.field input, .field select {
  width: 100%; padding: .65em .8em; font-family: var(--sans); font-size: .95rem;
  border: 1px solid var(--line-light); border-radius: var(--radius-sm); background: #fff; color: var(--ink);
  transition: border .15s var(--ease), box-shadow .15s var(--ease);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--mint); box-shadow: 0 0 0 3px rgba(77,184,158,.18); }
.login-error { color: var(--danger); font-size: .85rem; margin: 10px 0 0; font-weight: 600; }
.login-hint { margin-top: 18px; font-size: .8rem; color: var(--ink-muted); }
.login-hint summary { cursor: pointer; font-weight: 600; }
.login-hint ul { margin: 8px 0 0; padding-left: 18px; }
.login-hint code { background: var(--sand); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.login-foot { position: relative; z-index: 1; color: rgba(255,255,255,.6); font-size: .75rem; margin-top: 22px; }

/* ============================ APP SHELL ============================ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--navy-ink); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { padding: 22px 22px 16px; border-bottom: 1px solid var(--line-dark); }
.nav { display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: .7em .9em; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.78); font-weight: 500; font-size: .92rem; transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item .ic { width: 1.1em; text-align: center; opacity: .8; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.is-active { background: var(--navy); color: #fff; }
.nav-item.is-active .ic { color: var(--mint); opacity: 1; }
.sidebar-foot { padding: 14px 22px; border-top: 1px solid var(--line-dark); font-size: .78rem; color: rgba(255,255,255,.6); display: flex; align-items: center; gap: 8px; }
.sidebar-foot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 3px rgba(77,184,158,.25); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 14px 26px;
  background: #fff; border-bottom: 1px solid var(--line-light); position: sticky; top: 0; z-index: 20;
}
.topbar-project { display: flex; flex-direction: column; }
.tp-title { font-family: var(--serif); font-weight: 600; color: var(--navy-ink); font-size: 1.05rem; }
.tp-sub { font-size: .76rem; color: var(--ink-muted); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.user-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.user-name { font-weight: 600; font-size: .9rem; }

.views { padding: 26px; max-width: var(--maxw); width: 100%; margin: 0 auto; flex: 1; }
.view { animation: fade .35s var(--ease); }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.view-head h2 { font-size: 1.5rem; }
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title { font-size: 1.05rem; margin: 26px 0 14px; color: var(--navy); }

/* ============================ STAT CARDS ============================ */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat-card {
  background: #fff; border: 1px solid var(--line-light); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--mint)); }
.stat-label { font-size: .78rem; color: var(--ink-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-family: var(--serif); font-size: 2rem; font-weight: 600; color: var(--navy-ink); margin: 6px 0 2px; }
.stat-foot { font-size: .8rem; color: var(--slate); }

/* ============================ MODULES GRID ============================ */
.modules-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.module-card {
  background: #fff; border: 1px solid var(--line-light); border-radius: var(--radius); padding: 20px;
  cursor: pointer; transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease); box-shadow: var(--shadow-sm);
}
.module-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--mint); }
.module-card .mc-ic { font-size: 1.5rem; color: var(--emerald); }
.module-card h4 { font-family: var(--serif); font-weight: 600; margin: 10px 0 4px; color: var(--navy-ink); font-size: 1.05rem; }
.module-card p { margin: 0; font-size: .84rem; color: var(--ink-muted); }

/* ============================ CARDS GRID (cert. mensuales) ============================ */
.cards-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.cert-card { background: #fff; border: 1px solid var(--line-light); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.cert-card .cc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.cert-card .cc-period { font-family: var(--serif); font-size: 1.1rem; color: var(--navy-ink); font-weight: 600; }
.cert-card .cc-monto { font-size: 1.4rem; font-family: var(--serif); color: var(--navy); margin: 6px 0; }
.cert-card .cc-row { display: flex; justify-content: space-between; font-size: .85rem; color: var(--ink-muted); margin-top: 4px; }
.cert-card .cc-actions { margin-top: 14px; display: flex; gap: 8px; }

/* ============================ TABLES ============================ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line-light); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 640px; }
.table thead th { background: #EEF2F4; color: var(--navy); text-align: left; font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; padding: 12px 14px; border-bottom: 1px solid var(--line-light); white-space: nowrap; }
.table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line-light); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--paper); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============================ BADGES ============================ */
.badge { display: inline-block; padding: .2em .65em; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.badge-role { background: var(--navy); color: #fff; letter-spacing: .03em; }
.badge.is-ok       { background: rgba(47,174,146,.16);  color: #1d7a64; }   /* aprobado / finalizado / pagado */
.badge.is-progress { background: rgba(132,207,214,.28); color: #14627a; }   /* en ejecución / presentado / seguimiento */
.badge.is-pending  { background: var(--sand-deep);      color: #6c5f3e; }   /* pendiente / en preparación */
.badge.is-warn     { background: rgba(201,146,31,.18);  color: #8a6411; }   /* observado / media */
.badge.is-danger   { background: var(--danger-soft);    color: var(--danger); } /* alta / abierta */
.badge.is-neutral  { background: #E7EBEE;               color: var(--ink-muted); }

/* ============================ PROGRESS ============================ */
.progress { background: var(--sand); border-radius: 999px; height: 8px; width: 100%; min-width: 90px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--emerald)); border-radius: 999px; transition: width .6s var(--ease); }
.progress-label { display: flex; align-items: center; gap: 8px; }
.progress-label small { font-variant-numeric: tabular-nums; color: var(--ink-muted); font-weight: 600; min-width: 34px; }

/* ============================ MINI-GANTT ============================ */
.gantt-col { min-width: 200px; }
.gantt-track { position: relative; height: 18px; background: var(--paper); border-radius: 5px; border: 1px solid var(--line-light); }
.gantt-bar { position: absolute; top: 2px; bottom: 2px; border-radius: 4px; background: var(--mint-soft); }
.gantt-bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: linear-gradient(90deg, var(--emerald), var(--mint)); }

/* ============================ TOOLBAR / SEGMENT ============================ */
.toolbar { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.inline-field { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; color: var(--ink-muted); font-weight: 600; }
.inline-field input, .inline-field select { padding: .45em .6em; border: 1px solid var(--line-light); border-radius: var(--radius-sm); font-family: var(--sans); font-size: .88rem; background: #fff; color: var(--ink); }
.seg { display: inline-flex; background: var(--sand); border-radius: var(--radius-sm); padding: 3px; }
.seg-btn { border: none; background: none; padding: .45em 1em; border-radius: 6px; font-family: var(--sans); font-weight: 600; font-size: .85rem; color: var(--ink-muted); cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease); }
.seg-btn.is-active { background: #fff; color: var(--navy); box-shadow: var(--shadow-sm); }

/* Navegación de período (◀ fecha ▶ etiqueta) en informes */
.period-nav { display: inline-flex; align-items: center; gap: 8px; }
.period-nav input[type="date"] { padding: .4em .55em; border: 1px solid var(--line-light); border-radius: var(--radius-sm); font-family: var(--sans); font-size: .85rem; background: #fff; color: var(--ink); }
.period-label { font-family: var(--sans); font-weight: 600; font-size: .85rem; color: var(--navy); margin-left: 4px; }
.nota-acciones { margin-left: auto; display: inline-flex; gap: 6px; }
.monto-edit { padding: .35em .5em; border: 1px solid var(--line-light); border-radius: var(--radius-sm); font-family: var(--sans); font-size: .85rem; text-align: right; }

/* ============================ FOTO GRID ============================ */
.foto-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.foto-cell { background: #fff; border: 1px solid var(--line-light); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow-sm); }
.foto-cell .ph { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--sand); }
.foto-cell .ph-fallback { width: 100%; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; color: var(--slate); font-size: .8rem; background: repeating-linear-gradient(45deg, var(--sand), var(--sand) 10px, var(--sand-deep) 10px, var(--sand-deep) 20px); }
.foto-cell figcaption { padding: 8px 10px; font-size: .76rem; color: var(--ink-muted); line-height: 1.35; }

/* ============================ NOTAS ============================ */
.notas-list { display: flex; flex-direction: column; gap: 12px; }
.nota-card { background: #fff; border: 1px solid var(--line-light); border-left: 4px solid var(--slate); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.nota-card.prio-alta { border-left-color: var(--danger); }
.nota-card.prio-media { border-left-color: var(--warn); }
.nota-card.prio-baja { border-left-color: var(--mint); }
.nota-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.nota-cat { font-weight: 600; color: var(--navy-ink); }
.nota-meta { font-size: .78rem; color: var(--slate); margin-left: auto; }
.nota-desc { font-size: .9rem; color: var(--ink); }

/* ============================ MODAL / TOAST ============================ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(11,34,64,.5); animation: fade .2s var(--ease); }
.modal-card { background: var(--paper); border-radius: 14px; width: 100%; max-width: 460px; box-shadow: 0 30px 80px rgba(5,18,36,.4); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line-light); }
.modal-head h3 { font-size: 1.1rem; }
.modal-body { padding: 20px; }
.modal-body .field:last-of-type { margin-bottom: 0; }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--navy-ink); color: #fff; padding: .8em 1.3em; border-radius: 999px; font-size: .88rem; font-weight: 500; box-shadow: var(--shadow); z-index: 120; animation: rise .3s var(--ease); }

/* ============================ MOBILE ============================ */
.only-mobile { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(11,34,64,.45); z-index: 30; }
.bottom-nav { display: none; }

@media (max-width: 900px) {
  .only-mobile { display: inline-flex; }
  .stats-grid, .modules-grid { grid-template-columns: repeat(2, 1fr); }
  .cards-grid { grid-template-columns: 1fr; }
  .foto-grid { grid-template-columns: repeat(2, 1fr); }

  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 40; height: 100vh;
    transform: translateX(-100%); transition: transform .28s var(--ease); box-shadow: 0 0 60px rgba(5,18,36,.5);
  }
  .sidebar.open { transform: translateX(0); }

  .topbar-user .user-meta { display: none; }
  .views { padding: 18px 16px 84px; }
  .view-head h2 { font-size: 1.3rem; }

  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 35;
    background: #fff; border-top: 1px solid var(--line-light); justify-content: space-around; padding: 6px 4px;
  }
  .bn-item { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 1.1rem; color: var(--ink-muted); padding: 4px 8px; border-radius: 8px; }
  .bn-item span { font-size: .62rem; font-weight: 600; }
  .bn-item.is-active { color: var(--navy); background: var(--sand); }
}

@media (max-width: 560px) {
  .stats-grid, .modules-grid { grid-template-columns: 1fr; }
  .foto-grid { grid-template-columns: 1fr; }
}

/* ============================ CURVA S ================================ */
.chart-card { background:#fff; border:1px solid var(--line-light); border-radius:var(--radius); padding:18px 18px 8px; box-shadow:var(--shadow-sm); }
.curva-s-svg { width:100%; height:auto; display:block; }

/* ============================ GANTT INTERACTIVO ====================== */
.gantt-row { cursor:pointer; }
.gantt-row:hover { background:var(--ivory) !important; }
.gantt-tooltip {
  position:fixed; z-index:200; background:var(--navy-ink); color:#fff;
  padding:.45em .8em; border-radius:8px; font-size:.8rem; pointer-events:none;
  box-shadow:var(--shadow); white-space:nowrap;
}

/* ============================ TOAST ERROR ============================ */
.toast-error { background:var(--danger) !important; }

/* ============================ SELECT INLINE ========================== */
select.btn { padding: .35em .7em; }

/* ============================ OVERLAY DE CARGA ======================= */
#loading-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(5,18,36,.55); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
}
#loading-overlay[hidden] { display: none; }
.loading-box {
  background: #fff; border-radius: var(--radius); padding: 28px 34px;
  box-shadow: var(--shadow); text-align: center; max-width: 320px;
}
.loading-box p { margin: 16px 0 0; font-size: .92rem; color: var(--ink); }
.spinner {
  width: 42px; height: 42px; margin: 0 auto;
  border: 4px solid var(--line-light); border-top-color: var(--emerald);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================ ANIMACIONES ============================ */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
