/* A&M Tres Compañia LLC — estilos
   Identidad: plano técnico (blueprint) + cobre de tubería.
   Azul acero como color de marca, cobre como acento, cuadrícula sutil de fondo. */
:root {
  --primary: #0e5a8a;
  --primary-dark: #0a3450;
  --accent: #148fb4;
  --copper: #b06a3b;
  --copper-soft: #d9a071;
  --bg: #f2f6f9;
  --surface: #ffffff;
  --text: #16232e;
  --muted: #5b6f7e;
  --border: #d8e2e9;
  --success: #1e8e5a;
  --warning: #b97a0f;
  --danger: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(10, 52, 80, .07), 0 6px 18px rgba(10, 52, 80, .07);
  --shadow-lift: 0 4px 10px rgba(10, 52, 80, .1), 0 14px 34px rgba(10, 52, 80, .12);
  --font-display: "Avenir Next Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --font-body: "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, monospace;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  background-image:
    linear-gradient(rgba(14, 90, 138, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(14, 90, 138, .045) 1px, transparent 1px);
  background-size: 30px 30px;
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: .01em;
  text-wrap: balance;
}

:focus-visible { outline: 3px solid var(--copper-soft); outline-offset: 2px; }

/* ---- Topbar ---- */
.topbar {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  border-bottom: 3px solid var(--copper);
  color: #fff;
  padding: .8rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}
.brand {
  color: #fff;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: .02em;
}
.brand span { font-weight: 500; opacity: .8; }
.topbar nav { display: flex; gap: .25rem; }
.topbar nav a {
  color: #fff;
  text-decoration: none;
  padding: .4rem .85rem;
  border-radius: 7px;
  font-size: .92rem;
  transition: background .12s ease;
}
.topbar nav a:hover { background: rgba(255, 255, 255, .14); }
.topbar nav a.logout { opacity: .75; }

/* ---- Layout ---- */
.container {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 1.4rem 1rem 2.8rem;
}
.page-head { margin-bottom: 1.4rem; }
.page-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
}
.page-head-row .btn { text-decoration: none; }
.page-head h1 { font-size: 1.9rem; margin-bottom: .15rem; line-height: 1.1; }
.muted { color: var(--muted); font-size: .92rem; }
.notes { margin-top: .5rem; font-size: .95rem; }

