:root {
  --primary: #0C447C;
  --primary-dark: #09305f;
  --bg: #ffffff;
  --surface: #f4f6f9;
  --card: #ffffff;
  --border: #dfe5ec;
  --text: #1c2430;
  --muted: #667085;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ── APP ── */
.app {
  min-height: 100vh;
  position: relative;
}

/* ── TOPBAR ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
  color: var(--primary);
  font-size: 15px;
}

.vsw {
  display: flex;
  gap: 4px;
  background: #eef2f6;
  padding: 3px;
  border-radius: var(--radius-sm);
}

.vsw-btn {
  padding: 7px 14px;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  transition: all 0.15s;
}

.vsw-btn.active {
  background: white;
  color: var(--text);
  font-weight: bold;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.client-sel {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: white;
  color: var(--text);
  cursor: pointer;
}

/* ── MAIN ── */
.main {
  padding: 20px 40px;
}

/* Contenedor de scroll horizontal para tablas anchas */
.tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── METRICS ── */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.metric {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.metric-val {
  font-size: 28px;
  font-weight: bold;
}

.metric-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #E24B4A;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── CARDS ── */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.card-title {
  font-weight: bold;
  font-size: 14px;
}

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.tab {
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: bold;
}

/* ── TABLE ── */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.tbl th {
  padding: 8px 10px;
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  font-weight: normal;
  border-bottom: 1px solid var(--border);
}

.tbl td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.tbl tbody tr:hover td {
  background: var(--surface);
}

.ticket-status-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: bold;
}

