/* ============================================
   Dashboard — La Ceiba Dorada (tema claro)
   ============================================ */
:root {
  --bg:        #f3f4f1;
  --surface:   #ffffff;
  --surface-2: #f8f9f7;
  --line:      #e1e4de;
  --line-soft: #eceee9;
  --ink:       #1b2420;
  --ink-2:     #4b544e;
  --muted:     #7a827c;
  --green:     #1f3d2b;
  --green-2:   #2b5139;
  --green-soft:#eef2ee;
  --gold:      #a8822e;
  --danger:    #a63a32;
  --radius:    6px;
  --radius-lg: 10px;
  --font:      'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar-w: 232px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--green-2); outline-offset: 2px; }

/* ---- Controles ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 38px; padding: 0 16px; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-2); }
.btn-primary:disabled { opacity: .6; cursor: default; }
.btn-outline { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-outline:hover { border-color: #c9cec6; color: var(--ink); }
.btn-block { width: 100%; height: 44px; }

.field {
  height: 38px; padding: 0 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 0.875rem; color: var(--ink); outline: none;
  transition: border-color .15s;
}
.field:focus { border-color: var(--green-2); }
select.field { padding-right: 32px; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237a827c' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }

.brand { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; color: var(--green); }

/* ---- Login ---- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 40px 36px;
}
.login-box .brand { display: block; margin-bottom: 28px; }
.login-box h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.login-sub { color: var(--muted); font-size: 0.9rem; margin: 4px 0 28px; }
.field-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.login-box .field { width: 100%; height: 44px; margin-bottom: 18px; font-size: 0.95rem; }
.login-error { display: none; color: var(--danger); font-size: 0.85rem; margin: -4px 0 16px; }
.login-error.show { display: block; }
.login-hint { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 0.8rem; }
.login-hint strong { color: var(--ink-2); font-weight: 600; }

/* ---- Layout ---- */
.dash-wrap { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: fixed; inset: 0 auto 0 0;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 60; transition: transform .25s ease;
}
.sb-brand { padding: 26px 24px 22px; display: flex; flex-direction: column; gap: 2px; }
.sb-brand-sub { font-size: 0.8rem; color: var(--muted); }
.sb-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.sb-link {
  position: relative; display: block; padding: 9px 12px; border-radius: var(--radius);
  color: var(--ink-2); text-decoration: none; font-size: 0.9rem; font-weight: 500;
}
.sb-link:hover { background: var(--surface-2); color: var(--ink); }
.sb-link.active { background: var(--green-soft); color: var(--green); font-weight: 600; }
.sb-footer { padding: 16px 12px 20px; border-top: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 2px; }
.sb-user { padding: 4px 12px 12px; display: flex; flex-direction: column; }
.sb-user strong { font-size: 0.875rem; font-weight: 600; }
.sb-user span { font-size: 0.78rem; color: var(--muted); }
.sb-ext, .sb-logout {
  display: block; padding: 7px 12px; border-radius: var(--radius); text-align: left;
  font-size: 0.84rem; color: var(--ink-2); text-decoration: none; background: none; border: 0; cursor: pointer;
}
.sb-ext:hover, .sb-logout:hover { background: var(--surface-2); color: var(--ink); }
.sb-logout { color: var(--danger); }
.sb-backdrop { display: none; }

.dash-main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); padding: 32px 40px 56px; }

.dash-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.dash-top-left { display: flex; align-items: center; gap: 12px; }
.dash-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.dash-date { color: var(--muted); font-size: 0.875rem; margin-top: 2px; }
.dash-date::first-letter { text-transform: uppercase; }
.dash-actions { display: flex; gap: 8px; }
.menu-toggle {
  display: none; width: 38px; height: 38px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer;
}

