:root {
  --brand: #0B6F74;
  --brand-600: #0A6065;
  --brand-50: #E6F5F6;
  --ink: #0F1720;
  --text: #2B3645;
  --muted: #637083;
  --line: #e3e9f0;
  --bg: #f7fafb;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(10, 20, 30, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
}

/* Keep links styled like the app, no default blue/purple */
.app-body a {
  color: inherit;
  text-decoration: none;
}

.app-body a:visited {
  color: inherit;
}

.app-body a:hover {
  color: inherit;
}

.app-body {
  min-height: 100vh;
  background: radial-gradient(circle at top left, var(--brand-50), #ffffff 45%);
}

/* LOGIN LAYOUT */

.app-body-login {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, var(--brand-50), #ffffff 55%);
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  border: 1px solid var(--line);
  text-align: center;
}

.login-logo img {
  height: 52px;
  width: auto;
}

.login-title {
  margin: 18px 0 6px;
  font-size: 1.4rem;
  color: var(--ink);
}

.login-subtitle {
  margin: 0 0 20px;
  font-size: 0.95rem;
  color: var(--muted);
}

.login-google-btn-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.login-footnote {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* APP HEADER */

.app-header {
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-logo-link {
  display: inline-flex;
  align-items: center;
}

.app-logo-img {
  height: 40px;
  width: auto;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-button {
  border: 1.5px solid var(--line);
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.back-button:hover {
  background: var(--brand-50);
  border-color: var(--brand);
  color: var(--brand);
  transform: translateX(-2px);
}

.back-button:active {
  transform: translateX(-1px) scale(0.98);
}

.icon-button {
  border: 1.5px solid var(--line);
  background: #ffffff;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
}

.icon-button:hover {
  background: var(--brand-50);
  border-color: var(--brand);
  color: var(--brand);
  transform: scale(1.05);
}

.icon-button:active {
  transform: scale(0.95);
}

.menu-group {
  position: relative;
}

.menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #ffffff;
  border-radius: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  min-width: 350px;
  padding: 6px;
  display: none;
  z-index: 30;
}

.menu-dropdown.open {
  display: block;
}

.menu-dropdown button {
  width: 100%;
  border: none;
  background: transparent;
  padding: 8px 10px;
  text-align: left;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: 10px;
}

.menu-dropdown button:hover {
  background: var(--brand-50);
}

/* USER MENU */

.app-header-right {
  display: flex;
  align-items: center;
}

.user-menu {
  position: relative;
  z-index: 99999;
}

.user-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--line);
  cursor: pointer;
  position: relative;
  z-index: 99999;
}

.user-name {
  font-size: 0.9rem;
  color: var(--text);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  background: var(--brand-50);
}

/* Dropdown */

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--line);
  min-width: 200px;
  padding: 8px;
  display: none;
  z-index: 99999 !important;
  animation: fadeInDown 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-menu-dropdown.open {
  display: block;
}

.user-menu-dropdown button {
  width: 100%;
  border: none;
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
  color: var(--text);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

.user-menu-dropdown button:hover {
  background: var(--brand-50);
  color: var(--brand);
  transform: translateX(2px);
}

.user-menu-dropdown button:active {
  transform: translateX(1px);
}

/* MAIN CONTENT */

.app-main {
  padding: 24px 16px 40px;
}

.app-section {
  max-width: 1800px; /* widened for table-heavy pages to prevent horizontal scroll */
  margin: 0 auto;
}

.app-section-title {
  margin: 4px 0 4px;
  font-size: 1.4rem;
  color: var(--ink);
}

.app-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.app-section-header-left,
.app-section-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.app-section-header-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.below-buttons {
  margin-top: 8px;
}

@media (max-width: 640px) {
  .app-section-header {
    justify-content: space-between;
  }
  .menu-group {
    margin-left: auto;
  }
}

.app-section-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* APP GRID (Inicio icons) */

.app-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

@media (max-width: 640px) {
  .app-grid {
    grid-template-columns: 1fr;
  }
}

.app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 14px;
  border-radius: 18px;
  background: transparent;
  border: none;
  box-shadow: none;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s ease;
}

.app-tile:hover {
  transform: translateY(-2px);
}

.app-tile-muted {
  opacity: 0.7;
}

.app-tile-icon {
  width: 100px;
  height: 100px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-50);
  font-weight: 700;
  color: var(--brand-600);
  margin-bottom: 8px;
  font-size: 1.1rem;
  overflow: hidden;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.app-tile-icon-primary {
  background: var(--brand);
  color: #ffffff;
}

.app-tile-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 18px;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0;
  margin: 0;
}

