/* CSS System: Modern Glassmorphic Dark Theme with A4 Print Support */

:root {
  /* Brandbook Color System */
  --color-big-stone: #173042;      /* Azul Marino Oscuro Profundo (Principal / Cards) */
  --color-mirage: #14202a;         /* Azul Negro / Gris Oscuro (General Background) */
  --color-racing-green: #070c0b;   /* Verde Bosque Casi Negro (Para texto oscuro extremo) */
  --color-electric-lime: #c8ff00;  /* Verde Lima Eléctrico / Ácido (Neon Accent) */
  --color-wild-sand: #f6f6f6;      /* Gris Claro Neutro (Fondos de inputs / alternos) */
  --color-white: #ffffff;          /* Blanco Puro */

  --bg-app: #f6f6f6; /* Wild Sand */
  --bg-card: #FFFFFF; /* Neutral background card */
  --bg-card-hover: #fafafa;
  --border-color: rgba(23, 48, 66, 0.15); /* Clean border based on Big Stone */
  --border-glow: rgba(200, 255, 0, 0.4); /* Electric Lime Glow */
  
  --primary: #173042; /* Big Stone - Principal */
  --primary-hover: #14202a; /* Mirage */
  --secondary: #54606b; /* Corporate Gray */
  --secondary-hover: #14202a;
  --accent: #c8ff00; /* Electric Lime */
  
  --danger: #ba1a1a;
  --danger-hover: #93000a;
  --success: #10B981;
  --warning: #F59E0B;
  
  --text-primary: #14202a; /* Mirage */
  --text-muted: #54606b; /* Corporate Gray */
  --text-dark: #173042; /* Big Stone */
  
  --font-display: "Arial Nova", "Arial", sans-serif;
  --font-body: "Arial Nova", "Arial", sans-serif;
  --font-mono: 'JetBrains Mono', 'Roboto Mono', monospace;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 15px rgba(200, 255, 0, 0.25);
  
  --radius-sm: 4px; /* Standard Soft Rounded 4px */
  --radius-md: 8px; /* Container Card 8px */
  --radius-lg: 12px;
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  background-image: radial-gradient(circle at 10% 20%, rgba(0, 90, 156, 0.04) 0%, transparent 40%),
                    radial-gradient(circle at 90% 80%, rgba(90, 90, 90, 0.04) 0%, transparent 40%);
  background-attachment: fixed;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* Header & Banner */
header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand img {
  height: 42px;
  width: auto;
  object-fit: contain;
  border-radius: 4px;
}

.brand-text-container {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-main {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--primary);
  letter-spacing: -0.06em;
  text-transform: lowercase;
}

.brand-sub {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.7rem;
  color: var(--secondary);
  text-transform: lowercase;
  letter-spacing: 0.05em;
  margin-top: -2px;
}

.brand-group {
  letter-spacing: 0.18em;
  font-weight: 700;
}

.brand span {
  font-size: 0.75rem;
  background: rgba(0, 90, 156, 0.08);
  color: var(--primary);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glow);
  font-family: var(--font-mono);
  margin-left: 0.5rem;
}

.sync-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.sync-dot.offline {
  background-color: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

/* Navigation Tabs */
nav.tabs {
  display: flex;
  overflow-x: auto;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border-color);
  scrollbar-width: none;
  position: sticky;
  top: 80px;
  z-index: 99;
}

nav.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 1rem 1.5rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(0, 90, 156, 0.06);
}

/* App Container & Tabs Panels */
main.container {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 0 1.5rem 6rem 1.5rem;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  transition: border-color 0.3s ease;
}

.card:hover {
  border-color: rgba(0, 90, 156, 0.25);
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-dark);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.card-title svg {
  color: var(--primary);
  width: 20px;
  height: 20px;
}