.b-blue   { background: #dceeff; color: #004c8f; }
.b-green  { background: #ddf5df; color: #1c6b2a; }
.b-red    { background: #ffe2e2; color: #a42828; }
.b-amber  { background: #fff0d7; color: #9b5b00; }
.b-gray   { background: #eef2f6; color: var(--muted); }

.company-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: bold;
  line-height: 1.2;
  white-space: nowrap;
}

.company-badge--gray {
  background: #eef2f6;
  color: var(--muted);
}

.company-extra {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ffe2e2;
  color: #a42828;
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  transition: all 0.15s;
}

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

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

.btn-danger {
  background: #E24B4A;
  color: white;
  border-color: #E24B4A;
}
.btn-danger:hover { background: #c93b3a; border-color: #c93b3a; }

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

.btn-secondary {
  background: var(--primary-dark);
  color: white;
  border-color: var(--primary-dark);
}

.btn-secondary:hover {
  background: #0a3a6a;
  border-color: #0a3a6a;
}

.btn-sm {
  padding: 4px 9px;
  font-size: 12px;
}

/* ── PROGRESS BAR ── */
.progress-bar {
  height: 6px;
  background: #eef2f6;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s;
}

/* ── HORA BARS (admin clients tab) ── */
.hora-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.hora-name {
  font-size: 13px;
  flex: 0 0 140px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hora-prog {
  flex: 1;
  min-width: 40px;
  height: 8px;
  background: #eef2f6;
  border-radius: 999px;
  overflow: hidden;
}

.hora-fill {
  height: 100%;
  border-radius: 999px;
}

.hora-val {
  font-size: 12px;
  color: var(--muted);
  flex: 0 0 160px;
  min-width: 0;
  text-align: right;
}

/* ── TECH SELECT (inline in table) ── */
.tech-sel {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: white;
  color: var(--text);
  max-width: 150px;
  width: 100%;
}

.tech-sel--unassigned {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
  font-weight: 600;
}

/* ── MODAL OVERLAY ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: white;
  border-radius: 16px;
  padding: 22px;
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: 90vh;
  overflow-y: auto;
}

.modal.modal-lg {
  width: 680px;
}

.modal-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  font-weight: bold;
  font-size: 15px;
}

/* ── FORM ── */
.form-row {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}

.form-input {
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: Arial, sans-serif;
  color: var(--text);
  background: white;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

textarea.form-input {
  resize: vertical;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ── AI RESULT BOX ── */
.ai-box {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
  font-size: 13px;
  color: var(--muted);
  min-height: 38px;
  margin-top: 8px;
  line-height: 1.6;
}

/* ── SPINNER ── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── DETAIL GRID ── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

/* ── FORM GRIDS (modales) ── */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.status-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── TOPBAR EXTRAS ── */
.topbar-center {
  display: flex;
  align-items: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-badge {
  background: #dceeff;
  color: var(--primary);
  font-size: 12px;
  font-weight: bold;
  padding: 4px 12px;
  border-radius: 999px;
}

.topbar-badge--admin {
  background: #e8f5e9;
  color: #1c6b2a;
}

.topbar-username {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* ── LOGIN PAGE ── */
.login-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%;
  max-width: 390px;
  box-shadow: 0 4px 24px rgba(0,0,0,.09);
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: bold;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

.input-wrap {
  position: relative;
}

.input-wrap .form-input {
  padding-right: 42px;
}

.eye-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 17px;
  display: flex;
  align-items: center;
  padding: 0;
}

.eye-btn:hover {
  color: var(--text);
}

.alert-error {
  background: #fff0f0;
  color: #a42828;
  border: 1px solid #f5c6c6;
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 13px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  line-height: 1.5;
}

.alert-warn {
  background: #fff8ec;
  color: #9b5b00;
  border: 1px solid #f5dfa0;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 12px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

.login-back {
  display: block;
  text-align: center;
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.login-back:hover {
  color: var(--primary);
}

/* ── LANDING PAGE ── */
.landing-body {
  background: var(--surface);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.landing-wrap {
  text-align: center;
  padding: 24px;
  max-width: 700px;
  width: 100%;
}

.landing-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 28px;
  font-weight: bold;
  color: var(--primary);
  margin-bottom: 8px;
}

.landing-logo .ti {
  font-size: 32px;
}

.landing-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 36px;
}

.landing-cards {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.landing-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  width: 260px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: box-shadow 0.2s, transform 0.2s;
}

.landing-card:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
  transform: translateY(-3px);
}

.lcard-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.lcard-icon--client {
  background: #dceeff;
  color: var(--primary);
}

.lcard-icon--admin {
  background: #e8f5e9;
  color: #1c6b2a;
}

.lcard-title {
  font-size: 17px;
  font-weight: bold;
}

.lcard-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}

.lcard-cta {
  font-size: 13px;
  color: var(--primary);
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

/* ── CALENDAR ── */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-title {
  font-weight: bold;
  font-size: 14px;
}

.cal-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
  min-width: 480px;
}

.cal-th {
  padding: 6px 4px;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  border-bottom: 2px solid var(--border);
}

.cal-cell {
  vertical-align: top;
  padding: 4px 5px;
  height: 76px;
  border: 1px solid var(--border);
  transition: background 0.1s;
}

.cal-cell:not(.cal-empty) {
  cursor: default;
}

.cal-cell:not(.cal-empty):hover {
  background: var(--bg);
}

.cal-empty {
  background: #fafbfc;
  border-color: #eef2f6;
}

.cal-day-num {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 3px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.cal-today-num {
  background: var(--primary);
  color: white;
  font-weight: bold;
}

.cal-chip {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  font-weight: 500;
  display: block;
  transition: opacity 0.1s;
}

.cal-chip:hover {
  opacity: 0.8;
}

.cal-more {
  font-size: 10px;
  color: var(--muted);
  padding: 1px 5px;
}

/* ── MONTHLY CHART ── */
.monthly-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 130px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.month-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  gap: 0;
}

.month-val {
  font-size: 11px;
  font-weight: bold;
  margin-bottom: 4px;
  min-height: 16px;
  line-height: 1;
}

.month-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}

.month-bar {
  width: 100%;
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  transition: height 0.4s ease;
}

.month-name {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
}

/* ── EMPRESA ACCORDION ── */
.empresa-accordion {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--card);
}

.empresa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  cursor: pointer;
  user-select: none;
  gap: 12px;
  transition: background .15s;
}
.empresa-header:hover { background: var(--surface); }

.empresa-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.empresa-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.empresa-chevron {
  font-size: 14px;
  color: var(--muted);
  transition: transform .2s;
  flex-shrink: 0;
}
.empresa-accordion.open .empresa-chevron { transform: rotate(90deg); }

.empresa-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.empresa-chips { display: flex; gap: 5px; flex-wrap: wrap; }
.echip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.echip-open    { background: rgba(24,95,165,.15); color: #5da3f5; }
.echip-pending { background: rgba(239,159,39,.15); color: #EF9F27; }
.echip-closed  { background: rgba(255,255,255,.07); color: var(--muted); }

.empresa-body {
  border-top: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--surface);
}

.empresa-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ══════════════ RESPONSIVE ══════════════ */

/* ── Tablet horizontal / portátil pequeño ── */
@media (max-width: 1024px) {
  .main { padding: 18px 24px; }

  /* Las tablas dejan de comprimirse: se dimensionan por contenido
     y el .tbl-wrap padre las desplaza horizontalmente. */
  .tbl {
    table-layout: auto;
    width: max-content;
    min-width: 100%;
  }

  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

/* ── Tablet vertical ── */
@media (max-width: 768px) {
  .main { padding: 16px 16px; }

  .form-grid-2,
  .form-grid-3,
  .detail-grid { grid-template-columns: 1fr; }

  .modal { padding: 18px; border-radius: 14px; }

  /* Barras de horas: el nombre se encoge con elipsis */
  .hora-name { flex: 1 1 90px; }
  .hora-val  { flex: 0 0 auto; }

  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; justify-content: center; }

  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; }
}

/* ── Móvil ── */
@media (max-width: 480px) {
  .main { padding: 12px; }

  /* Topbar compacta en una sola fila */
  .topbar {
    flex-wrap: nowrap;
    padding: 10px 12px;
    gap: 6px;
  }
  .topbar-center,
  .topbar-username { display: none; }
  .topbar-right { gap: 6px; flex-shrink: 0; }
  .topbar-right .btn-sm { padding: 6px 8px; }
  .topbar-right .btn-sm .btn-label { display: none; }
  .logo { font-size: 14px; min-width: 0; }

  .card { padding: 14px; }

  /* Acordeón de empresas: cabecera en dos líneas */
  .empresa-header { flex-wrap: wrap; row-gap: 8px; padding: 12px; }
  .empresa-header-left { flex: 1 1 100%; }
  .empresa-name { white-space: normal; }
  .empresa-header-right { flex: 1 1 100%; justify-content: flex-end; }
  .empresa-header-right .hora-prog { width: 70px !important; }
  .empresa-body { padding: 12px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { padding: 12px; }
  .metric-val { font-size: 22px; }

  /* El nombre pasa a su propia línea; barra y valor debajo */
  .hora-bar { flex-wrap: wrap; row-gap: 6px; }
  .hora-name { flex: 1 0 100%; font-weight: 600; }
  .hora-val { font-size: 11px; }

  .landing-cards { flex-direction: column; align-items: center; }
  .landing-card { width: 100%; max-width: 320px; }
  .login-card { padding: 26px 20px; }
}
