/* Panel de administración / especialista (mobile-first). */

:root {
  --brand: #0f766e;
  --brand-accent: #0d645e;
  --brand-soft: #e7f1f0;
  --brand-contrast: #ffffff;
  --brand-sidebar: #0b1f1d;
  --brand-sidebar-hover: #123230;

  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e5e9ee;
  --text: #0f172a;
  --text-muted: #64748b;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 10px 30px -12px rgba(16, 24, 40, 0.12);
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); }

.muted { color: var(--text-muted); }

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.flash.ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}
.flash.error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
}

.success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
}

/* --- Login --- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  box-sizing: border-box;
  padding: 1.5rem;
  background:
    radial-gradient(1100px 520px at 100% -10%, rgba(15, 118, 110, 0.16), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(13, 100, 94, 0.14), transparent 55%),
    #f5f7f8;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border: 1px solid rgba(15, 118, 110, 0.08);
  border-radius: 20px;
  box-shadow: 0 24px 60px -24px rgba(2, 18, 17, 0.35);
  padding: 2.5rem 2.25rem 2.25rem;
  box-sizing: border-box;
}
.login-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}
.login-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-accent));
  box-shadow: 0 10px 24px -10px rgba(15, 118, 110, 0.65);
}
.login-mark svg { width: 28px; height: 28px; }
.login-card h1 {
  margin: 0;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.login-sub {
  margin: 0.35rem 0 1.75rem;
  text-align: center;
  color: #64748b;
  font-size: 0.95rem;
}
.login-card form { display: flex; flex-direction: column; gap: 1rem; }
.login-card .field { display: flex; flex-direction: column; }
.login-card .field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.4rem;
}
.login-card input {
  display: block;
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 1rem;
  box-sizing: border-box;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.login-card input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15);
}
.login-card button {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-accent));
  color: var(--brand-contrast);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 22px -10px rgba(15, 118, 110, 0.6);
  transition: filter 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}
.login-card button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.login-card button:active { transform: translateY(0); box-shadow: 0 4px 12px -8px rgba(15, 118, 110, 0.6); }
.login-foot {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
}
.login-foot a { color: var(--brand); text-decoration: none; font-weight: 600; }
.login-foot a:hover { color: var(--brand-accent); text-decoration: underline; }

/* --- Shell del panel --- */
.panel-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.panel-header .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  padding: 7px;
  box-sizing: border-box;
  background: var(--brand-soft);
  color: var(--brand);
}
.brand-mark svg { width: 100%; height: 100%; }