/* Form Layout Grids */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input, select, textarea {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  transition: all 0.2s ease;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--border-glow);
  background: #FFFFFF;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  text-align: center;
  text-decoration: none;
  min-height: 48px;
  text-transform: uppercase;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 0 2px var(--accent);
}

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-secondary:hover {
  background: var(--bg-app);
  border-color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-icon-only {
  width: 44px;
  height: 44px;
  min-height: 44px;
  min-width: 44px;
  padding: 0;
  border-radius: 50%;
}

/* GPS Info Panel */
.gps-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 90, 156, 0.05);
  border: 1px solid rgba(0, 90, 156, 0.15);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.gps-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.gps-info svg {
  color: var(--secondary);
  animation: pulse 2s infinite;
}

.gps-coords {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 0.8; }
}

/* Checklist custom UI */
.checklist-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.checklist-item:last-child {
  border-bottom: none;
}

.checklist-desc {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.checklist-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.checklist-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.rfp-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-right: 0.5rem;
  color: var(--secondary);
}

/* Ambient Readings Table */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background: var(--bg-app);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-dark);
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: #FFFFFF;
}

tr:last-child td {
  border-bottom: none;
}

table input {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  min-width: 60px;
}

table select {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  min-width: 100px;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
  gap: 0.75rem;
}

/* Beams Inspection Checklist */
.bents-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.bent-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #FFFFFF;
}

.bent-header {
  padding: 1rem 1.5rem;
  background: #F8FAFC;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s ease;
}

.bent-header:hover {
  background: #F1F5F9;
}

.bent-card.open .bent-header {
  border-bottom-color: var(--border-color);
  background: rgba(0, 90, 156, 0.06);
}

.bent-title-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.bent-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
}

.bent-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
}

.bent-badge.ok {
  background: rgba(16, 185, 129, 0.15);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.bent-badge.warn {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.bent-toggle-icon {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}

.bent-card.open .bent-toggle-icon {
  transform: rotate(180deg);
}

.bent-content {
  display: none;
  padding: 1.5rem;
  background: #FFFFFF;
  border-top: 1px solid var(--border-color);
}

.bent-card.open .bent-content {
  display: block;
}

.sub-section-title {
  font-size: 1rem;
  margin: 1.5rem 0 1rem 0;
  color: var(--secondary);
  border-bottom: 1px solid rgba(6, 182, 212, 0.1);
  padding-bottom: 0.4rem;
}

.sub-section-title:first-child {
  margin-top: 0;
}

/* Photo Slots & Custom Camera Input */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.photo-slot {
  border: 1px dashed var(--border-color);
  background: #FFFFFF;
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  min-height: 180px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.photo-slot:hover {
  border-color: var(--primary);
  background: rgba(0, 90, 156, 0.03);
}

.photo-slot-icon {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.photo-slot-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.photo-slot-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.photo-slot input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 5;
}

.photo-preview-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  z-index: 10;
  display: none;
}

.photo-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(239, 68, 68, 0.85);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 15;
  transition: background 0.2s;
}

.photo-remove-btn:hover {
  background: var(--danger);
}

.photo-info-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 8px;
  padding: 4px 6px;
  text-align: left;
  line-height: 1.2;
  z-index: 12;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

/* Signature Pad Component */
.signature-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.signature-canvas-wrapper {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  touch-action: none;
  width: 100%;
  max-width: 500px;
  height: 200px;
}

canvas.signature-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.signature-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  width: 100%;
  max-width: 500px;
}

.signature-actions button {
  flex: 1;
}

/* Footer Controls (For navigation inside form) */
.footer-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

/* Print Form Element - Hidden in App View */
#print-report-container {
  display: none;
}