/* ---- Resumen ---- */
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  margin-bottom: 36px;
}
.stat { padding: 20px 24px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--line-soft); }
.stat-label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 1.9rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-value-sm { font-size: 1.25rem; line-height: 1.3; }
.stat-note { font-size: 0.82rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Secciones ---- */
.content-section { display: none; }
.content-section.active { display: block; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }
.section-head h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.field-search { width: 250px; }

/* ---- Tabla ---- */
.table-panel { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  text-align: left; font-size: 0.78rem; font-weight: 600; color: var(--muted);
  padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fbfcfa; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td:nth-child(4), .data-table td:nth-child(6), .data-table td:nth-child(7) { white-space: nowrap; }
.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.col-actions { width: 1%; text-align: right; }
.readonly .col-actions { display: none; }
.btn-del {
  background: none; border: 0; padding: 4px 0; cursor: pointer;
  color: var(--danger); font-size: 0.84rem; font-weight: 600;
}
.btn-del:hover { text-decoration: underline; }
.empty-row td { text-align: center; color: var(--muted); padding: 48px 16px; }
.table-count { font-size: 0.8rem; color: var(--muted); margin-top: 10px; }

/* ---- Gráficas ---- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart { padding: 22px 24px; }
.chart h3 { font-size: 0.9rem; font-weight: 600; margin-bottom: 18px; }
.chart-wide { grid-column: 1 / -1; }
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 36px; align-items: center; gap: 12px; }
.bar-label { font-size: 0.84rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--green); border-radius: 3px; }
.bar-val { font-size: 0.84rem; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.chart-empty { color: var(--muted); font-size: 0.875rem; }

/* ---- Próximos ---- */
.proximo { display: grid; grid-template-columns: 64px 1fr auto; gap: 20px; align-items: center; padding: 18px 24px; }
.proximo + .proximo { border-top: 1px solid var(--line-soft); }
.pd { text-align: center; line-height: 1.1; }
.pd-day { display: block; font-size: 1.6rem; font-weight: 700; color: var(--green); letter-spacing: -0.02em; }
.pd-mon { font-size: 0.78rem; color: var(--muted); }
.proximo-info { min-width: 0; }
.proximo-info strong { display: block; font-size: 0.95rem; font-weight: 600; }
.proximo-info span { font-size: 0.84rem; color: var(--muted); }
.proximo-meta { text-align: right; font-size: 0.84rem; color: var(--ink-2); }
.proximo-meta span { display: block; color: var(--muted); }
.empty-panel { padding: 48px 24px; text-align: center; color: var(--muted); }

/* ---- Responsive ---- */
@media (max-width: 1360px) {
  .data-table th:nth-child(7), .data-table td:nth-child(7) { display: none; }
}
@media (max-width: 1100px) {
  .dash-main { padding: 28px 28px 48px; }
  .data-table th, .data-table td { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(27,36,32,.15); }
  .sb-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(27,36,32,.25); z-index: 55; }
  .dash-main { margin-left: 0; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line-soft); }
}

@media (max-width: 900px) {
  /* Tabla → tarjetas apiladas */
  .table-panel { background: transparent; border: 0; border-radius: 0; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); margin-bottom: 10px; padding: 6px 0; }
  .data-table td, .data-table td:nth-child(7) { display: flex; justify-content: space-between; gap: 16px; padding: 8px 16px; border: 0; text-align: right; }
  .data-table td::before { content: attr(data-label); color: var(--muted); font-size: 0.8rem; text-align: left; flex-shrink: 0; }
  .data-table td:first-child { display: block; text-align: left; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--line-soft); }
  .data-table td:first-child::before { content: none; }
  .data-table td.col-actions { width: 100%; justify-content: flex-end; }
  .data-table td.col-actions::before { content: none; }
  .data-table tbody tr:hover td { background: transparent; }
  .empty-row { padding: 0; }
  .empty-row td { display: block; text-align: center; }
  .empty-row td::before { content: none; }

}

@media (max-width: 760px) {
  body { font-size: 14px; }
  .dash-main { padding: 20px 16px 40px; }
  .dash-top { flex-direction: column; align-items: stretch; gap: 16px; margin-bottom: 20px; }
  .dash-title { font-size: 1.3rem; }
  .dash-actions .btn { flex: 1; }
  .stat { padding: 16px; }
  .stat-value { font-size: 1.5rem; }
  .stat-value-sm { font-size: 1.05rem; }
  .filters, .filters .field { width: 100%; }
  .charts { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 100px 1fr 32px; }

  .proximo { grid-template-columns: 52px 1fr; gap: 14px; padding: 16px; }
  .proximo-meta { grid-column: 2; text-align: left; }
  .proximo-meta span { display: inline; }
  .proximo-meta span::before { content: ", "; }
}

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