.breadcrumbs {
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .04em;
  margin-bottom: 1.1rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: baseline;
}
.breadcrumbs a { color: var(--primary); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs span { color: var(--copper); }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 1.15rem;
  margin-bottom: .9rem;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.card h2::before {
  content: "";
  width: 26px;
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--copper-soft), var(--copper));
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, .4);
  flex: none;
}
.card h3 { font-size: 1.15rem; margin-bottom: .3rem; color: var(--primary-dark); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}
.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  margin-bottom: 0;
  border-top: 3px solid var(--primary);
}
.card-link:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-top-color: var(--copper);
}
.stats {
  display: flex;
  gap: .9rem;
  margin-top: .7rem;
  font-size: .84rem;
  color: var(--muted);
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

.progress {
  margin-top: .6rem;
  height: 7px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  border-radius: 4px;
}

/* ---- Forms ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .85rem 1rem;
}
.form-grid .span-2 { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 600; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"],
input[type="email"], select, textarea {
  font: inherit;
  font-weight: 400;
  padding: .58rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  width: 100%;
  transition: border-color .12s ease, box-shadow .12s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 143, 180, .16);
}
textarea { resize: vertical; }

.form-inline {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  align-items: center;
}
.form-inline input[type="text"] { flex: 1; min-width: 200px; width: auto; }
.form-inline input[type="file"] { flex: 1; min-width: 200px; font-size: .88rem; }

/* ---- Buttons ---- */
.btn {
  font: inherit;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: .58rem 1.15rem;
  cursor: pointer;
  transition: background .12s ease, box-shadow .12s ease, transform .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 2px 6px rgba(10, 52, 80, .25);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 3px 10px rgba(10, 52, 80, .3); }
.btn-secondary {
  background: var(--surface);
  color: var(--primary-dark);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn-secondary:hover { border-color: var(--primary); background: #eef4f8; }
.btn-block { width: 100%; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .74rem;
  font-weight: 700;
  padding: .2rem .65rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge-pendiente { background: #fdeeda; color: var(--warning); }
.badge-en_progreso { background: #dcf1f7; color: var(--primary); }
.badge-terminado { background: #ddf2e7; color: var(--success); }

/* ---- Floors / rooms ---- */
.floor-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .6rem;
  flex-wrap: wrap;
}
.floor-head h2 { margin-bottom: 0; }
.room-list { list-style: none; margin-bottom: .8rem; }
.room-list li + li { border-top: 1px solid var(--border); }
.room-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .6rem .45rem;
  text-decoration: none;
  color: inherit;
  border-radius: 7px;
  border-left: 3px solid transparent;
  transition: background .12s ease, border-color .12s ease;
}
.room-link:hover { background: var(--bg); border-left-color: var(--copper); }
.room-name { font-weight: 500; }

/* ---- Photos ---- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .8rem;
  margin-top: 1rem;
}
.photo {
  position: relative;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.photo:hover { transform: scale(1.02); box-shadow: var(--shadow-lift); }
.photo img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}
.btn-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(192, 57, 43, .92);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: .75rem;
  line-height: 1;
}

/* ---- Misc ---- */
.flash {
  background: #ddf2e7;
  color: var(--success);
  border: 1px solid #b9e4cd;
  border-left: 4px solid var(--success);
  padding: .6rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .92rem;
}
.error {
  background: #fbe3e0;
  color: var(--danger);
  border: 1px solid #f3c3bd;
  border-left: 4px solid var(--danger);
  padding: .6rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: .92rem;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 2.8rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ---- Login ---- */
.login-box {
  max-width: 390px;
  margin: 8vh auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--copper);
  border-radius: var(--radius);
  padding: 2.1rem 1.85rem;
  box-shadow: var(--shadow-lift);
}
.login-box h1 { font-size: 1.6rem; color: var(--primary-dark); }
.login-box .muted { margin-bottom: 1.2rem; }
.login-box form { display: flex; flex-direction: column; gap: .9rem; margin-top: .5rem; }

/* ---- Footer ---- */
.footer {
  text-align: center;
  padding: 1.3rem 1rem;
  font-size: .84rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer a { color: var(--primary); }

/* ---- Móvil ---- */
@media (max-width: 560px) {
  .container { padding: 1rem .8rem 2.2rem; }
  .topbar { padding: .65rem .8rem; }
  .brand { font-size: 1.15rem; }
  .topbar nav a { padding: .35rem .6rem; font-size: .88rem; }
  .card { padding: 1rem .95rem; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 1.5rem; }
  .form-inline input[type="text"], .form-inline input[type="file"] { min-width: 100%; }
  .form-inline .btn { width: 100%; }
  .dash-stats { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
  .stat-tile { padding: .8rem .85rem; }
  .stat-num { font-size: 1.6rem; }
  .stat-tile-primary { grid-column: 1 / -1; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .photo img { height: 100px; }
  .login-box { margin-top: 5vh; padding: 1.6rem 1.2rem; }
  .breadcrumbs { font-size: .68rem; }
}

/* ---- Informe imprimible ---- */
.report-body { background: #e7edf2; display: block; padding: 1rem; }
.report-toolbar {
  max-width: 850px;
  margin: 0 auto 1rem;
  display: flex;
  justify-content: space-between;
  gap: .6rem;
  flex-wrap: wrap;
}
.report {
  max-width: 850px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-lift);
  padding: 2.1rem 2.3rem;
}
.report-letterhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  border-bottom: 3px solid var(--primary);
  padding-bottom: 1rem;
  margin-bottom: 1.4rem;
  flex-wrap: wrap;
}
.report-letterhead h1 { font-size: 1.7rem; color: var(--primary-dark); letter-spacing: .01em; }
.report-letterhead p { color: var(--muted); font-size: .92rem; }
.report-meta { text-align: right; font-size: .92rem; }
.report-project h2 { font-size: 1.35rem; margin-bottom: .6rem; }
.report-info { border-collapse: collapse; margin-bottom: 1.4rem; font-size: .92rem; }
.report-info th { text-align: left; padding: .25rem 1.2rem .25rem 0; color: var(--muted); font-weight: 600; vertical-align: top; white-space: nowrap; }
.report-info td { padding: .25rem 0; }
.report-building { margin-bottom: 1.4rem; }
.report-building h3 { font-size: 1.15rem; color: var(--primary-dark); margin-bottom: .5rem; }
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
  font-variant-numeric: tabular-nums;
}
.report-table th, .report-table td {
  border: 1px solid var(--border);
  padding: .4rem .55rem;
  text-align: left;
  vertical-align: top;
}
.report-table thead th { background: #eef4f8; color: var(--primary-dark); font-size: .82rem; }
.report-table tfoot td { background: #f6f9fb; font-weight: 700; }
.report-table .num { text-align: right; white-space: nowrap; }
.report-totals { margin-top: 1.2rem; }
.report-totals th { background: var(--primary); color: #fff; font-size: .92rem; padding: .55rem .7rem; }
.report-footer {
  margin-top: 1.6rem;
  padding-top: .8rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--muted);
  text-align: center;
}

/* Informe en teléfono: tabla desplazable, márgenes compactos */
@media (max-width: 700px) {
  .report-body { padding: .6rem; }
  .report { padding: 1.2rem 1rem; }
  .report-letterhead h1 { font-size: 1.35rem; }
  .report-meta { text-align: left; }
  .report-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .report-toolbar .btn, .toolbar-actions { flex: 1 1 auto; }
  .report-toolbar .btn, .toolbar-actions .btn { text-align: center; flex: 1 1 auto; }
}

@media print {
  .no-print { display: none !important; }
  body { background-image: none; }
  .report-body { background: #fff; padding: 0; }
  .report { max-width: none; border: none; border-radius: 0; box-shadow: none; padding: 0; }
  .report-building { break-inside: avoid; }
  .badge { border: 1px solid currentColor; }
  .badge::before { display: none; }
  a { color: inherit; text-decoration: none; }
}

/* ---- Envío de informe por correo ---- */
.toolbar-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.report-toolbar .btn, .toolbar-actions .btn { text-decoration: none; }
.report-email {
  max-width: 850px;
  margin: 1rem auto 0;
}

/* ---- Fotos antes/después ---- */
.photo-section { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--border); }
.photo-section h3 {
  font-family: var(--font-mono);
  font-size: .76rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--copper);
  margin-bottom: .7rem;
}

/* ---- Dashboard de proyectos ---- */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .8rem;
  margin-bottom: 1.3rem;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .95rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.stat-num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  font-size: .78rem;
  color: var(--muted);
}
.stat-tile-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: var(--primary-dark);
}
.stat-tile-primary .stat-num { color: #fff; }
.stat-tile-primary .stat-label { color: rgba(255, 255, 255, .8); }
.stat-tile-primary .progress { background: rgba(255, 255, 255, .25); margin-top: .35rem; }
.stat-tile-primary .progress-bar { background: linear-gradient(90deg, var(--copper-soft), #fff); }

/* ---- Bloques plegables (editar / crear) ---- */
.edit-toggle summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary);
  list-style: none;
  transition: color .12s ease;
}
.edit-toggle summary:hover { color: var(--copper); }
.edit-toggle summary::-webkit-details-marker { display: none; }
.edit-toggle[open] summary { margin-bottom: 1rem; color: var(--copper); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