/* A4 Print Layout Media Query */
@media print {
  @page {
    size: A4 portrait;
    margin: 12mm 15mm 15mm 15mm;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-family: Arial, Helvetica, sans-serif !important;
    font-size: 11px !important;
    line-height: 1.4 !important;
  }

  header, nav.tabs, main.container, .footer-nav, .btn, .sync-status, .photo-remove-btn {
    display: none !important;
  }

  #print-report-container {
    display: block !important;
    width: 100% !important;
    color: #000000 !important;
  }

  .print-page {
    page-break-after: always;
    position: relative;
    box-sizing: border-box;
    width: 100%;
  }

  .print-page:last-child {
    page-break-after: avoid;
  }

  /* Print Header */
  .print-header {
    border-bottom: 2px solid #000000;
    padding-bottom: 8px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
  }

  .print-header h1 {
    font-size: 18px;
    font-family: inherit;
    font-weight: bold;
    color: #000000;
    margin: 0;
  }

  .print-header .subtitle {
    font-size: 10px;
    color: #555555;
    text-transform: uppercase;
    font-family: monospace;
  }

  .print-logo-text {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -1px;
    border: 2px solid #000;
    padding: 2px 6px;
  }

  /* Grid Layouts for Print */
  .print-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
  }

  .print-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
  }

  /* Data Groups */
  .print-group {
    border: 1px solid #cccccc;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 12px;
    background: #fafafa;
  }

  .print-group-title {
    font-weight: bold;
    font-size: 12px;
    border-bottom: 1px solid #777777;
    margin-bottom: 8px;
    padding-bottom: 3px;
    text-transform: uppercase;
  }

  .print-field {
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dashed #dddddd;
    padding-bottom: 2px;
  }

  .print-field:last-child {
    border-bottom: none;
  }

  .print-label {
    font-weight: bold;
    color: #444444;
  }

  .print-value {
    font-family: monospace;
    font-weight: normal;
  }

  /* Tables for Print */
  table.print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    font-size: 10px;
  }

  table.print-table th {
    background-color: #eeeeee !important;
    color: #000000 !important;
    border: 1px solid #999999 !important;
    padding: 5px 6px !important;
    font-weight: bold !important;
    font-size: 9px !important;
  }

  table.print-table td {
    border: 1px solid #cccccc !important;
    padding: 4px 6px !important;
    background-color: transparent !important;
  }

  /* Checklist items in Print */
  .print-check-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #eeeeee;
  }

  .print-check-row:last-child {
    border-bottom: none;
  }

  /* Photo Log Print styling: 2 photos per page */
  .print-photo-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 10px;
  }

  .print-photo-card {
    border: 1px solid #999999;
    padding: 8px;
    background: #ffffff;
    border-radius: 4px;
    text-align: center;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
  }

  .print-photo-wrapper {
    position: relative;
    width: 100%;
    height: 180px;
    background: #eeeeee;
    border: 1px solid #dddddd;
    overflow: hidden;
  }

  .print-photo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .print-photo-watermark {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    font-family: monospace;
    font-size: 7px;
    padding: 2px 4px;
    text-align: left;
    line-height: 1.1;
  }

  .print-photo-caption {
    font-weight: bold;
    font-size: 10px;
    margin-top: 5px;
  }

  .print-photo-tag {
    font-size: 8px;
    color: #666666;
    margin-top: 2px;
  }

  /* Signature section */
  .print-signature-section {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 30px;
    border-top: 1px solid #aaaaaa;
    padding-top: 15px;
  }

  .print-sign-box {
    text-align: center;
    width: 200px;
  }

  .print-sign-img-wrapper {
    border-bottom: 1px solid #000;
    height: 50px;
    margin-bottom: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .print-sign-img {
    max-height: 45px;
    object-fit: contain;
  }
}

/* Live A4 Preview Styling */
.a4-preview-scroll-wrapper {
  background: #e2e8f0;
  padding: 1.5rem 1rem;
  border-radius: var(--radius-md);
  max-height: 800px;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.08);
  margin-top: 1rem;
}

#live-a4-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

@media (max-width: 840px) {
  .a4-preview-scroll-wrapper {
    overflow-x: auto;
  }
}

/* Radio & Checkbox width reset */
input[type="radio"], input[type="checkbox"] {
  width: auto !important;
  height: auto !important;
  cursor: pointer;
  margin: 0;
  accent-color: var(--primary);
}

/* Next button validation errors */
.btn-error-red {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
}

.btn-error-red-shake {
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.validation-error-box {
  background-color: #fef2f2;
  border: 1.5px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin: 1rem 0;
  font-size: 0.85rem;
  color: #991b1b;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.input-error-highlight {
  border-color: #ef4444 !important;
  background-color: #fef2f2 !important;
  box-shadow: 0 0 0 1px #ef4444 !important;
}


/* Matrix Table Styles for Beams 10 to 15 */
.matrix-table-wrapper {
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background-color: #fff;
}

.matrix-table th, .matrix-table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  vertical-align: middle;
}

