/* Panel Aurvël — sistema visual
   Paleta de marca (verde imperial, oro viejo, crema) adaptada a interfaz de datos. */

:root {
  --bg: #F6F4EE;
  --surface: #FFFFFF;
  --surface-2: #FAF8F3;
  --surface-3: #F1EDE4;
  --border: #E6E0D4;
  --border-strong: #D3C9B6;
  --text: #1E2622;
  --text-2: #56605A;
  --text-3: #858C86;
  --primary: #1B3A2A;
  --primary-hover: #2C5340;
  --on-primary: #F7F2E7;
  --accent: #7A5E24;
  --gold: #C9A55C;
  --ring: rgba(44, 83, 64, .35);
  --danger: #8F3427;
  --warn: #A06A1F;
  --ok: #2F6B4A;

  --nav-bg: #142E20;
  --nav-text: #CFD8D1;
  --nav-text-strong: #F2EDE3;
  --nav-hover: rgba(242, 237, 227, .07);
  --nav-active: rgba(201, 165, 92, .14);

  /* Estados de cliente */
  --st-prospecto: #4E6A80;
  --st-propuesta: #8A6A22;
  --st-en-curso: #2B6390;
  --st-pendiente: #B05A22;
  --st-pausa: #7C847E;
  --st-finalizado: #2F6B4A;
  --st-ko: #993A2C;

  /* Tipos de evento */
  --ev-publicacion: #7B4F9E;
  --ev-reunion: #2B6390;
  --ev-entrega: #2F6B4A;
  --ev-cobro: #8A6A22;
  --ev-recordatorio: #B05A22;
  --ev-otro: #6B746E;

  --shadow-sm: 0 1px 2px rgba(20, 30, 25, .05);
  --shadow: 0 1px 2px rgba(20, 30, 25, .04), 0 4px 16px rgba(20, 30, 25, .06);
  --shadow-lg: 0 8px 40px rgba(14, 22, 18, .18);
  --radius: 8px;
  --radius-sm: 6px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --font: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --sidebar: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D1511; --surface: #131D18; --surface-2: #17221C; --surface-3: #1C2922;
    --border: #233229; --border-strong: #31443A;
    --text: #ECE8DF; --text-2: #A8B1AA; --text-3: #75807A;
    --primary: #C9A55C; --primary-hover: #D6B673; --on-primary: #142E20; --accent: #D6B673;
    --ring: rgba(201, 165, 92, .45);
    --danger: #E07B6A; --warn: #E0A15A; --ok: #6FBF92;
    --nav-bg: #0A110D; --nav-hover: rgba(242, 237, 227, .05);
    --st-prospecto: #8EAAC0; --st-propuesta: #D9B66A; --st-en-curso: #6FA8D8; --st-pendiente: #E6935A;
    --st-pausa: #9BA39D; --st-finalizado: #6FBF92; --st-ko: #E07B6A;
    --ev-publicacion: #B58AD8; --ev-reunion: #6FA8D8; --ev-entrega: #6FBF92; --ev-cobro: #D9B66A; --ev-recordatorio: #E6935A; --ev-otro: #9BA39D;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D1511; --surface: #131D18; --surface-2: #17221C; --surface-3: #1C2922;
  --border: #233229; --border-strong: #31443A;
  --text: #ECE8DF; --text-2: #A8B1AA; --text-3: #75807A;
  --primary: #C9A55C; --primary-hover: #D6B673; --on-primary: #142E20; --accent: #D6B673;
  --ring: rgba(201, 165, 92, .45);
  --danger: #E07B6A; --warn: #E0A15A; --ok: #6FBF92;
  --nav-bg: #0A110D; --nav-hover: rgba(242, 237, 227, .05);
  --st-prospecto: #8EAAC0; --st-propuesta: #D9B66A; --st-en-curso: #6FA8D8; --st-pendiente: #E6935A;
  --st-pausa: #9BA39D; --st-finalizado: #6FBF92; --st-ko: #E07B6A;
  --ev-publicacion: #B58AD8; --ev-reunion: #6FA8D8; --ev-entrega: #6FBF92; --ev-cobro: #D9B66A; --ev-recordatorio: #E6935A; --ev-otro: #9BA39D;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 400 14.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  font-feature-settings: 'tnum' 1;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* Arranque */
.boot { min-height: 100vh; display: grid; place-content: center; gap: 18px; justify-items: center; }
.boot-mark { font-family: var(--font-display); font-size: 40px; color: var(--primary); letter-spacing: .02em; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Estructura */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column; padding: 20px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; background: linear-gradient(140deg, #D9BC7E, #A8853F); color: #142E20; font: 600 15px var(--font-display); }
.brand-name { font-family: var(--font-display); font-size: 25px; color: var(--nav-text-strong); line-height: 1; letter-spacing: .01em; }
.brand-sub { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #8FA197; margin-top: 3px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #6F8478; padding: 14px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--nav-text); text-decoration: none; font-weight: 500; position: relative;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.nav a:hover { background: var(--nav-hover); color: var(--nav-text-strong); }
.nav a.active { background: var(--nav-active); color: var(--nav-text-strong); }
.nav a.active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold); }
.nav a svg { width: 18px; height: 18px; opacity: .9; }
.nav .count { margin-left: auto; font-size: 12px; color: #93A59A; font-weight: 500; }
.nav .count.alert { color: #F0C987; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(242, 237, 227, .08); padding-top: 14px; display: grid; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; background: #2C5340; color: #F2EDE3; flex: none; }
.avatar.sm { width: 22px; height: 22px; font-size: 10.5px; }
.avatar.alexia { background: #7A5E24; }
.avatar.claude { background: #5C4A7A; }
.me-name { color: var(--nav-text-strong); font-weight: 500; font-size: 14px; line-height: 1.2; }
.me-mail { font-size: 11.5px; color: #8FA197; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.foot-row { display: flex; gap: 6px; }
.nav-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 8px; border-radius: var(--radius-sm); border: 1px solid rgba(242, 237, 227, .1); background: transparent; color: var(--nav-text); font-size: 12.5px; }
.nav-btn:hover { background: var(--nav-hover); color: var(--nav-text-strong); }
.nav-btn svg { width: 15px; height: 15px; }
.sync { font-size: 11.5px; color: #7F9387; padding: 0 6px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 32px; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px); -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font: 600 17px var(--font); letter-spacing: -.005em; }
.topbar .crumb { color: var(--text-3); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { padding: 28px 32px 64px; max-width: 1360px; width: 100%; }
.mobile-only { display: none !important; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 14px; white-space: nowrap; transition: background .18s var(--ease), border-color .18s var(--ease), opacity .18s;
}
.btn:hover { background: var(--surface-3); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn:disabled { opacity: .55; cursor: default; }

/* Cabecera de página */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font: 500 32px/1.1 var(--font-display); margin: 0; letter-spacing: -.005em; }
.page-sub { color: var(--text-2); margin-top: 6px; }
.page-head .spacer { flex: 1; }

/* Tarjetas */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .hint { color: var(--text-3); font-size: 12.5px; }
.card-head .right { margin-left: auto; }
.card-body { padding: 16px 18px; }
.card-empty { padding: 26px 18px; text-align: center; color: var(--text-3); font-size: 13.5px; }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
.kpi { padding: 16px 18px 15px; position: relative; overflow: hidden; }
.kpi-label { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi-label svg { width: 15px; height: 15px; color: var(--text-3); }
.kpi-value { font-size: 27px; font-weight: 500; letter-spacing: -.015em; margin-top: 8px; line-height: 1.1; }
.kpi-value small { font-size: 14px; color: var(--text-3); font-weight: 500; margin-left: 4px; letter-spacing: 0; }
.kpi-foot { margin-top: 6px; font-size: 12.5px; color: var(--text-3); }
.kpi-foot b { color: var(--text-2); font-weight: 500; }
.kpi.accent::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold); }

/* Listas de atención / agenda */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); cursor: pointer; transition: background .15s var(--ease); }
.list-item:first-child { border-top: 0; }
.list-item:hover { background: var(--surface-2); }
.li-icon { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--text-2); }
.li-icon svg { width: 16px; height: 16px; }
.li-icon.red { background: color-mix(in srgb, var(--danger) 13%, transparent); color: var(--danger); }
.li-icon.amber { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.li-icon.green { background: color-mix(in srgb, var(--ok) 13%, transparent); color: var(--ok); }
.li-main { min-width: 0; flex: 1; }
.li-title { font-weight: 500; line-height: 1.35; }
.li-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; line-height: 1.4; }
.li-meta { margin-left: auto; text-align: right; font-size: 12.5px; color: var(--text-3); white-space: nowrap; padding-left: 8px; }
.li-meta.red { color: var(--danger); font-weight: 500; }
.li-meta.amber { color: var(--warn); font-weight: 500; }

.day-group { padding: 10px 18px 4px; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); font-weight: 600; border-top: 1px solid var(--border); }
.day-group:first-child { border-top: 0; }
.day-group.today { color: var(--accent); }

/* Barra de cartera */
.funnel { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.funnel span { display: block; min-width: 6px; transition: opacity .2s; }
.funnel span:hover { opacity: .8; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; }
.legend button { border: 0; background: none; padding: 0; display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); }
.legend button:hover { color: var(--text); }
.legend b { color: var(--text); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* Actividad */
.feed { list-style: none; margin: 0; padding: 4px 0; }
.feed li { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding: 10px 18px; position: relative; }
.feed li::before { content: ''; position: absolute; left: 28.5px; top: 34px; bottom: -10px; width: 1px; background: var(--border); }
.feed li:last-child::before { display: none; }
.feed-who { font-size: 13px; color: var(--text-2); }
.feed-who b { color: var(--text); font-weight: 600; }
.feed-who a { font-weight: 600; text-decoration: none; color: var(--text); }
.feed-who a:hover { text-decoration: underline; }
.feed-text { margin-top: 3px; line-height: 1.5; overflow-wrap: anywhere; }
.feed-text.auto { color: var(--text-2); font-size: 13.5px; }
.feed-date { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.sys-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border-strong); display: grid; place-items: center; color: var(--text-3); }
.sys-dot svg { width: 12px; height: 12px; }

/* Insignias */
.badge {
  --c: var(--text-3);
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 8px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap; color: var(--c);
  background: color-mix(in srgb, var(--c) 11%, transparent); border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.badge.plain::before { display: none; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); }
.tag svg { width: 13px; height: 13px; }
.pelota-nuestra { color: var(--ok); }
.pelota-suya { color: var(--text-3); }
.pelota-mixta { color: var(--warn); }
.prio { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.prio-alta { background: var(--danger); }
.prio-media { background: var(--warn); }
.prio-baja { background: var(--border-strong); }

/* Barra de herramientas */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search { position: relative; flex: 0 1 320px; min-width: 220px; }
.toolbar .chips { flex: 1; min-width: 0; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.search input { width: 100%; height: 36px; padding: 0 12px 0 34px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); outline: none; }
.search input:focus { border-color: var(--primary-hover); box-shadow: 0 0 0 3px var(--ring); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 1px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); font-size: 13px; color: var(--text-2); white-space: nowrap; flex: none;
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip .n { font-size: 12px; opacity: .7; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; height: 34px; padding: 0 11px; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--surface-3); color: var(--text); font-weight: 500; }
.seg svg { width: 15px; height: 15px; }

/* Tabla */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase;
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; user-select: none;
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { color: var(--text); }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { cursor: pointer; transition: background .12s var(--ease); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .r { text-align: right; }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.cell-action { max-width: 380px; line-height: 1.4; }
.date-chip { font-size: 12.5px; color: var(--text-2); margin-top: 3px; display: inline-flex; gap: 5px; align-items: center; }
.date-chip svg { width: 12px; height: 12px; }
.date-chip.over { color: var(--danger); font-weight: 500; }
.date-chip.soon { color: var(--warn); font-weight: 500; }

/* Tarjetas de cliente (móvil) */
.client-cards { display: grid; gap: 10px; }
.client-card { padding: 14px 15px; cursor: pointer; }
.client-card .row1 { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.client-card .name { font-weight: 600; font-size: 15.5px; }
.client-card .fase { color: var(--text-2); font-size: 13.5px; margin-top: 6px; line-height: 1.4; }
.client-card .next { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 13.5px; line-height: 1.4; }
.client-card .next-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); font-weight: 600; margin-bottom: 3px; }
.client-card .row3 { display: flex; gap: 12px; align-items: center; margin-top: 10px; flex-wrap: wrap; }

/* Kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--surface-3); border-radius: var(--radius); padding: 10px; min-height: 140px; display: flex; flex-direction: column; gap: 8px; }
.col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 6px; font-weight: 600; font-size: 13.5px; }
.col-head .n { color: var(--text-3); font-weight: 500; }
.col-head .sum { margin-left: auto; color: var(--text-3); font-size: 12px; font-weight: 500; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; cursor: pointer; box-shadow: var(--shadow-sm); transition: border-color .15s var(--ease), transform .15s var(--ease); }
.kcard:hover { border-color: var(--border-strong); }
.kcard .name { font-weight: 600; font-size: 14px; }
.kcard .txt { font-size: 13px; color: var(--text-2); margin-top: 5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.kcard .foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; font-size: 12px; color: var(--text-3); }
.kcard .foot .amt { margin-left: auto; color: var(--text-2); font-weight: 500; }

/* Panel lateral (detalle) */
.scrim { position: fixed; inset: 0; background: rgba(10, 16, 13, .38); z-index: 40; animation: fade .2s var(--ease); }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); z-index: 41; background: var(--bg);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .28s var(--ease);
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { padding: 16px 22px 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.drawer-top { display: flex; align-items: flex-start; gap: 10px; }
.drawer-title { font: 500 28px/1.15 var(--font-display); margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.drawer-meta { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 8px; font-size: 13px; color: var(--text-2); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 40px; -webkit-overflow-scrolling: touch; }
.tabs { display: flex; gap: 20px; margin-top: 14px; }
.tabs button { border: 0; background: none; padding: 10px 0 11px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; display: inline-flex; gap: 6px; align-items: center; }
.tabs button.on { color: var(--text); border-bottom-color: var(--primary); }
.tabs .n { font-size: 12px; color: var(--text-3); }

.status-picker { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 2px; }
.status-picker button {
  --c: var(--text-3);
  height: 30px; padding: 0 11px; border-radius: 999px; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
}
.status-picker button::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.status-picker button:hover { border-color: var(--c); color: var(--text); }
.status-picker button.on { background: color-mix(in srgb, var(--c) 13%, var(--surface)); border-color: var(--c); color: var(--c); }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.fact { background: var(--surface); padding: 11px 14px; min-width: 0; }
.fact.wide { grid-column: 1 / -1; }
.fact-label { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.fact-value { margin-top: 3px; overflow-wrap: anywhere; line-height: 1.45; }
.fact-value.empty { color: var(--text-3); }
.next-box { border: 1px solid var(--border); border-left: 3px solid var(--gold); background: var(--surface); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.next-box .fact-value { font-weight: 500; font-size: 15px; }
.next-box.over { border-left-color: var(--danger); }

.composer { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 10px; margin-bottom: 14px; }
.composer textarea { width: 100%; border: 0; outline: none; resize: vertical; min-height: 64px; background: transparent; font-size: 15px; line-height: 1.5; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer:focus-within { border-color: var(--primary-hover); box-shadow: 0 0 0 3px var(--ring); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 0 0 18px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: 12.5px; top: 28px; bottom: 2px; width: 1px; background: var(--border-strong); }
.timeline li:last-child::before { display: none; }
.timeline .bubble { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.timeline .bubble.auto { background: transparent; border-style: dashed; color: var(--text-2); font-size: 13.5px; }
.timeline .who { font-size: 12.5px; color: var(--text-3); margin-bottom: 4px; }
.timeline .who b { color: var(--text-2); font-weight: 600; }
.timeline .txt { line-height: 1.55; overflow-wrap: anywhere; }

.md { line-height: 1.6; overflow-wrap: anywhere; }
.md h1 { font: 500 26px/1.2 var(--font-display); margin: 4px 0 12px; }
.md h2 { font-size: 17px; margin: 24px 0 8px; }
.md h3 { font-size: 15px; margin: 20px 0 6px; }
.md table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 10px 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md blockquote { margin: 12px 0; padding: 10px 14px; border-left: 3px solid var(--gold); background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-2); }
.md code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.md a { color: var(--accent); }
.wikilink { color: var(--accent); font-weight: 500; }

/* Formularios */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 38px; padding: 8px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); outline: none; font-size: 14.5px;
}
.field textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary-hover); box-shadow: 0 0 0 3px var(--ring); }
.field .help { font-size: 12px; color: var(--text-3); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.inline-2 { display: grid; grid-template-columns: 1fr 110px; gap: 8px; }

/* Modal */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal-wrap .scrim { z-index: 0; }
.modal { position: relative; z-index: 1; width: min(560px, 100%); max-height: calc(100vh - 40px); background: var(--bg); border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: pop .22s var(--ease); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-head { padding: 16px 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); background: var(--surface); border-radius: 10px 10px 0 0; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: center; background: var(--surface); border-radius: 0 0 10px 10px; }
.modal-foot .spacer { flex: 1; }

/* Menú */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 5px; z-index: 30; animation: pop .16s var(--ease); }
.menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; background: none; border-radius: var(--radius-sm); text-align: left; font-size: 14px; }
.menu button:hover { background: var(--surface-3); }
.menu svg { width: 16px; height: 16px; color: var(--text-2); }
.menu small { display: block; color: var(--text-3); font-size: 12px; }

/* Facturación */
.chart { width: 100%; height: auto; max-height: 230px; display: block; }
.chart text { font-size: 11px; fill: var(--text-3); font-family: var(--font); }
.chart .bar-a { fill: var(--border-strong); }
.chart .bar-b { fill: var(--primary); }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 2 3; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); }
.chart-legend span { display: inline-flex; gap: 6px; align-items: center; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.progress { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: 6px; width: 90px; margin-left: auto; }
.progress span { display: block; height: 100%; background: var(--ok); }

/* Calendario */
.cal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-month { font: 500 28px/1 var(--font-display); margin: 0 6px; min-width: 210px; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--border); gap: 1px; }
.cal-dow { background: var(--surface-2); padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; }
.cal-day { background: var(--surface); min-height: 118px; padding: 6px 6px 8px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; transition: background .12s var(--ease); min-width: 0; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.out { background: var(--surface-2); }
.cal-day.out .cal-num { color: var(--text-3); opacity: .6; }
.cal-day.weekend { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.cal-num { font-size: 13px; font-weight: 500; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: var(--text-2); }
.cal-day.today .cal-num { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--primary-hover); }
.ev {
  --c: var(--ev-otro);
  display: flex; align-items: center; gap: 5px; font-size: 12px; line-height: 1.25; padding: 3px 6px; border-radius: 4px;
  background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--text); border-left: 3px solid var(--c);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: left; border-top: 0; border-right: 0; border-bottom: 0; width: 100%; min-width: 0;
}
.ev span.t { overflow: hidden; text-overflow: ellipsis; }
.ev .h { color: var(--text-2); font-variant-numeric: tabular-nums; flex: none; }
.ev.derived { background: transparent; border-left-style: dashed; color: var(--text-2); }
.ev.done { opacity: .5; text-decoration: line-through; }
.ev-more { font-size: 11.5px; color: var(--text-3); padding-left: 6px; }
.cal-dots { display: none; }
.agenda-ev { display: flex; gap: 12px; align-items: flex-start; padding: 11px 18px; border-top: 1px solid var(--border); cursor: pointer; }
.agenda-ev:hover { background: var(--surface-2); }
.agenda-ev .bar { width: 3px; align-self: stretch; border-radius: 2px; background: var(--c); flex: none; }
.agenda-ev .bar.dashed { background: none; border-left: 3px dashed var(--c); width: 0; }
.agenda-ev .time { width: 54px; flex: none; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; padding-top: 1px; }
.type-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-top: 12px; }
.type-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Avisos */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; pointer-events: none; }
.toast { background: #142E20; color: #F2EDE3; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 14px; display: flex; gap: 9px; align-items: center; animation: pop .2s var(--ease); pointer-events: auto; }
.toast svg { width: 16px; height: 16px; color: #C9A55C; }
.toast.err { background: #5E231A; }
.toast.err svg { color: #F2C3B9; }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn) 8%, var(--surface)); margin-bottom: 16px; }
.banner svg { width: 18px; height: 18px; color: var(--warn); flex: none; margin-top: 2px; }
.center-msg { max-width: 520px; margin: 12vh auto; text-align: center; padding: 0 20px; }
.center-msg h2 { font: 500 30px var(--font-display); margin: 0 0 10px; }

.tabbar { display: none; }
.fab-row { display: none; }

/* ---------- Tableta y móvil ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-only { display: revert !important; }
  .topbar .brand-mark.mobile-only { display: grid !important; }
  .desktop-only { display: none !important; }
  .topbar { padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .topbar h1 { font-size: 16px; }
  .content { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
  .page-title { font-size: 29px; }
  .page-head { margin-bottom: 16px; }
  .kpis { gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi-value { font-size: 22px; }
  .search { max-width: none; min-width: 0; flex-basis: 100%; }
  .search input, .field input, .field select, .field textarea, .composer textarea { font-size: 16px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 500; color: var(--text-3); text-decoration: none; padding: 5px 0; position: relative; }
  .tabbar a svg { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--primary); }
  .tabbar .badge-n { position: absolute; top: 1px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10.5px; display: grid; place-items: center; }
  .drawer { width: 100vw; }
  .drawer-head { padding: calc(12px + env(safe-area-inset-top)) 16px 0; }
  .drawer-body { padding: 16px 16px calc(40px + env(safe-area-inset-bottom)); }
  .drawer-title { font-size: 25px; }
  .status-picker { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -16px; padding-right: 16px; }
  .status-picker button { flex: none; }
  .form { grid-template-columns: 1fr; }
  .modal-wrap { padding: 0; place-items: end stretch; }
  .modal { width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; }
  .modal-head { border-radius: 14px 14px 0 0; }
  .modal-foot { border-radius: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .cal-day { min-height: 54px; padding: 4px 2px; align-items: center; }
  .cal-day .ev, .cal-day .ev-more { display: none; }
  .cal-dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; max-width: 34px; }
  .cal-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--c); }
  .cal-dow { padding: 6px 0; text-align: center; font-size: 11px; }
  .cal-month { font-size: 24px; min-width: 0; flex: 1; }
  .list-item { padding: 12px 14px; }
  .card-head { padding: 13px 14px; }
  .toasts { bottom: calc(86px + env(safe-area-inset-bottom)); width: calc(100% - 32px); }
  .board { grid-auto-columns: 82%; scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
}

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