.panel-user { display: flex; align-items: center; gap: 0.75rem; }
.panel-user .user-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.panel-user .user-name { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.panel-user .user-role { font-size: 0.75rem; color: var(--text-muted); }
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-accent));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.panel-user .logout {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.panel-user .logout:hover { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }

.panel-layout { display: flex; flex-direction: column; min-height: calc(100vh - 61px); }

.sidebar {
  background: var(--brand-sidebar);
  padding: 0.75rem;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-content: flex-start;
}
.sidebar a {
  color: rgba(226, 232, 240, 0.8);
  text-decoration: none;
  padding: 0.6rem 0.9rem;
  border-radius: 9px;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar a:hover { background: var(--brand-sidebar-hover); color: #fff; }
.sidebar a.active { background: var(--brand-sidebar-hover); color: #fff; font-weight: 600; }

.panel-content { padding: 1.25rem 1rem 3rem; flex: 1; min-width: 0; }
.panel-content h2 {
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
}
.panel-content h3 {
  font-size: 1.05rem;
  color: #334155;
  margin: 1.75rem 0 0.75rem;
}

/* --- Componentes --- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; margin: 1.25rem 0; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.kpi-value { display: block; font-size: 1.6rem; font-weight: 800; color: var(--brand); letter-spacing: -0.02em; }
.kpi-label { color: var(--text-muted); font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 0.95rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table thead th {
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background 0.12s ease; }
.data-table tbody tr:hover { background: #f8fafc; }

.form label { display: block; margin-bottom: 1rem; font-size: 0.88rem; font-weight: 600; color: #334155; }
.form input, .form textarea, .form select {
  display: block;
  width: 100%;
  padding: 0.6rem 0.8rem;
  margin-top: 0.35rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  box-sizing: border-box;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form textarea { min-height: 90px; resize: vertical; }
.form input:focus, .form textarea:focus, .form select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15);
}
.form input[type="color"] { width: 72px; height: 44px; padding: 0.25rem; }
.form .checkbox { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.form .checkbox input { width: auto; margin: 0; }

.btn {
  display: inline-block;
  background: var(--brand);
  color: var(--brand-contrast);
  border: 0;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--brand-accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.danger { background: #b91c1c; }
.btn.danger:hover { background: #991b1b; }

.link {
  display: inline-flex;
  align-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  border: 0;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}
.link:hover { background: #d6e9e7; }
.link.danger { background: #fee2e2; color: #b91c1c; }
.link.danger:hover { background: #fecaca; }

.inline { display: inline; }
.search { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; max-width: 480px; }
.search input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15); }
.search button {
  padding: 0.6rem 1.1rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.search button:hover { background: var(--brand-accent); }

.totals { margin-top: 1.5rem; padding: 1rem 1.25rem; background: var(--brand-soft); border-radius: var(--radius); color: var(--brand); font-size: 0.95rem; }
.record-list { list-style: none; padding: 0; margin: 0; }
.record-list li { border-bottom: 1px solid var(--border); padding: 0.9rem 0; }
.record-list li:last-child { border-bottom: 0; }
.record-list p { margin: 0.4rem 0 0; }

/* --- Reportes --- */
.report-actions { margin-bottom: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.report-actions .btn { font-size: 0.85rem; padding: 0.4rem 0.8rem; }

.date-range { margin: 0.75rem 0 1rem; }
.presets { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.preset {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  text-decoration: none;
  color: #334155;
  font-size: 0.85rem;
  font-weight: 600;
  background: #fff;
  transition: all 0.15s ease;
}
.preset:hover { border-color: var(--brand); color: var(--brand); }
.preset.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.filters {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin: 0.75rem 0 1.5rem;
  padding: 1rem 1.25rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.filters label { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; }
.filters select, .filters input[type="date"] {
  display: block;
  margin-top: 0.3rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  min-width: 160px;
  font-size: 0.9rem;
}
.filters select:focus, .filters input[type="date"]:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15);
}
.custom-range { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; margin-top: 0.5rem; }
.custom-range label { font-size: 0.82rem; color: var(--text-muted); font-weight: 600; }
.custom-range input[type="date"] {
  display: block;
  margin-top: 0.3rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
}

.report .group-header td { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.report .total td { background: #f8fafc; font-size: 0.9rem; }
.report .group-footer td { background: #f1f5f9; color: var(--text-muted); font-size: 0.85rem; }
.chart-summary { padding: 0.5rem; }
.chart-series { color: var(--text-muted); font-size: 0.9rem; }
.pivot-table { border-collapse: collapse; width: 100%; }
.pivot-table th, .pivot-table td { border: 1px solid var(--border); padding: 0.45rem 0.65rem; }

.chart-box { padding: 0.75rem 0; }
.chart-title { font-weight: 700; color: var(--brand); margin-bottom: 0.5rem; }
.chart-bars { display: flex; flex-direction: column; gap: 0.5rem; max-width: 560px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 64px; align-items: center; gap: 0.6rem; }
.bar-label { font-size: 0.85rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #e2e8f0; border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, var(--brand), var(--brand-accent)); border-radius: 999px; height: 12px; min-width: 2px; }
.bar-value { font-size: 0.85rem; text-align: right; color: #334155; font-weight: 600; }
.chart-legend { list-style: none; padding: 0; max-width: 560px; }
.chart-legend li { display: flex; justify-content: space-between; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.legend-label { color: var(--text-muted); }
.legend-value { color: var(--brand); font-weight: 700; }

/* --- Apariencia --- */
.preview { margin: 1rem 0; padding: 1.25rem; border: 1px dashed #cbd5e1; border-radius: var(--radius); background: #fff; }
.preview-header {
  background: var(--brand);
  color: var(--brand-contrast);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  display: inline-block;
  margin-bottom: 0.75rem;
}
.preview .btn { margin-right: 0.5rem; }

/* --- Móvil --- */
.nav-toggle { display: none; }

@media (max-width: 768px) {
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .panel-user .user-meta { display: none; }
}

/* --- Escritorio (>=1024px) --- */
@media (min-width: 1024px) {
  .panel-layout { flex-direction: row; }
  .sidebar {
    flex-direction: column;
    width: 240px;
    min-height: 100%;
    padding: 1rem 0.75rem;
    gap: 0.25rem;
  }
  .sidebar a {
    border-left: 3px solid transparent;
    border-radius: 8px;
  }
  .sidebar a.active { border-left-color: var(--brand); }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .panel-content { padding: 1.75rem 2.5rem 4rem; }
  .nav-toggle { display: none; }
}

/* Editor de descripción enriquecida */
.rich-toolbar {
  display: block;
  margin: 0.35rem 0;
}
.preview.rich-text {
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface, #fff);
  border: 1px dashed var(--border, #d0d7de);
  border-radius: var(--radius-sm, 8px);
}
.preview.rich-text img { max-width: 100%; height: auto; }