.matrix-table th {
  background: var(--primary);
  font-family: var(--font-display);
  font-weight: 600;
  text-align: center;
  color: #ffffff !important;
}

.matrix-table td {
  background: #ffffff !important;
  color: var(--text-primary) !important;
}

.matrix-table tr:nth-child(even) td {
  background: var(--color-wild-sand) !important;
}

.matrix-table th:first-child, .matrix-table td:first-child {
  text-align: left;
  font-weight: 600;
  width: 250px;
  min-width: 220px;
  background: #f8fafc !important;
  color: var(--primary) !important;
  border-right: 2px solid var(--border-color);
}

.matrix-table input, .matrix-table select {
  width: 100%;
  box-sizing: border-box;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  min-width: 0;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  background-color: #fff;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.matrix-table input:focus, .matrix-table select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 90, 156, 0.15);
}

/* Readonly fields in matrix */
.matrix-table input[readonly] {
  background-color: #f1f5f9;
  font-weight: 600;
  color: var(--secondary);
  cursor: not-allowed;
}

/* Validation highlight in matrix */
.matrix-table input.input-error-highlight, .matrix-table select.input-error-highlight {
  border-color: var(--danger);
  background-color: rgba(239, 68, 68, 0.05);
}



/* Expanded Text Modal & Input Helper Styling */
.input-expandable-container {
  position: relative;
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.input-expandable-container input,
.input-expandable-container textarea {
  padding-right: 28px !important;
}

.input-expand-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 4px;
  opacity: 0.6;
  transition: opacity 0.2s, background-color 0.2s;
  z-index: 5;
}

.input-expandable-container textarea + .input-expand-btn {
  top: 12px;
  transform: none;
}

.input-expand-btn:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.08);
}

.input-expand-btn svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

/* Modal Overlay */
#text-expander-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
}

.text-modal-card {
  background: #ffffff;
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(0, 0, 0, 0.05);
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes modalScaleUp {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.text-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
}

.text-modal-title {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.text-modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.text-modal-textarea {
  width: 100%;
  min-height: 200px;
  max-height: 400px;
  resize: vertical;
  padding: 12px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #334155;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.text-modal-textarea:focus {
  outline: none;
  border-color: #173042;
  box-shadow: 0 0 0 3px rgba(23, 48, 66, 0.15);
}

.text-modal-stats {
  font-size: 0.75rem;
  color: #64748b;
  text-align: right;
}

.text-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #f8fafc;
}

.text-modal-btn {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.text-modal-btn-cancel {
  background: #e2e8f0;
  color: #475569;
}

.text-modal-btn-cancel:hover {
  background: #cbd5e1;
}

.text-modal-btn-save {
  background: #173042;
  color: #ffffff;
}

.text-modal-btn-save:hover {
  background: #001b2c;
}

/* Voice Dictation (Speech-to-Text) Styles */
.text-modal-mic-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #005a9c;
  color: #ffffff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.text-modal-mic-btn:hover {
  background: #004578;
}

.text-modal-mic-btn:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}

@keyframes mic-pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { transform: scale(1.04); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.mic-recording-pulse {
  animation: mic-pulse 1.5s infinite;
}

/* ==========================================
   MODULAR BEAM INSPECTION DASHBOARD STYLES
   ========================================== */

/* Active Beam Banner */
.active-beam-banner {
  position: sticky;
  top: 136px; /* Positioned below main header and nav tabs */
  left: 0;
  right: 0;
  z-index: 98;
  background: var(--primary);
  color: #ffffff;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  margin-bottom: 1.5rem;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.banner-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  background-color: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 1.5s infinite;
}

/* Progress Bars */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 6px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 9999px;
}

.bg-progress-red {
  background-color: var(--danger) !important;
  box-shadow: 0 0 6px rgba(186, 26, 26, 0.3);
}

.bg-progress-yellow {
  background-color: var(--warning) !important;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.3);
}

.bg-progress-green {
  background-color: var(--success) !important;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.3);
}

.progress-percentage {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: bold;
}