.app-tile-label {
  font-size: 0.95rem;
  text-align: center;
}

/* UTILITIES */

code {
  font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 0.8rem;
}

/* DENUNCIAS / TABLE PAGES */

.denuncias-controls {
  margin: 12px 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}

.denuncias-controls-left label {
  font-size: 0.9rem;
  color: var(--muted);
}

.denuncias-controls select {
  margin-left: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #fff;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  cursor: pointer;
}

.denuncias-controls select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(11, 111, 116, 0.1);
}

.denuncias-controls select:hover:not(:focus) {
  border-color: #cbd5e1;
}

.denuncias-controls-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.denuncias-controls-right input {
  padding: 10px 16px;
  border-radius: 999px;
  border: 2px solid var(--line);
  min-width: 240px;
  font-size: 0.9rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.denuncias-controls-right input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(11, 111, 116, 0.15), 0 4px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.denuncias-controls-right input:hover:not(:focus) {
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.denuncias-table-wrapper {
  margin-top: 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07), 0 8px 24px rgba(0, 0, 0, 0.05);
  overflow-x: visible;
  overflow-y: visible;
  width: 100%;
}

.denuncias-table {
  width: 100%;
  min-width: 1000px; /* Minimum width to ensure all columns are visible */
  border-collapse: collapse;
  font-size: 0.9rem;
}

.denuncias-table th,
.denuncias-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
  white-space: nowrap; /* keep one line per row, content will be truncated in JS */
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.denuncias-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.denuncias-table th {
  background: linear-gradient(to bottom, var(--brand-50), #e8f4f5);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 2px solid var(--brand);
  padding: 14px 16px;
}

.denuncias-table tbody tr {
  transition: all 0.15s ease;
}

.denuncias-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.denuncias-table tbody tr:hover {
  background: linear-gradient(to right, #f0f7ff, #ffffff);
  transform: translateX(4px);
  box-shadow: -4px 0 8px rgba(11, 111, 116, 0.1);
}

.denuncias-empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 0;
  font-size: 0.9rem;
}

/* Estado badges (denuncias) */

.denuncias-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.denuncias-badge-activa {
  background: #e1f8f0;
  color: #047857;
}

.denuncias-badge-cerrada {
  background: #e5e7eb;
  color: #4b5563;
}

.denuncias-actions-button {
  font-size: 0.875rem;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #ffffff;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.01em;
}

.denuncias-actions-button:hover {
  background: var(--brand-50);
  border-color: var(--brand);
  color: var(--brand);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(11, 111, 116, 0.1);
}

.denuncias-actions-button:active {
  transform: scale(0.98);
}

/* Trabajadores specific */
.trab-controls {
  gap: 8px;
}

.trab-table {
  min-width: 1200px; /* Ensure all columns fit */
}

.trab-table .col-nombre { min-width: 200px; max-width: 280px; }
.trab-table .col-obra { min-width: 200px; max-width: 320px; }
.trab-table .col-dni { min-width: 100px; max-width: 140px; }
.trab-table .col-cat { min-width: 120px; max-width: 180px; }
.trab-table .col-fecha { min-width: 110px; max-width: 130px; }
.trab-table .col-estado { width: 70px; min-width: 70px; text-align: center; }

.trab-table td.col-estado {
  text-align: center;
}

/* Ensure all tables have enough width */
.denuncias-table:not(.trab-table) {
  min-width: 900px; /* Minimum for obras, epis, denuncias tables */
}

.trabajador-detail-modal {
  width: 100%;
  max-width: 900px;
  position: relative;
}

.trabajador-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 820px) {
  .trabajador-detail-grid {
    grid-template-columns: 1fr;
  }
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: #ffffff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--muted);
}

.close-button:hover {
  background: var(--brand-50);
  border-color: var(--brand);
  color: var(--brand);
  transform: scale(1.05);
}

.close-button:active {
  transform: scale(0.95);
}

/* Export modal */
.export-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 32, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.export-backdrop.open {
  display: flex;
}

.export-backdrop.open .export-modal {
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.export-modal {
  width: 100%;
  max-width: 520px;
  background: #ffffff;
  border-radius: 20px 20px 16px 16px;
  border: none;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05);
  position: relative;
  display: flex;
  flex-direction: column;
}

.export-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: var(--brand);
  color: #ffffff;
  border-radius: 20px 20px 0 0;
  margin: 0;
}

