/* 1.14.4: superficies y texto opacos; el brillo queda en los adornos. */
html:not([data-theme]), html[data-theme="light"] {
  --surface:#fff; --surface-soft:#f2f7fa; --ink:#172b3d; --title:#0b1f30; --muted:#455b70;
  --teal:#087565; --green-soft:#dcf6ed; --violet:#6942c1; --violet-soft:#eee8fa;
  --amber:#a34b04; --amber-soft:#fff0d8; --red:#b82746; --red-soft:#ffe8ef; --blue:#2467b4;
  --action-start:#087e69; --action-end:#2162b6; --on-action:#fff;
}
html[data-theme="rest"] {
  --action-start:#286b55; --action-end:#405d92; --on-action:#fff;
}
html:is([data-theme="dark"],[data-theme="soft"]) {
  --action-start:#087e69; --action-end:#2162b6; --on-action:#fff;
}
html[data-palette="slate"] { --action-start:#425e7c; --action-end:#355879; }
html[data-palette="forest"] { --action-start:#1b7045; --action-end:#17634c; }
html[data-palette="purple"] { --action-start:#7044c8; --action-end:#5446b8; }
html[data-palette="wine"] { --action-start:#a12448; --action-end:#892252; }
html[data-theme="light"]:is([data-palette="navy"],[data-palette="claro"]) { --accent:#1762c0; --focus:#1762c0; }

body { color:var(--ink); }
/* Las superficies opacas no mezclan la letra con el color detrás del panel. */
html[data-theme] :is(.workspace-panel,.metric,.plan-card,.employee-card,.quick-card,.card,.stats-filters,.subscription-strip),
html[data-theme] #authView :is(.auth-panel,.welcome-overview,.welcome-benefits article,.welcome-start,.welcome-plan-grid article) {
  background:var(--surface); color:var(--ink); border-color:var(--line); backdrop-filter:none;
}
html[data-theme][data-palette] .sidebar {
  background:var(--surface); color:var(--ink); border-color:var(--line); backdrop-filter:none;
  height:calc(100dvh - 32px); top:16px;
}
html[data-theme] :is(.company-switch,.workspace-launch,.mobile-open,.theme-switch select,.secondary,.chip,.segmented,.nav-toggle) {
  background:var(--surface-soft); color:var(--ink); border-color:var(--line); backdrop-filter:none;
}
html[data-theme] :is(.secondary,.chip,.workspace-launch,.mobile-open):hover {
  background:var(--surface); color:var(--title);
}
html[data-theme] :is(input,select,textarea) { background:var(--surface); color:var(--ink); }
html[data-theme] :is(input,textarea)::placeholder { color:var(--muted); opacity:1; }
html[data-theme] select option { background:var(--surface); color:var(--ink); }
html[data-theme] .company-switch { color:var(--title); }
html[data-theme] .company-switch small { color:var(--muted); font-size:11px; }
html[data-theme] .sidebar button { color:var(--ink); font-size:12px; }
html[data-theme] .sidebar button:hover { background:var(--surface-soft); color:var(--title); border-color:var(--line); }
html[data-theme] .sidebar button > span { background:var(--surface-soft); color:var(--ink); box-shadow:none; }
html[data-theme] .sidebar button.active { background:#e4f7fc; color:#143042; border-color:#92cad8; }
html[data-theme] .sidebar button.active > span { background:#087e69; color:#fff; }
html[data-theme] .sidebar :is(.nav-label,.nav-group summary,.sidebar-footer > small) { color:var(--muted); }
html[data-theme] .eyebrow { color:var(--muted); }

html[data-theme] .segmented button { color:var(--ink); background:transparent; font-weight:600; }
html[data-theme] .segmented button:hover { background:var(--surface); color:var(--title); }
html[data-theme] .segmented button[aria-pressed="true"] {
  background:var(--action-start); color:var(--on-action); box-shadow:0 2px 6px var(--shadow);
}
/* Botones de las fichas: cada acción conserva su clase y su contraste. */
html[data-theme] #appView .card button:not(.secondary) { background:var(--surface-soft); color:var(--ink); }
html[data-theme] :is(.primary,.btn-primary),
html[data-theme] #authView .btn-primary,
html[data-theme] #appView .primary,
html[data-theme] #appView .card :is(button.primary,button[type="submit"],button:not([type])) {
  background:linear-gradient(135deg,var(--action-start),var(--action-end)); color:var(--on-action);
}
html[data-theme] :is(.primary,.btn-primary):hover { filter:brightness(.94); }
html[data-theme] .cal-cell.today .cal-daynum { background:var(--action-start); color:var(--on-action); }
html[data-theme] .danger { background:#b82746; color:#fff; }
html[data-theme] #appView .card button.danger { background:#b82746; color:#fff; }
html[data-theme] .chip.on { background:var(--green-soft); color:var(--teal); }
html[data-theme] #appToast { background:var(--action-start); color:var(--on-action); }

html[data-theme] .data-table :is(th,td) { color:var(--ink); }
html[data-theme] .data-table th { color:var(--muted); }
html[data-theme] .data-table td { background:var(--surface); border-color:var(--line); }
html[data-theme] :is(.emp-tile,.kb-card,.crm-dialog) { background:var(--surface); color:var(--ink); }
html[data-theme] :is(.emp-tile strong,.employee-card h3,.gallery-caption h3,.pv-stage figcaption strong) { color:var(--title); }
html[data-theme] :is(.emp-tile > span,.employee-card p,.gallery-caption p,.pv-stage figcaption span,.pv-stage figcaption small) { color:var(--muted); }
html[data-theme] .metric > * { position:relative; z-index:1; }
html[data-theme] .metric::after { pointer-events:none; z-index:0; opacity:.18; }
html[data-theme] .metric :is(small,span) { color:var(--muted); }
html[data-theme] :is(.workspace-panel,.card,.plan-card) p { color:var(--muted); }
html[data-theme] :is(.metric,.workspace-panel,.company-switch,.segmented,.emp-tile,.sidebar) { text-shadow:none; }
html[data-theme] :is(.toolbar input,.toolbar select,.muted,.user-label,.theme-switch > span) { color:var(--muted); }
html[data-theme] :is(.workspace-panel,.card,.plan-card) :is(h1,h2,h3) { color:var(--title); }
html[data-theme] :is(.welcome-panel,.analytics-welcome) { background:var(--green-soft); color:var(--ink); }
html[data-theme] :is(.welcome-panel,.analytics-welcome) :is(h2,p,small,.eyebrow) { color:var(--ink); text-shadow:none; }
html[data-theme] .brand-mark { background:var(--green-soft); color:var(--teal); }
/* El nombre del tema cambia también los paneles de bienvenida. */
html:is([data-theme="dark"],[data-theme="soft"]) .auth { background:var(--canvas); }
html[data-theme="rest"] :is(body,.auth) { background:var(--canvas); }

.view-switch { font-size:12px; }
.view-switch button { min-height:36px; }
.wa-history-text { white-space:pre-wrap; overflow-wrap:anywhere; }
.wa-history-message { min-width:0; flex:1; }
.wa-account code { overflow-wrap:anywhere; }
#waForm { display:grid; gap:12px; }
#waForm label { display:grid; gap:6px; }
#waForm input { width:100%; min-width:0; }
#waForm > button { justify-self:start; }
#waList { display:grid; gap:14px; }
.wa-account-actions { display:flex; flex-wrap:wrap; gap:8px; }
.wa-history-panel { margin-top:18px; }
.wa-message-panel { margin-top:16px; }
@media(min-width:901px) {
  html[data-theme] .nav-collapsed .sidebar .nav-list button,
  html[data-theme] .nav-collapsed .sidebar #logout { font-size:0; }
}
@media(max-width:900px) {
  html[data-theme][data-palette] .sidebar { height:auto; top:0; }
}
@media(max-width:650px) {
  .view-switch { width:100%; }
  .view-switch button { flex:1 1 auto; font-size:12px; }
  .toolbar-actions .secondary { font-size:11px; }
  .metric > span,.metric small { font-size:11px; }
}
@media print {
  #printArea { --ink:#172b3a; --title:#102536; --muted:#465563; --surface:#fff; --surface-soft:#eef3f6; }
}

/* 1.14.7: gráfica mensual sin fondos que parezcan barras. */
html[data-theme] .trend-panel [hidden] { display:none !important; }
html[data-theme] .trend-panel .trend-month { background:transparent; }
html[data-theme] .trend-panel .trend-bars { background:repeating-linear-gradient(to top,transparent 0,transparent 49px,var(--line) 50px,transparent 51px); }
html[data-theme] .trend-panel .trend-bar.blue { background:var(--blue); }
html[data-theme] .trend-panel .trend-bar.teal { background:var(--teal); }
html[data-theme] .trend-panel .trend-bar > span { color:var(--ink); background:transparent; }

/* 1.14.9: navegación amplia y tarjetas inspiradas en el dashboard de referencia. */
@media(min-width:901px) {
  #appView:not(.nav-collapsed) .sidebar { width:240px; min-width:240px; flex-shrink:0; padding:24px 16px 18px; }
  #appView:not(.nav-collapsed) .sidebar button { font-size:13px; line-height:1.4; padding:10px 12px; }
  #appView:not(.nav-collapsed) .sidebar .nav-list button { white-space:normal; overflow-wrap:normal; }
}
html[data-theme="light"] { --canvas:#eef0f5; --surface:#ffffff; --surface-soft:#f4f6fb; --line:#dce2ed; --ink:#203047; --title:#13243b; --muted:#52647b; --blue:#1764d6; --teal:#087565; --violet:#6942c1; --amber:#a34b04; }
html[data-theme="light"] body { background:var(--canvas); }
html[data-theme="light"] #appView { background:var(--canvas); }
html[data-theme] #appView :is(.workspace-panel,.metric,.quick-card,.stats-filters) { border-radius:20px; border:1px solid var(--line); box-shadow:0 5px 18px var(--shadow); }
html[data-theme="light"] .sidebar button.active { background:#e8f1ff; color:#174c9c; border-color:#b6d0fa; box-shadow:inset 3px 0 0 #1764d6; }
html[data-theme="light"] .sidebar button.active > span { background:#1764d6; color:#fff; }
html[data-theme] .dashboard-metrics .metric:nth-child(4n+1) { border-top:3px solid var(--blue); }
html[data-theme] .dashboard-metrics .metric:nth-child(4n+2) { border-top:3px solid var(--teal); }
html[data-theme] .dashboard-metrics .metric:nth-child(4n+3) { border-top:3px solid var(--violet); }
html[data-theme] .dashboard-metrics .metric:nth-child(4n+4) { border-top:3px solid var(--amber); }
html[data-theme="light"] .dashboard-metrics .metric:nth-child(4n+1) strong { color:var(--blue); }
html[data-theme="light"] .dashboard-metrics .metric:nth-child(4n+2) strong { color:var(--teal); }
html[data-theme="light"] .dashboard-metrics .metric:nth-child(4n+3) strong { color:var(--violet); }
html[data-theme="light"] .dashboard-metrics .metric:nth-child(4n+4) strong { color:var(--amber); }
html[data-theme="light"] .analytics-welcome { background:linear-gradient(115deg,#e4efff,#e4f7f4); border:1px solid #ccdfee; }
html[data-theme="light"] .stats-grid .ch-line { stroke:var(--blue); }
@media(max-width:900px) { #appView .sidebar { width:100%; min-width:0; } }