.active-beam-banner .progress-percentage,
.accordion-header .progress-percentage {
  color: #ffffff !important;
}

/* Beam Hub (Section 1.5 Dashboard) */
.beam-hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.beam-hub-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.beam-hub-card:hover {
  border-color: rgba(23, 48, 66, 0.4);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.beam-hub-card-accent {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background-color: var(--secondary);
}

.beam-hub-card.active-state .beam-hub-card-accent {
  background-color: var(--accent);
}

.beam-hub-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.beam-hub-card-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--primary);
}

.beam-hub-card-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
}

.beam-hub-card-detail strong {
  color: var(--text-primary);
}

.beam-hub-card-progress-section {
  border-top: 1px solid var(--border-color);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}

.beam-hub-card-btn {
  margin-top: 1rem;
  width: 100%;
  min-height: 38px;
  height: 38px;
  font-size: 0.8rem;
  padding: 0.25rem 1rem;
}

/* Inspection Sections Grid inside Beam Workspace */
.beam-workspace-index-card {
  margin-bottom: 1.5rem;
  padding: 1.5rem;
}

.inspection-sections-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.inspection-section-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
}

.inspection-section-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.inspection-section-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.inspection-section-item-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Nested Crack Survey Layout */
.nested-crack-survey-panel {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  background: var(--bg-card);
  margin-top: 1rem;
}

.nested-crack-survey-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.nested-crack-survey-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}

/* Photo Attachment Style Overrides */
.photo-trigger-cell .btn {
  min-height: auto;
  height: auto;
  padding: 2px;
}

.photo-cell-thumbnail-wrapper {
  position: relative;
  display: inline-block;
  border: 2px solid var(--success);
  border-radius: 6px;
  overflow: hidden;
  width: 60px;
  height: 60px;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.photo-cell-thumbnail-wrapper:hover {
  transform: scale(1.05);
}

.photo-cell-thumbnail-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.photo-cell-thumbnail-check {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: bold;
}

/* Accordion Styling for Active Beam Workspace */
.accordion-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1rem !important;
  background: var(--bg-card);
  transition: all 0.2s ease;
  padding: 0 !important;
  overflow: hidden;
}

.accordion-header {
  user-select: none;
  background: var(--primary) !important;
  transition: background-color 0.2s ease;
}

.accordion-title {
  color: #ffffff !important;
}

.accordion-header:hover {
  background-color: var(--primary-hover) !important;
}

.accordion-card.active .accordion-caret {
  transform: rotate(180deg);
}

/* Required Toggle Switch */
.required-toggle-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.required-label {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.required-toggle {
  display: inline-flex;
  align-items: center;
  width: 58px;
  height: 24px;
  border-radius: 12px;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: bold;
  cursor: pointer;
  color: #ffffff;
  padding: 2px 6px;
  box-sizing: border-box;
  transition: background-color 0.2s ease;
  user-select: none;
  outline: none;
  position: relative;
}

.required-toggle::after {
  content: '';
  position: absolute;
  top: -10px;
  bottom: -10px;
  left: -10px;
  right: -10px;
}

.required-toggle.btn-on {
  background-color: #10b981; /* Green */
  justify-content: space-between;
}

.required-toggle.btn-off {
  background-color: #64748b; /* Grey */
  justify-content: space-between;
}

.required-toggle .toggle-knob {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.required-toggle .toggle-text {
  flex: 1;
  text-align: center;
}


/* Responsiveness Audit & Optimization for Two Main Tabs and Touch Targets */
@media (max-width: 768px) {
  nav.tabs {
    display: flex;
    width: 100%;
    position: sticky;
    top: 60px; /* Shift lower for smaller headers */
  }
  
  nav.tabs .tab-btn {
    flex: 1;
    justify-content: center;
    padding: 0.85rem 0.5rem;
    font-size: 0.8rem;
    text-align: center;
  }

  /* Active Beam Banner & Close Button Responsive Styles */
  .active-beam-banner {
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem !important;
    gap: 0.5rem !important;
    top: 110px !important; /* Move higher for mobile */
  }
  .active-beam-banner .banner-info {
    font-size: 0.85rem !important;
  }
  .active-beam-banner .banner-progress {
    margin-left: 0 !important;
    margin-right: 0 !important;
    font-size: 0.7rem !important;
  }
  .active-beam-banner .progress-bar-container {
    width: 60px !important;
  }
  .close-beam-btn {
    padding: 8px 12px !important;
    font-size: 0.8rem !important;
    min-height: 38px !important;
  }
  .close-beam-btn .btn-text-long {
    display: none !important;
  }

  /* Header backup controls responsiveness */
  .header-backup-controls {
    margin-left: 0 !important;
    flex-wrap: wrap;
    gap: 0.4rem !important;
  }
  #link-tgr-folder-btn {
    padding: 2px 6px !important;
    min-height: 28px !important;
    font-size: 0.7rem !important;
  }
  #save-indicator {
    font-size: 0.75rem !important;
  }
  #dir-status {
    font-size: 0.7rem !important;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 480px) {
  /* Ensure a minimum tap height of 44px for tactile ease on inspections */
  input, select, textarea {
    min-height: 44px;
    font-size: 16px;
    padding: 12px 16px;
  }
  
  .btn {
    min-height: 44px;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }
  
  /* Prevent horizontal scroll in container while keeping forms 100% wide */
  main.container {
    padding: 0 0.75rem 5rem 0.75rem;
    margin: 1rem auto;
  }
}