.export-modal-content {
  padding: 20px 24px 18px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}

.export-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.export-subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Export modal close button */
.export-modal .close-button {
  position: static;
  width: auto;
  height: auto;
  border-radius: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: #ffffff;
  padding: 4px 8px;
  margin: -4px -8px;
  top: auto;
  right: auto;
}

.export-modal .close-button:hover {
  background: transparent;
  border: none;
  color: #ffffff;
  transform: none;
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 2px;
  border-radius: 6px;
}

.export-modal .close-button:active {
  transform: scale(0.95);
}

.export-columns {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-bottom: 14px;
  padding-right: 4px;
}

.export-columns::-webkit-scrollbar,
.export-modal-content::-webkit-scrollbar {
  width: 8px;
}

.export-columns::-webkit-scrollbar-track,
.export-modal-content::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
}

.export-columns::-webkit-scrollbar-thumb,
.export-modal-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

.export-columns::-webkit-scrollbar-thumb:hover,
.export-modal-content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.export-columns label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.export-columns label:hover {
  background: var(--brand-50);
}

.export-columns input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--brand);
  transition: transform 0.2s ease;
}

.export-columns input[type="checkbox"]:hover {
  transform: scale(1.05);
}

.export-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}


/* VALORADAS PAGE – list style: icon + name + description */

.valoradas-section {
  margin-bottom: 40px;
}

.valoradas-section:last-child {
  margin-bottom: 0;
}

.valoradas-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 16px;
  letter-spacing: -0.01em;
}

.valoradas-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.valoradas-item {
  display: flex;
  align-items: center;
  padding: 14px 12px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.valoradas-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(10, 20, 30, 0.12);
  border-color: var(--brand-50);
}

.valoradas-icon {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-50);
  color: var(--brand-600);
  font-weight: 700;
  font-size: 1rem;
  margin-right: 10px;
}

.valoradas-icon-primary {
  background: var(--brand);
  color: #ffffff;
}

.valoradas-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.valoradas-title {
  font-size: 0.98rem;
  color: var(--ink);
  margin-bottom: 2px;
}

.valoradas-desc {
  font-size: 0.86rem;
  color: var(--muted);
}

/* VALORADAS GUARDADAS PAGE – month buttons */

.valoradas-meses-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.valoradas-mes-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
  cursor: pointer;
  font-size: 0.98rem;
  color: var(--ink);
  text-align: left;
}

.valoradas-mes-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(10, 20, 30, 0.12);
  border-color: var(--brand-50);
}

.valoradas-mes-item-selected {
  background: var(--brand-50);
  border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(11, 111, 116, 0.15);
}

.valoradas-mes-item-selected .valoradas-mes-name {
  color: var(--brand);
  font-weight: 600;
}

.valoradas-mes-name {
  font-weight: 500;
}

.valoradas-mes-count {
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-50);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
}

/* Estado badges for valoradas */
.estado-enviada {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  background: #10b981;
  color: #ffffff;
}

.estado-pendiente {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  background: #f59e0b;
  color: #ffffff;
}

/* Presupuesto table header row - ensure background color is applied */
.presupuesto-header-row {
  background: var(--brand) !important;
  color: white !important;
}

.presupuesto-header-row th {
  background: inherit !important;
  color: inherit !important;
}

/* Floating chat button (global) */
.floating-chat-button {
  position: fixed !important;
  bottom: 24px !important;
  right: 24px !important;
  left: auto !important;
  top: auto !important;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand);
  color: #ffffff;
  border: none;
  box-shadow: 0 8px 24px rgba(11, 111, 116, 0.35), 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 3px solid #ffffff;
  margin: 0;
  padding: 0;
}

.floating-chat-button:hover {
  background: var(--brand-600);
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 12px 32px rgba(11, 111, 116, 0.4), 0 6px 16px rgba(0, 0, 0, 0.2);
}

.floating-chat-button:active {
  transform: scale(1.05) translateY(0);
}

@media (max-width: 768px) {
  .floating-chat-button {
    width: 56px !important;
    height: 56px !important;
    font-size: 24px;
    bottom: 20px !important;
    right: 20px !important;
  }
}
