/* ============================================================
   DANGOFE — Estilos (tema verde menta / oscuro)
   ============================================================ */
:root {
  --bg:        #DCFCE7;
  --surface:   #FFFFFF;
  --surface2:  #E2E8F0;
  --border:    #DDE3EA;
  --primary:   #0B161E;
  --secondary: #51625C;
  --accent:    #A6B9BE;
  --text:      #1A2630;
  --text-muted:#6B7A8D;
  --green:     #1A6636;
  --red:       #B52020;
  --blue:      #1A4D80;
  --warn:      #7A4A00;
  --mint:      #5EE9B5;
  --mint2:     #3DD4A0;
  --radius:    14px;
  --shadow:    0 6px 20px rgba(11,22,30,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--blue); }
.hidden { display: none !important; }

/* ---------- LOGIN ---------- */
/* Contenedor del video de fondo */
.login-video-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}

body.login-page::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(13, 27, 42, 0.75); /* Overlay oscuro */
  z-index: -1;
}

.login-container {
  position: relative;
  z-index: 1;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

}
/* Overlay oscuro semitransparente para mantener la legibilidad del formulario */
#login-view::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(8,20,30,.72), rgba(11,22,30,.82));
  z-index: 1;
}
.login-card {
  position: relative; z-index: 2;
  width: 380px; max-width: 92vw;
  padding: 38px 34px;
  border-radius: 20px;
  background: rgba(40, 60, 52, .55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  color: #fff;
}
.login-logo { text-align: center; font-size: 38px; font-weight: 700; letter-spacing: 4px; }
.login-title { text-align: center; font-size: 15px; font-weight: 700; letter-spacing: 2px; margin-top: 8px; }
.login-sub { text-align: center; font-size: 12px; color: #cdeede; margin-top: 2px; }
.login-divider { height: 3px; width: 60%; margin: 16px auto 22px;
  background: linear-gradient(90deg, var(--mint), transparent); border-radius: 3px; }
.login-card label { display:block; font-size: 11px; font-weight: 700; letter-spacing: 1px; margin: 14px 0 6px; color:#d5f5e8; }
.login-card input[type=email], .login-card input[type=password] {
  width: 100%; padding: 13px 14px; border-radius: 10px; border: none;
  background: rgba(20,40,60,.6); color: #fff; font-size: 14px;
}
.login-card input::placeholder { color: #9bb3ab; }
.login-remember { display:flex; align-items:center; gap:8px; margin: 16px 0; font-size: 12px; color:#d5f5e8; }
.btn-login {
  width: 100%; padding: 14px; border: none; border-radius: 10px; cursor: pointer;
  background: linear-gradient(90deg, var(--mint), var(--mint2));
  color: #0B161E; font-weight: 700; font-size: 14px; letter-spacing: 1px;
  transition: transform .1s, filter .2s;
}
.btn-login:hover { filter: brightness(1.05); }
.btn-login:active { transform: scale(.99); }
.btn-login:disabled { opacity:.6; cursor: wait; }
.login-error { color: #ffb4b4; font-size: 13px; margin-top: 12px; text-align:center; min-height: 18px; }

/* ---------- HEADER ---------- */
header.app-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 60px;
}
.brand { font-weight: 700; letter-spacing: 2px; text-transform: uppercase; font-size: 16px; }
.brand span { color: var(--mint); }
.header-spacer { flex: 1; }
.role-badge {
  background: var(--mint); color: var(--primary); font-weight: 700;
  font-size: 11px; padding: 4px 10px; border-radius: 20px; text-transform: uppercase;
}
.header-btn {
  background: transparent; border: 1px solid rgba(255,255,255,.25); color: #fff;
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.header-btn:hover { background: rgba(255,255,255,.1); }

/* ---------- NAV TABS ---------- */
nav.tabs {
  background: var(--primary); display: flex; gap: 4px; padding: 0 20px;
  overflow-x: auto; border-bottom: 1px solid rgba(255,255,255,.08);
  position: sticky; top: 52px; z-index: 49;
}
nav.tabs button {
  background: transparent; border: none; color: #b7c4cc; cursor: pointer;
  padding: 12px 16px; font-size: 14px; font-weight: 600; white-space: nowrap;
  border-bottom: 3px solid transparent;
}
nav.tabs button:hover { color: #fff; }
nav.tabs button.active { color: var(--mint); border-bottom-color: var(--mint); }

/* ---------- LAYOUT ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.view { display: none; }
.view.active { display: block; animation: fade .2s; }
@keyframes fade { from {opacity:0; transform: translateY(4px);} to {opacity:1;} }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card h2 { font-size: 18px; color: var(--primary); margin-bottom: 4px; }
.card .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--primary); margin: 18px 0 10px;
  padding-bottom: 6px; border-bottom: 2px solid var(--surface2); }

/* ---------- FORM ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; }
.field.full { grid-column: 1 / -1; }
label.lbl { font-size: 12px; font-weight: 700; color: var(--secondary); margin-bottom: 6px; }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--mint2); border-color: var(--mint2); }
textarea { resize: vertical; min-height: 70px; }

.btn {
  border: none; border-radius: 9px; padding: 11px 18px; cursor: pointer;
  font-weight: 700; font-size: 14px; transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: linear-gradient(90deg, var(--mint), var(--mint2)); color: var(--primary); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn:disabled { opacity:.6; cursor: wait; }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ---------- TABLES ---------- */
.toolbar { display:flex; gap:10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.scroll-table { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 540px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface2); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--secondary); }
tbody tr:hover { background: #f5faf7; }
.badge { display:inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge.green { background: #d6f3e1; color: var(--green); }
.badge.red { background: #fbdada; color: var(--red); }
.badge.blue { background: #d8e6f5; color: var(--blue); }
.badge.warn { background: #f6e9cf; color: var(--warn); }

.pagination { display:flex; gap:6px; align-items:center; justify-content:center; margin-top:16px; }
.pagination button { padding: 6px 12px; border: 1px solid var(--border); background:#fff; border-radius: 7px; cursor: pointer; }
.pagination button:disabled { opacity:.4; cursor: default; }

/* ---------- SUB-TABS ---------- */
.subtabs { display:flex; gap: 4px; border-bottom: 2px solid var(--surface2); margin-bottom: 16px; flex-wrap: wrap; }
.subtabs button { background:transparent; border:none; padding:10px 14px; cursor:pointer; font-weight:600;
  color: var(--text-muted); border-bottom: 3px solid transparent; margin-bottom:-2px; }
.subtabs button.active { color: var(--primary); border-bottom-color: var(--mint2); }

/* ---------- TAGS / multiselect ---------- */
.tags { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.tag { background: var(--surface2); border-radius: 20px; padding: 4px 10px; font-size: 13px; display:flex; gap:6px; align-items:center; }
.tag button { background:none; border:none; cursor:pointer; color: var(--red); font-weight:700; font-size: 14px; }

.svc-row { display:grid; grid-template-columns: 2fr 80px 110px auto; gap:8px; align-items:end; margin-bottom:8px; }

/* ---------- TOTALS / cálculos ---------- */
.calc-box { background: #f0fbf5; border: 1px dashed var(--mint2); border-radius: 10px; padding: 14px; margin-top: 14px; }
.calc-row { display:flex; justify-content: space-between; padding: 4px 0; font-size: 14px; }
.calc-row.total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; color: var(--primary); }

/* ---------- MODAL ---------- */
.overlay { position: fixed; inset: 0; background: rgba(11,22,30,.55); display:flex; align-items:center; justify-content:center; z-index: 100; padding: 16px; }
.modal { background:#fff; border-radius: 16px; padding: 24px; width: 480px; max-width: 95vw; max-height: 90vh; overflow:auto; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.modal h3 { color: var(--primary); margin-bottom: 14px; }

/* ---------- TOAST ---------- */
#toasts { position: fixed; top: 18px; right: 18px; z-index: 200; display:flex; flex-direction: column; gap: 10px; }
.toast { background: var(--primary); color:#fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: slidein .2s; max-width: 320px; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes slidein { from { transform: translateX(40px); opacity:0; } to {transform: none; opacity:1;} }

/* ---------- LOADING ---------- */
.spinner { display:inline-block; width:16px; height:16px; border:2px solid rgba(255,255,255,.4); border-top-color:#fff; border-radius:50%; animation: spin .7s linear infinite; vertical-align:middle; }
.loading-row { text-align:center; padding: 24px; color: var(--text-muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 720px) {
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .svc-row { grid-template-columns: 1fr 1fr; }
  .brand { font-size: 13px; }
  main { padding: 14px 10px 50px; }
}


/* ============================================================
   COMPONENTES v3.0 — Autocomplete, Arqueo, Sub-filas, Gráficos
   ============================================================ */

/* ---------- Autocomplete ---------- */
.ac { position: relative; }
.ac-input { width: 100%; }
.ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); margin-top: 4px;
  max-height: 240px; overflow-y: auto;
}
.ac-item { padding: 9px 12px; cursor: pointer; font-size: 14px; border-bottom: 1px solid var(--surface2); }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active { background: var(--bg); color: var(--green); }

/* ---------- Novedades ---------- */
.proy-info {
  margin-top: 10px; padding: 10px 14px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border); font-size: 14px;
}
.nov-sec { margin-top: 16px; }

/* ---------- Registro: filas expandibles ---------- */
.proy-row { cursor: pointer; }
.proy-row:hover { background: var(--bg); }
.expander { font-weight: 700; color: var(--mint2); width: 24px; text-align: center; }
.proy-sub td { background: var(--bg); }
.sub-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 18px;
  font-size: 13px; padding: 6px 0;
}
.sub-grid .lbl { font-weight: 700; color: var(--secondary); }

/* ---------- Arqueo de Caja ---------- */
.arqueo-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 16px 0; }
.arqueo-pill {
  border-radius: var(--radius); padding: 16px 18px; color: #fff;
  box-shadow: var(--shadow);
}
.arqueo-pill .sub { color: rgba(255,255,255,.85); font-size: 12px; font-weight: 600; }
.arqueo-pill .amt { font-size: 24px; font-weight: 700; margin-top: 4px; }
.arqueo-pill.ingreso { background: linear-gradient(135deg, #1A6636, #2bb673); }
.arqueo-pill.egreso  { background: linear-gradient(135deg, #B52020, #d65555); }
.arqueo-pill.balance { background: linear-gradient(135deg, #0B161E, #1A4D80); }
.aviso {
  background: #d6f3e1; color: var(--green); padding: 10px 14px;
  border-radius: 10px; font-weight: 600; margin: 10px 0;
}

/* ---------- Gráficos ---------- */
.charts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin-top: 18px; }
.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.chart-card h4 { font-size: 14px; margin-bottom: 12px; color: var(--primary); }
.chart-card canvas { max-height: 320px; }
/* Caja con altura fija para todas las gráficas (responsive) */
.chart-box { position: relative; height: 300px; }
.chart-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #8aa0a0; font-size: 13px; text-align: center; padding: 20px; }
.chart-box.chart-scroll { overflow-y: auto; }
.chart-box.chart-scroll canvas { max-height: none; }
/* Gráficas que ocupan las dos columnas */
.chart-wide { grid-column: 1 / -1; }
.chart-wide .chart-box { height: 360px; }

/* ---------- Card destacada ITBIS / DGII ---------- */
.itbis-card {
  display: flex; align-items: center; gap: 18px;
  margin-top: 18px; padding: 22px 24px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--green) 0%, #0e4f2b 100%);
  color: #fff; box-shadow: var(--shadow);
}
.itbis-icon { font-size: 46px; line-height: 1; }
.itbis-label { font-size: 13px; letter-spacing: .5px; opacity: .9; text-transform: uppercase; }
.itbis-monto { font-size: 34px; font-weight: 700; margin: 4px 0; }
.itbis-sub { font-size: 12px; opacity: .85; max-width: 640px; }

/* ---------- Zona de Peligro (Admin) ---------- */
.danger-zone {
  margin-top: 22px;
  border: 1px solid #e7a3a3;
  background: #fdeaea;
}
.danger-zone h2 { color: var(--red); }
.danger-text { color: #7a1414; font-size: 14px; margin: 8px 0 16px; line-height: 1.55; }
.danger-zone #reset-confirm {
  width: 100%; padding: 11px 12px; border-radius: 10px;
  border: 1px solid #e7a3a3; background: #fff; font-size: 15px; letter-spacing: 2px; font-weight: 700;
}
.danger-zone .btn-danger { margin-top: 14px; font-weight: 700; letter-spacing: 1px; }
.danger-zone .btn-danger:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 860px) {
  .charts-grid { grid-template-columns: 1fr; }
  .chart-wide { grid-column: auto; }
  .itbis-card { flex-direction: column; text-align: center; }
  .arqueo-bar { grid-template-columns: 1fr; }
  .sub-grid { grid-template-columns: 1fr 1fr; }
}



/* ===== v3.0.1 — Registro completo + modal de detalle ===== */
.muted { color: #94a3a0; }

/* Columna de técnicos: limita ancho y muestra elipsis (tooltip con title) */
#tabla-proyectos td.col-tecnicos {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#tabla-proyectos td.col-acciones { white-space: nowrap; }
#tabla-proyectos th, #tabla-proyectos td { white-space: nowrap; }

/* Tablas pequeñas dentro del modal Ver */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0 4px;
  font-size: 13px;
}
.mini-table th, .mini-table td {
  border: 1px solid #d6efe0;
  padding: 6px 8px;
  text-align: left;
}
.mini-table thead th {
  background: #ecfdf5;
  color: #0f6b48;
  font-weight: 600;
}
.mini-table tr.mini-total td { background: #f0fdf6; }



/* ---------- Arqueo de Caja (FASE B) ---------- */
.arqueo-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 6px 0 4px; }
.arqueo-col { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); }
.arqueo-col-head {
  padding: 10px 14px; font-weight: 800; letter-spacing: .04em; color: #fff; font-size: 14px;
}
.arqueo-col-head.ingresos { background: linear-gradient(135deg, #1A6636, #2bb673); }
.arqueo-col-head.egresos  { background: linear-gradient(135deg, #B52020, #d65555); }
.arqueo-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.arqueo-table thead th {
  background: #f0fbf5; color: var(--primary); font-weight: 700;
  padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border);
}
.arqueo-table td { padding: 7px 10px; border-bottom: 1px solid #eef4f0; }
.arqueo-table td.cod { font-family: monospace; font-weight: 700; color: var(--secondary); white-space: nowrap; }
.arqueo-table td.num, .arqueo-table th.num { text-align: right; white-space: nowrap; font-weight: 600; }
.arqueo-table tr.mov-ingresos td { background: #f3fcf7; }
.arqueo-table tr.mov-egresos  td { background: #fdf4f4; }

/* Tarjetas de totales */
.totales-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 8px 0 4px; }
.total-card { border-radius: 14px; padding: 18px 20px; color: #fff; box-shadow: var(--shadow); }
.total-card .t-label { font-size: 13px; font-weight: 600; opacity: .9; }
.total-card .t-amt { font-size: 26px; font-weight: 800; margin-top: 6px; }
.total-card.egresos   { background: linear-gradient(135deg, #B52020, #d65555); }
.total-card.ingresos  { background: linear-gradient(135deg, #1A6636, #2bb673); }
.total-card.ganancias { background: linear-gradient(135deg, #0B161E, #1A4D80); }

/* Registro histórico de cierres */
.cierre-card {
  border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  margin-bottom: 18px; background: var(--surface); box-shadow: var(--shadow);
}
.cierre-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.cierre-acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.cierre-totales {
  display: flex; justify-content: flex-end; gap: 26px; flex-wrap: wrap;
  background: var(--primary); color: #fff; border-radius: 10px;
  padding: 12px 18px; margin-top: 12px; font-size: 14px;
}
.cierre-totales strong { color: var(--mint); margin-left: 4px; }

@media (max-width: 760px) {
  .arqueo-cols { grid-template-columns: 1fr; }
  .totales-cards { grid-template-columns: 1fr; }
  .cierre-totales { justify-content: flex-start; gap: 14px; }
}