select, select option, .matrix-table select, .matrix-table select option, #meta-lighting-adequate, #meta-clean-before-reopening, #meta-stored-safely, #meta-safety-concern {
  color: #000000 !important;
  opacity: 1 !important;
  -webkit-text-fill-color: #000000 !important;
}

/* TGR Native Camera Overlay Modal Styles */
.tgr-camera-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  z-index: 30000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.tgr-camera-video-stream {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.tgr-camera-controls-container {
  position: absolute;
  bottom: 40px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  z-index: 30010;
}

.tgr-camera-shutter-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid #ffffff;
  background: #ef4444;
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  position: relative;
}

.tgr-camera-shutter-btn:disabled {
  background: #475569;
  border-color: #94a3b8;
  color: #94a3b8;
  cursor: not-allowed;
}

.tgr-camera-shutter-btn .spinner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #ffffff;
  position: absolute;
  top: 0;
  left: 0;
  animation: spin 1s linear infinite;
  box-sizing: border-box;
}

.tgr-camera-cancel-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.5);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 30010;
}

.tgr-camera-cancel-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: #ffffff;
}

.tgr-camera-info-banner {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 8px 12px;
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  z-index: 30010;
  pointer-events: none;
}

/* Estandardización de Celdas y Miniaturas en Tablas */
.photo-cell-thumbnail-wrapper {
  position: relative;
  display: inline-block;
  border: 2px solid var(--success) !important;
  border-radius: 6px !important;
  overflow: visible !important;
  width: 60px !important;
  height: 60px !important;
  background: #ffffff !important;
  box-shadow: var(--shadow-sm) !important;
  cursor: pointer !important;
  transition: transform 0.2s ease !important;
  box-sizing: border-box !important;
}

.photo-cell-thumbnail-wrapper img {
  width: 60px !important;
  height: 60px !important;
  object-fit: cover !important;
  display: block !important;
  border-radius: 4px !important;
}

.photo-cell-thumbnail-check {
  position: absolute !important;
  bottom: -5px !important;
  right: -5px !important;
  background: var(--success) !important;
  color: white !important;
  border-radius: 50% !important;
  width: 18px !important;
  height: 18px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 10px !important;
  font-weight: bold !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
  z-index: 12 !important;
}

.photo-cell-thumbnail-delete-btn {
  position: absolute !important;
  top: -5px !important;
  right: -5px !important;
  background: #ef4444 !important;
  color: white !important;
  border: none !important;
  border-radius: 50% !important;
  width: 18px !important;
  height: 18px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 11px !important;
  font-weight: bold !important;
  cursor: pointer !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
  z-index: 12 !important;
  transition: background 0.2s !important;
}

.photo-cell-thumbnail-delete-btn:hover {
  background: #b91c1c !important;
}


