:root {
  --bg: #0a0a0f;
  --bg-2: #0f0f17;
  --surface: #14141d;
  --surface-2: #1c1c28;
  --border: #262635;
  --text: #f1f5f9;
  --text-muted: #8b8ba0;
  --text-dim: #5a5a72;

  --q-do: #ef4444;
  --q-do-bg: rgba(239, 68, 68, .08);
  --q-do-border: rgba(239, 68, 68, .35);
  --q-plan: #3b82f6;
  --q-plan-bg: rgba(59, 130, 246, .08);
  --q-plan-border: rgba(59, 130, 246, .35);
  --q-delegate: #eab308;
  --q-delegate-bg: rgba(234, 179, 8, .08);
  --q-delegate-border: rgba(234, 179, 8, .35);
  --q-drop: #94a3b8;
  --q-drop-bg: rgba(148, 163, 184, .06);
  --q-drop-border: rgba(148, 163, 184, .25);

  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5; min-height: 100vh;
}
body {
  background:
    radial-gradient(circle at 20% 0%, rgba(239,68,68,.06), transparent 50%),
    radial-gradient(circle at 80% 0%, rgba(59,130,246,.06), transparent 50%),
    var(--bg);
}

/* HEADER */
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: rgba(10,10,15,.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.brand i { font-size: 22px; color: #10b981; }
.header-actions { display: flex; gap: 8px; }

.icon-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  color: var(--text); cursor: pointer; font-size: 18px; transition: all .15s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--text-dim); }
.icon-btn.primary { background: #10b981; border-color: #10b981; color: #0a0a0f; }
.icon-btn.primary:hover { background: #34d399; }

/* TABS */
.tabs {
  display: flex; gap: 4px; padding: 12px 16px 0; max-width: 1100px; margin: 0 auto;
}
.tab {
  flex: 1; padding: 10px 12px; background: transparent; border: 1px solid var(--border);
  border-radius: 10px; color: var(--text-muted); cursor: pointer; font-size: 13px;
  display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 500;
  transition: all .15s;
}
.tab i { font-size: 16px; }
.tab:hover { color: var(--text); border-color: var(--text-dim); }
.tab.active { background: var(--surface-2); color: var(--text); border-color: var(--text-muted); }

/* MAIN */
main { padding: 20px 16px 80px; max-width: 1100px; margin: 0 auto; }

.hero { text-align: center; padding: 28px 0 20px; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3);
  color: #10b981; padding: 5px 14px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .8px; margin-bottom: 14px;
}
.status-pill .dot { width: 7px; height: 7px; background: #10b981; border-radius: 50%; box-shadow: 0 0 8px #10b981; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.hero h1 { font-size: 36px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 6px; }
.hero-date { color: var(--text-muted); font-size: 14px; text-transform: capitalize; }
.legend {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
  margin-top: 14px; font-size: 10px; letter-spacing: .5px; font-weight: 500;
}
.legend .lg { color: var(--text-muted); }
.legend .lg.fixed { color: #10b981; }
.legend .lg.manual { color: #94a3b8; }
.legend .lg.claude { color: #c084fc; }
.legend .lg.calendar { color: #fb923c; }

.progress-mini { max-width: 280px; margin: 14px auto 0; }

.icon-btn.spinning i { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sync-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 200; opacity: 0; transition: opacity .2s;
}
.sync-toast.show { opacity: 1; }
.sync-toast.error { border-color: rgba(239,68,68,.4); color: #fca5a5; }
.sync-toast.success { border-color: rgba(16,185,129,.4); color: #6ee7b7; }
.bar { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #10b981, #34d399); transition: width .3s; width: 0; }
.progress-meta { display: flex; justify-content: center; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }

/* AXIS */
.axis-labels { max-width: 1100px; margin: 8px auto 6px; padding: 0 4px; }
.axis-x {
  display: flex; gap: 12px; font-size: 10px; font-weight: 600; letter-spacing: 1.2px;
  color: var(--text-dim);
}
.axis-x span { flex: 1; text-align: center; }
.axis-x span:first-child { color: #ef4444; }

/* MATRIX */
.matrix {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  max-width: 1100px; margin: 0 auto;
}
.quadrant {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; min-height: 220px; position: relative; display: flex; flex-direction: column;
  transition: border-color .15s;
}
.quadrant.q-do { background: linear-gradient(180deg, var(--q-do-bg), var(--surface)); border-color: var(--q-do-border); }
.quadrant.q-plan { background: linear-gradient(180deg, var(--q-plan-bg), var(--surface)); border-color: var(--q-plan-border); }
.quadrant.q-delegate { background: linear-gradient(180deg, var(--q-delegate-bg), var(--surface)); border-color: var(--q-delegate-border); }
.quadrant.q-drop { background: linear-gradient(180deg, var(--q-drop-bg), var(--surface)); border-color: var(--q-drop-border); }
.quadrant.drag-over { border-color: var(--text) !important; box-shadow: 0 0 0 2px rgba(255,255,255,.08); }

.quadrant header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 12px;
}
.q-meta { display: flex; gap: 10px; align-items: center; }
.q-dot { width: 14px; height: 14px; border-radius: 50%; }
.q-do .q-dot { background: var(--q-do); box-shadow: 0 0 12px var(--q-do); }
.q-plan .q-dot { background: var(--q-plan); box-shadow: 0 0 12px var(--q-plan); }
.q-delegate .q-dot { background: var(--q-delegate); box-shadow: 0 0 12px var(--q-delegate); }
.q-drop .q-dot { background: var(--q-drop); }
.quadrant h2 { font-size: 15px; font-weight: 600; line-height: 1.1; }
.quadrant small { font-size: 10px; color: var(--text-dim); letter-spacing: 1px; font-weight: 600; }
.count {
  background: var(--surface-2); color: var(--text-muted);
  padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
}

.tasks { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.task {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px 8px 12px; display: flex; gap: 8px; align-items: flex-start;
  cursor: grab; transition: all .15s; position: relative; overflow: hidden;
}
.task::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.task[data-source="fixed"]::before { background: #10b981; }
.task[data-source="manual"]::before { background: #64748b; }
.task[data-source="claude"]::before { background: #a855f7; box-shadow: 0 0 8px rgba(168,85,247,.5); }
.task[data-source="calendar"]::before { background: #f97316; box-shadow: 0 0 8px rgba(249,115,22,.5); }
.task:hover { border-color: var(--text-dim); }
.task.dragging { opacity: .4; }
.task.done { opacity: .45; }
.task.done .task-title { text-decoration: line-through; }
.task input[type=checkbox] {
  width: 16px; height: 16px; margin-top: 2px; accent-color: #10b981; cursor: pointer; flex-shrink: 0;
}
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13px; font-weight: 500; word-break: break-word; line-height: 1.3; }
.task-meta { font-size: 10px; color: var(--text-dim); margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; }
.task-meta .b {
  background: var(--surface-2); padding: 1px 5px; border-radius: 3px; letter-spacing: .3px;
}
.task-meta .b.warn { background: rgba(239,68,68,.15); color: #fca5a5; }

.add-here {
  background: transparent; border: 1px dashed var(--border); color: var(--text-dim);
  width: 100%; padding: 6px; border-radius: var(--radius-sm); margin-top: 8px; cursor: pointer;
  font-size: 13px; transition: all .15s;
}
.add-here:hover { border-color: var(--text-muted); color: var(--text-muted); }

.axis-y-label {
  display: flex; justify-content: space-between; max-width: 1100px; margin: 8px auto 0; padding: 0 4px;
  font-size: 10px; letter-spacing: 1.2px; font-weight: 600; color: var(--text-dim);
}

.focus-card {
  max-width: 1100px; margin: 24px auto 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
.focus-card label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 600; letter-spacing: .5px; margin-bottom: 8px; }
.focus-card label i { color: #10b981; }
.focus-card textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--text); font-family: inherit; font-size: 14px; resize: vertical;
}
.focus-card textarea:focus { outline: none; border-color: #10b981; }

/* MODAL */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; max-width: 460px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal-content h3 { margin-bottom: 16px; font-size: 17px; }
.modal-content label { display: block; margin-bottom: 12px; font-size: 12px; color: var(--text-muted); font-weight: 500; }
.modal-content input, .modal-content select, .modal-content textarea {
  width: 100%; padding: 9px 11px; margin-top: 5px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; font-family: inherit;
}
.modal-content input:focus, .modal-content select:focus, .modal-content textarea:focus { outline: none; border-color: #10b981; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-2 label { margin-bottom: 12px; }
.modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

.btn-primary, .btn-secondary, .btn-danger {
  border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px;
  cursor: pointer; font-weight: 500; transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: #10b981; color: #0a0a0f; }
.btn-primary:hover { background: #34d399; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text-dim); }
.btn-danger { background: rgba(239,68,68,.15); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,.25); }

.warn {
  background: rgba(239,68,68,.1); color: #fca5a5; padding: 8px 12px; border-radius: 8px;
  font-size: 12px; margin-bottom: 12px; border: 1px solid rgba(239,68,68,.2);
}

.hidden { display: none !important; }

/* MOBILE */
@media (max-width: 720px) {
  .hero h1 { font-size: 26px; }
  .matrix { gap: 8px; }
  .quadrant { padding: 12px; min-height: 180px; }
  .quadrant h2 { font-size: 13px; }
  .tab { font-size: 12px; padding: 8px; }
  .tab i { font-size: 14px; }
}

/* ============ FEATURES v2 ============ */

/* Subsecciones dentro del cuadrante "Hacer ya" */
.subsection { margin-top: 10px; }
.subsection:first-child { margin-top: 0; }
.subsection-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim, #888);
  margin: 6px 0 4px 0;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.7;
}
.subsection-title i { font-size: 12px; }
.empty-row {
  color: var(--text-dim, #666);
  font-size: 11px;
  padding: 4px 0 4px 4px;
  font-style: italic;
  opacity: 0.5;
}

/* Focus bar (vista enfoque) */
.focus-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-wrap: wrap;
  background: rgba(255,255,255,0.02);
}
.focus-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-dim, #888);
  text-transform: uppercase;
}
.focus-chip {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text, #ddd);
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.focus-chip:hover { background: rgba(255,255,255,0.1); }
.focus-chip.active {
  background: var(--accent, #5b8def);
  color: #fff;
  border-color: transparent;
}

/* Badges de energía */
.task-meta .b.energy-high   { background: rgba(255, 90, 60, 0.18);  color: #ff7a5a; }
.task-meta .b.energy-medium { background: rgba(255, 200, 60, 0.18); color: #ffc83c; }
.task-meta .b.energy-low    { background: rgba(120, 200, 130, 0.18); color: #7ad07a; }
.task-meta .b.recur         { background: rgba(140, 120, 255, 0.18); color: #b3a8ff; }
.task-meta .b.ai            { background: rgba(91, 141, 239, 0.18); color: #8fb3ff; font-weight: 600; }

/* Modal: toggles, indents, hints */
.modal-content .toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  cursor: pointer;
}
.modal-content .toggle-row input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent, #5b8def);
  margin: 0;
}
.modal-content .indent {
  margin-left: 24px;
  padding-left: 8px;
  border-left: 2px solid rgba(255,255,255,0.08);
}
.modal-content .hint {
  display: block;
  font-size: 11px;
  color: var(--accent, #5b8def);
  margin-top: -4px;
  margin-bottom: 6px;
  padding-left: 2px;
}
.hidden { display: none !important; }

/* ============ SECTION SWITCH (Matriz vs Procesos) ============ */
.section-switch {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.015);
}
.sec-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text, #ddd);
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
}
.sec-btn:hover { background: rgba(255,255,255,0.07); }
.sec-btn.active {
  background: linear-gradient(135deg, rgba(91,141,239,0.25), rgba(91,141,239,0.1));
  border-color: rgba(91,141,239,0.5);
  color: #fff;
}
.sec-btn i { font-size: 16px; }
.forced-hidden { display: none !important; }

/* ============ VISTA PROCESOS ============ */
.proc-hero {
  padding: 20px 16px 4px;
  text-align: center;
}
.proc-hero h1 {
  font-size: 22px;
  margin: 6px 0 4px;
  letter-spacing: -0.02em;
}
.proc-sub {
  font-size: 12px;
  color: var(--text-dim, #888);
  margin: 0 auto;
  max-width: 540px;
  line-height: 1.5;
}

.proc-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  padding: 16px;
}
.proc-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.btn-primary.full { width: 100%; }
.proc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}
.proc-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.12s;
}
.proc-item:hover { background: rgba(255,255,255,0.06); }
.proc-item.active {
  background: linear-gradient(135deg, rgba(91,141,239,0.15), rgba(91,141,239,0.05));
  border-color: rgba(91,141,239,0.45);
}
.proc-item-main {
  display: flex;
  gap: 10px;
  align-items: center;
}
.proc-item-icon { font-size: 20px; }
.proc-item-text { flex: 1; min-width: 0; }
.proc-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #ddd);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proc-item-meta {
  font-size: 11px;
  color: var(--text-dim, #888);
  margin-top: 2px;
}
.proc-item-bar {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.proc-item-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #5b8def, #7ad07a);
  transition: width 0.3s;
}
.proc-empty-list {
  font-size: 12px;
  color: var(--text-dim, #888);
  padding: 16px;
  text-align: center;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 10px;
}

.proc-detail {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 18px;
  min-height: 400px;
}
.proc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  color: var(--text-dim, #888);
  text-align: center;
  padding: 60px 20px;
}
.proc-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.proc-detail-title {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  flex: 1;
  min-width: 0;
}
.proc-detail-icon { font-size: 32px; line-height: 1; }
.proc-detail-title h2 {
  font-size: 18px;
  margin: 0;
  letter-spacing: -0.01em;
}
.proc-detail-desc {
  font-size: 12px;
  color: var(--text-dim, #888);
  margin: 4px 0 0;
  line-height: 1.4;
}
.proc-detail-actions { display: flex; gap: 4px; }

.proc-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.proc-progress .bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.proc-progress .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #5b8def, #7ad07a);
  transition: width 0.3s;
}
.proc-pct {
  font-size: 11px;
  color: var(--text-dim, #888);
  font-weight: 600;
  white-space: nowrap;
}

.proc-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.proc-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  transition: all 0.12s;
  cursor: grab;
}
.proc-step:hover { background: rgba(255,255,255,0.05); }
.proc-step.dragging { opacity: 0.4; }
.proc-step.drop-target {
  border-top: 2px solid var(--accent, #5b8def);
}
.proc-step.done { opacity: 0.5; }
.proc-step.done .proc-step-text {
  text-decoration: line-through;
  color: var(--text-dim, #888);
}
.proc-step-num {
  background: rgba(91,141,239,0.18);
  color: #8fb3ff;
  font-size: 11px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.proc-step input[type=checkbox] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent, #5b8def);
  margin-top: 2px;
  flex-shrink: 0;
  cursor: pointer;
}
.proc-step-body { flex: 1; min-width: 0; }
.proc-step-text {
  font-size: 13px;
  color: var(--text, #ddd);
  line-height: 1.4;
}
.proc-step-note {
  font-size: 11px;
  color: var(--text-dim, #888);
  margin-top: 4px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.proc-step-edit {
  background: transparent;
  border: none;
  color: var(--text-dim, #888);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0.5;
  transition: opacity 0.12s;
}
.proc-step:hover .proc-step-edit { opacity: 1; }
.proc-step-edit:hover { background: rgba(255,255,255,0.08); color: var(--text, #ddd); }

@media (max-width: 720px) {
  .proc-layout { grid-template-columns: 1fr; }
  .proc-sidebar { order: 1; }
  .proc-detail { order: 2; }
}

/* ============ TYPE TOGGLE (Tarea / Evento) ============ */
.type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 4px;
}
.type-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: var(--text, #ddd);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.12s;
}
.type-btn:hover { background: rgba(255,255,255,0.07); }
.type-btn i { font-size: 22px; color: var(--text-dim, #888); }
.type-btn .type-name { font-size: 13px; font-weight: 700; }
.type-btn small { font-size: 11px; color: var(--text-dim, #888); display: block; margin-top: 2px; }
.type-btn.active {
  background: linear-gradient(135deg, rgba(91,141,239,0.18), rgba(91,141,239,0.06));
  border-color: rgba(91,141,239,0.5);
}
.type-btn.active i { color: #8fb3ff; }

/* ============ RECURRENCIA ============ */
.dow-chips {
  display: flex;
  gap: 4px;
  margin: 6px 0 8px;
  flex-wrap: wrap;
}
.dow-chip {
  flex: 1;
  min-width: 32px;
  height: 36px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text, #ddd);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
}
.dow-chip:hover { background: rgba(255,255,255,0.08); }
.dow-chip.active {
  background: linear-gradient(135deg, rgba(91,141,239,0.4), rgba(91,141,239,0.15));
  border-color: rgba(91,141,239,0.6);
  color: #fff;
}

/* ============ EJE Y LATERAL ============ */
.matrix-with-axis {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: stretch;
}
.axis-y-side {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  position: relative;
}
.axis-y-side span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-dim, #888);
  text-align: center;
  padding: 8px 0;
  opacity: 0.7;
}
.axis-y-side .axis-y-top { color: #ffd47a; }   /* mismo tono cálido = importante */
.axis-y-side .axis-y-bot { color: #888; }
.axis-y-label { display: none; }   /* ocultar el antiguo */

@media (max-width: 720px) {
  .matrix-with-axis { grid-template-columns: 20px 1fr; gap: 4px; }
  .axis-y-side span { font-size: 9px; padding: 4px 0; }
}

/* ============ AJUSTES VISUALES MATRIZ v2 ============ */
/* Labels más pegados al cuadrante + cuadrantes más grandes */
.matrix-with-axis {
  grid-template-columns: 22px 1fr !important;
  gap: 4px !important;
}
.axis-y-side span {
  padding: 4px 0 !important;
  font-size: 11px !important;
  letter-spacing: 0.18em !important;
}

/* Cuadrantes más espaciosos para mejor visualización */
.quadrant {
  min-height: 280px !important;
  padding: 18px !important;
}
.quadrant .tasks {
  flex: 1;
  min-height: 60px;
}

/* Mobile: ajustes proporcionales */
@media (max-width: 720px) {
  .matrix-with-axis { grid-template-columns: 16px 1fr !important; gap: 2px !important; }
  .axis-y-side span { font-size: 10px !important; padding: 2px 0 !important; }
  .quadrant { min-height: 220px !important; padding: 14px !important; }
}

/* ============ COMPORTAMIENTO TIPO APP NATIVA ============ */
/* Sin pinch-zoom, sin pull-to-refresh, sin selección accidental */
html, body {
  touch-action: pan-x pan-y;          /* permite scroll, bloquea pinch-zoom */
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;          /* sin bounce/refresh al deslizar */
}
button, .icon-btn, .tab, .sec-btn, .type-btn, .focus-chip, .dow-chip {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* Inputs con texto pueden seleccionarse; el resto no */
body * {
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

/* ============ SAFE AREA iPhone (notch / dynamic island / home indicator) ============ */
.app-header {
  padding-top: max(env(safe-area-inset-top), 14px) !important;
  padding-left: max(env(safe-area-inset-left), 16px) !important;
  padding-right: max(env(safe-area-inset-right), 16px) !important;
}
.section-switch {
  padding-left: max(env(safe-area-inset-left), 16px) !important;
  padding-right: max(env(safe-area-inset-right), 16px) !important;
}
body {
  padding-bottom: env(safe-area-inset-bottom);
  /* Bloquea zoom y rebote en standalone */
  overscroll-behavior: contain;
  position: relative;
}

/* ============ ANTI-ZOOM iOS REFORZADO ============ */
* { touch-action: manipulation; }
.matrix, .matrix-with-axis, .quadrant, .proc-detail, .proc-sidebar { touch-action: pan-y; }
/* Evita que iOS aumente fuente al rotar */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* Evita que inputs hagan zoom: tamaño 16+ */
input[type=text], input[type=number], input[type=date], input[type=time], textarea, select {
  font-size: 16px !important;
}

/* ============ CUADRANTES TAMAÑO FIJO (Mac 13" + iPhone) ============ */
/* Altura fija sin que crezcan con el contenido. Scroll interno si rebasa. */
.quadrant {
  height: 320px !important;
  min-height: 320px !important;
  max-height: 320px !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
}
.quadrant .tasks {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
}
.quadrant .tasks::-webkit-scrollbar { width: 4px; }
.quadrant .tasks::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.quadrant .tasks::-webkit-scrollbar-track { background: transparent; }
.quadrant .add-here { flex-shrink: 0; }
.quadrant .subsection { min-height: 0; display: flex; flex-direction: column; }

@media (max-width: 720px) {
  .quadrant {
    height: 240px !important;
    min-height: 240px !important;
    max-height: 240px !important;
  }
}

/* ============ HERO COMPACTO + MATRIZ CENTRADA Y AMPLIA ============ */
.hero.compact {
  padding: 16px 16px 12px;
  text-align: center;
}
.hero.compact .hero-date {
  font-size: 14px;
  margin: 8px 0;
  color: var(--text-muted, #8b8ba0);
  font-weight: 500;
}
.status-pill.small {
  font-size: 10px !important;
  padding: 5px 12px !important;
  letter-spacing: 0.1em;
}
.hero.compact .progress-mini { max-width: 480px; margin: 8px auto 0; }

/* Desktop: matriz ancha centrada con cuadrantes más grandes */
@media (min-width: 721px) {
  main#app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 32px 32px;
  }
  .matrix {
    gap: 16px !important;
  }
  .matrix-with-axis {
    grid-template-columns: 30px 1fr !important;
    gap: 6px !important;
    max-width: 1100px;
    margin: 0 auto;
  }
  .quadrant {
    height: 380px !important;
    min-height: 380px !important;
    max-height: 380px !important;
    padding: 22px !important;
  }
  .quadrant h2 { font-size: 17px !important; }
  .axis-x { max-width: 1100px; margin: 0 auto; }
}

/* ============ DESKTOP LAYOUT v3 — matriz amplia + todo visible ============ */
@media (min-width: 721px) {
  main#app {
    max-width: 1400px !important;
    padding: 0 24px 16px !important;
  }
  .hero.compact {
    padding: 8px 16px 6px !important;
  }
  .hero.compact .hero-date {
    font-size: 16px !important;
    margin: 0 0 6px !important;
    font-weight: 600;
  }
  .hero.compact .progress-mini {
    max-width: 420px;
    margin: 4px auto 0;
  }
  /* Matriz ancha, cuadrantes anchos */
  .matrix-with-axis {
    max-width: 1340px !important;
    grid-template-columns: 28px 1fr !important;
    gap: 8px !important;
  }
  .matrix {
    gap: 14px !important;
    grid-template-columns: 1fr 1fr !important;
  }
  .quadrant {
    height: 340px !important;
    min-height: 340px !important;
    max-height: 340px !important;
    padding: 20px 22px !important;
  }
  .quadrant h2 { font-size: 18px !important; }
  .quadrant small { font-size: 11px !important; }
  .axis-x {
    max-width: 1340px;
    margin: 0 auto;
    padding: 0 4px;
  }
  /* Foco del día más compacto */
  .focus-card {
    margin-top: 14px !important;
    padding: 12px 16px !important;
  }
  .focus-card textarea {
    min-height: 40px !important;
  }
  /* Switch matriz/procesos un poco menor */
  .section-switch {
    padding: 6px 16px !important;
  }
  .sec-btn { padding: 8px 12px !important; font-size: 13px !important; }
  /* Tabs menores */
  .tabs { padding: 6px 16px !important; }
  .tab { padding: 6px 10px !important; font-size: 12px !important; }
}

/* FIX: matriz debe llenar todo su contenedor (override de max-width antiguo) */
@media (min-width: 721px) {
  .matrix {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 16px !important;
  }
  .matrix-with-axis > .matrix { min-width: 0; }
}

/* ============ DESKTOP v4: todo en 1 vistazo (más compacto arriba) ============ */
@media (min-width: 721px) {
  .hero.compact { padding: 4px 16px 4px !important; }
  .hero.compact .hero-date { font-size: 15px !important; margin: 0 0 4px !important; }
  .hero.compact .progress-mini { margin: 2px auto 0 !important; }
  .section-switch { padding: 4px 16px !important; }
  .sec-btn { padding: 7px 12px !important; }
  .tabs { padding: 4px 16px !important; }
  .quadrant {
    height: clamp(260px, calc((100vh - 340px) / 2), 360px) !important;
    min-height: 260px !important;
    max-height: 360px !important;
    padding: 18px 20px !important;
  }
  .focus-card { margin-top: 10px !important; padding: 10px 14px !important; }
  .focus-card textarea { min-height: 32px !important; }
}

/* ============ iPHONE: bottom navigation (Matriz / Procesos) ============ */
@media (max-width: 720px) {
  .section-switch {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding: 8px max(env(safe-area-inset-left), 12px) max(env(safe-area-inset-bottom), 10px) !important;
    background: rgba(10,10,15,0.96) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top: 1px solid var(--border) !important;
    border-bottom: none !important;
    z-index: 100 !important;
    gap: 6px !important;
  }
  .sec-btn {
    flex-direction: column !important;
    gap: 2px !important;
    padding: 8px 10px !important;
    font-size: 11px !important;
    background: transparent !important;
    border: none !important;
  }
  .sec-btn i {
    font-size: 22px !important;
    color: var(--text-dim) !important;
  }
  .sec-btn.active {
    background: transparent !important;
    color: #10b981 !important;
  }
  .sec-btn.active i { color: #10b981 !important; }
  /* Espacio para el contenido no tapado por bottom nav */
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)) !important; }
}

/* ============ TASK ROW INLINE (título + meta a la derecha) ============ */
.task {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 8px 10px !important;
}
.task input[type=checkbox] {
  flex-shrink: 0;
}
.task .task-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.task-meta-inline {
  display: flex;
  gap: 6px;
  font-size: 10px;
  color: var(--text-dim, #888);
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.7;
  align-items: center;
}
.task-meta-inline .m-time { font-variant-numeric: tabular-nums; }
.task-meta-inline .m-warn { color: #ef4444; opacity: 1; }
.task-meta-inline .b { padding: 1px 5px; }
.task-meta-inline .b.energy-high, .task-meta-inline .b.energy-medium, .task-meta-inline .b.energy-low,
.task-meta-inline .b.recur, .task-meta-inline .b.ai { font-size: 10px; }
/* Ya no se muestra la meta debajo del título */
.task .task-meta { display: none !important; }
.task .task-body { display: none !important; }  /* refactor inline directo */

/* ============ ALTURAS DINÁMICAS DE CUADRANTES ============ */
/* JS iguala los 4 cuadrantes. Quitamos altura fija para que crezca con contenido. */
.quadrant {
  height: auto !important;
  max-height: none !important;
  min-height: 240px !important;
}
@media (min-width: 721px) {
  .quadrant { min-height: 280px !important; }
}
.quadrant .tasks { overflow-y: visible !important; }

/* Drop highlight en tabs (al arrastrar tarea entre Diario/Semanal/Mensual) */
.tab.drag-over {
  background: rgba(91,141,239,0.25) !important;
  border-color: rgba(91,141,239,0.6) !important;
  color: #fff !important;
}

.task-meta-inline .m-date {
  background: rgba(255,255,255,0.06);
  padding: 2px 7px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
  text-transform: capitalize;
}

.brand-icon { width: 26px; height: 26px; border-radius: 7px; }
