/* ============================================================
   SISTEMA-EVENTOS — Sistema de diseño
   Software de operaciones profesional: sobrio, denso, legible.
   Una sola familia tipográfica, iconos SVG de trazo, un acento.
   ============================================================ */
:root {
  --bg: #f5f5f3;
  --card: #ffffff;
  --line: #e7e6e2;
  --line-strong: #d8d7d2;
  --ink: #17181c;
  --side: #14151a;
  --side-hover: #1e2026;
  --side-active: #26282f;
  --text: #212328;
  --text-dim: #6d7076;
  --accent: #c86f0c;
  --accent-strong: #a95c07;
  --accent-soft: #faf0e0;
  --ok: #1e7a4c;
  --ok-soft: #e4f2ea;
  --warn: #a96206;
  --warn-soft: #faf0dc;
  --danger: #b3362b;
  --danger-soft: #f9e6e3;
  --info: #22608f;
  --info-soft: #e5eef6;
  --violet: #5d4a9c;
  --violet-soft: #ece8f7;
  --radius: 10px;
  --font: "Instrument Sans", -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }
#app { display: flex; min-height: 100vh; }

svg.ico { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: -3px; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 218px; flex-shrink: 0;
  background: var(--side);
  color: #a6a9b0;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; }
.brand-mark {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  border-radius: 8px; font-weight: 700; font-size: 14px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name {
  font-weight: 650; font-size: 13.5px; color: #fff; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub { font-size: 10.5px; color: #71747c; }
.nav { display: flex; flex-direction: column; padding: 4px 10px 10px; gap: 1px; flex: 1; overflow-y: auto; }
.nav-group {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600;
  color: #5a5d65; padding: 16px 10px 5px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px;
  color: #a6a9b0; text-decoration: none; font-weight: 500; font-size: 13.5px;
  transition: background .1s, color .1s;
}
.nav a:hover { background: var(--side-hover); color: #e8e9ec; }
.nav a.active { background: var(--side-active); color: #fff; }
.nav a.active .nav-ico { color: var(--accent); }
.nav-ico { width: 18px; display: grid; place-items: center; color: #7c7f88; }
.nav a:hover .nav-ico { color: #b8bbc2; }
.sidebar-user {
  padding: 12px 14px; border-top: 1px solid #24262d;
  display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.sidebar-user .avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: #2e3037; color: #d6d8dd; font-weight: 650;
  display: grid; place-items: center; font-size: 11.5px;
}
.sidebar-user .u-info { flex: 1; min-width: 0; line-height: 1.25; }
.sidebar-user .u-name { color: #e8e9ec; font-weight: 550; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .u-role { color: #71747c; font-size: 10.5px; }
.sidebar-user .logout { background: none; border: none; color: #71747c; cursor: pointer; padding: 4px; border-radius: 6px; display: grid; place-items: center; }
.sidebar-user .logout:hover { color: #e8e9ec; background: var(--side-hover); }

/* ---------------- Columna de contenido + barra superior ---------------- */
.content-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 32px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40;
}
.global-search { position: relative; flex: 1; max-width: 440px; }
.global-search input {
  width: 100%; padding: 8px 14px 8px 34px; border: 1px solid var(--line-strong);
  border-radius: 8px; font-family: var(--font); font-size: 13.5px; background: var(--bg);
  outline: none; transition: border-color .12s, box-shadow .12s, background .12s;
  color: var(--text);
}
.global-search input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(200, 111, 12, .12); }
.global-search .gs-ico { position: absolute; left: 10px; top: 8px; color: var(--text-dim); pointer-events: none; }
.search-drop {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow-lg); overflow: hidden; z-index: 60;
  max-height: 420px; overflow-y: auto;
}
.search-drop.open { display: block; }
.search-drop .sd-group { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); padding: 10px 14px 4px; font-weight: 600; }
.search-drop a { display: block; padding: 8px 14px; text-decoration: none; color: var(--text); font-size: 13.5px; }
.search-drop a:hover { background: var(--bg); }
.search-drop .sd-empty { padding: 14px; color: var(--text-dim); font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.dropdown-host { position: relative; }
.drop-menu {
  display: none; position: absolute; top: calc(100% + 6px); right: 0; min-width: 190px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 5px; z-index: 60;
}
.drop-menu.open { display: block; }
.drop-menu button, .drop-menu a {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 8px 11px; border: none; background: none;
  font-family: var(--font); font-size: 13.5px; font-weight: 500; color: var(--text);
  border-radius: 7px; cursor: pointer; text-decoration: none;
}
.drop-menu button:hover, .drop-menu a:hover { background: var(--bg); }
.wide-menu { min-width: 330px; max-height: 400px; overflow-y: auto; }
.wide-menu a { font-weight: 450; white-space: normal; line-height: 1.45; border-radius: 0; border-bottom: 1px solid var(--line); display: block; }
.wide-menu a:last-child { border-bottom: none; }
.bell {
  position: relative; background: var(--card); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 7px 9px; cursor: pointer; color: var(--text-dim);
  display: grid; place-items: center;
}
.bell:hover { background: var(--bg); color: var(--text); }
.bell-badge {
  position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 99px;
  display: grid; place-items: center; padding: 0 4px;
}

/* ---------------- Main ---------------- */
.main { flex: 1; padding: 26px 32px 60px; max-width: 1320px; animation: viewIn .18s ease; min-width: 0; width: 100%; }
@keyframes viewIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-weight: 650; font-size: 21px; letter-spacing: -.015em; }
.page-title small { display: block; font-weight: 450; font-size: 13px; color: var(--text-dim); letter-spacing: 0; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------- Botones ---------------- */
.btn {
  font-family: var(--font); font-weight: 550; font-size: 13.5px;
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--text);
  transition: background .1s, border-color .1s;
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
}
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #2a2c33; }
.btn.amber { background: var(--accent); border-color: var(--accent-strong); color: #fff; }
.btn.amber:hover { background: var(--accent-strong); }
.btn.danger { color: var(--danger); border-color: #e3beb9; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: rgba(0,0,0,.05); color: var(--text); }

/* ---------------- Tarjetas / tablas ---------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card h3 { font-size: 14px; font-weight: 650; margin-bottom: 12px; letter-spacing: -.005em; display: flex; align-items: center; gap: 8px; }
.card h3 .ico { color: var(--text-dim); }

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .grid.cols-3 { grid-template-columns: 1fr; } }

.stat { padding: 16px 18px; }
.stat .stat-label { font-size: 12px; font-weight: 550; color: var(--text-dim); }
.stat .stat-value { font-size: 25px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .stat-sub { font-size: 12px; color: var(--text-dim); margin-top: 3px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 600; padding: 9px 14px;
  border-bottom: 1px solid var(--line-strong);
}
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .08s; }
.tbl tbody tr:hover { background: #fafaf8; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow-x: auto; }
.row-link { cursor: pointer; }

.empty { text-align: center; padding: 44px 20px; color: var(--text-dim); font-size: 13.5px; }
.empty .empty-ico { margin-bottom: 10px; opacity: .45; display: flex; justify-content: center; }
.empty .empty-ico svg { width: 30px; height: 30px; }
.empty p { margin-bottom: 14px; line-height: 1.55; }

/* ---------------- Pills de estado ---------------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px;
  white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.cotizacion { background: var(--warn-soft); color: var(--warn); }
.pill.confirmado { background: var(--info-soft); color: var(--info); }
.pill.en_preparacion { background: var(--violet-soft); color: var(--violet); }
.pill.en_curso { background: var(--accent-soft); color: var(--accent-strong); }
.pill.finalizado { background: var(--ok-soft); color: var(--ok); }
.pill.facturado { background: #ececea; color: #55575c; }
.pill.cancelado { background: var(--danger-soft); color: var(--danger); }
.pill.disponible { background: var(--ok-soft); color: var(--ok); }
.pill.agotado { background: var(--danger-soft); color: var(--danger); }
.pill.parcial { background: var(--warn-soft); color: var(--warn); }

/* ---------------- Formularios ---------------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field label { font-size: 12px; font-weight: 550; color: var(--text-dim); }
.field input, .field select, .field textarea, .search input {
  font-family: var(--font); font-size: 13.5px; color: var(--text);
  padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: #fff; outline: none; transition: border-color .12s, box-shadow .12s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(200, 111, 12, .12);
}
.field textarea { resize: vertical; min-height: 70px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
.search { position: relative; min-width: 230px; }
.search input { padding-left: 32px; }
.search .s-ico { position: absolute; left: 10px; top: 8px; color: var(--text-dim); pointer-events: none; }

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 17, 21, .5);
  display: grid; place-items: center; z-index: 100; padding: 20px;
  animation: fadeIn .12s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--card); border-radius: 12px; width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 64px -12px rgba(0,0,0,.35);
  animation: modalIn .15s ease;
}
.modal.wide { max-width: 860px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.99); } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 0; }
.modal-head h2 { font-size: 16.5px; font-weight: 650; letter-spacing: -.01em; }
.modal-body { padding: 14px 22px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 22px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-dim); line-height: 1; padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--text); }

/* ---------------- Toast ---------------- */
#toastRoot { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 9px;
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg);
  animation: toastIn .18s ease; max-width: 380px;
}
.toast.error { background: #7c2822; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-strong); margin-bottom: 18px; flex-wrap: wrap; }
.tab {
  padding: 8px 14px; font-weight: 550; font-size: 13.5px; color: var(--text-dim);
  background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; font-family: var(--font);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ---------------- Flujo de fases ---------------- */
.pipeline { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.pipe-step {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; font-size: 12.5px; font-weight: 550;
  background: var(--card); color: var(--text-dim); cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: 99px;
  font-family: var(--font); transition: all .1s;
}
.pipe-step::before {
  content: attr(data-n); width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg); color: var(--text-dim); font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}
.pipe-step:hover { border-color: var(--accent); color: var(--accent-strong); }
.pipe-step.done { background: var(--bg); color: var(--text-dim); border-color: var(--line); }
.pipe-step.done::before { content: "✓"; background: var(--ok-soft); color: var(--ok); }
.pipe-step.current { background: var(--ink); color: #fff; border-color: var(--ink); }
.pipe-step.current::before { background: var(--accent); color: #fff; }
.pipe-step.cancel { border-color: transparent; background: none; color: var(--text-dim); }
.pipe-step.cancel::before { display: none; }
.pipe-step.cancel:hover { color: var(--danger); }
.pipe-step.cancel.current { background: var(--danger-soft); color: var(--danger); }

/* ---------------- Pestañas del proyecto ---------------- */
.proj-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-strong); margin-bottom: 18px; flex-wrap: wrap; }
.proj-tab {
  padding: 8px 15px; font-weight: 550; font-size: 13.5px; color: var(--text-dim);
  background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; font-family: var(--font); display: flex; gap: 7px; align-items: center;
}
.proj-tab:hover { color: var(--text); }
.proj-tab .tab-count { background: var(--bg); border: 1px solid var(--line); border-radius: 99px; font-size: 10.5px; padding: 0 6px; font-weight: 600; line-height: 16px; }
.proj-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.proj-tab.active .tab-count { background: var(--accent-soft); border-color: transparent; color: var(--accent-strong); }

/* ---------------- Kanban ---------------- */
.kanban { display: grid; gap: 10px; overflow-x: auto; align-items: start; }
.kb-col { background: #eeeeeb; border-radius: 10px; padding: 8px; min-height: 120px; border: 1px dashed transparent; }
.kb-col.dragover { border-color: var(--accent); background: var(--accent-soft); }
.kb-col h4 {
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim);
  padding: 4px 6px 8px; display: flex; justify-content: space-between; font-weight: 600;
}
.kb-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 7px; cursor: grab; box-shadow: var(--shadow);
  font-size: 13px;
}
.kb-card:active { cursor: grabbing; }
.kb-card .kb-name { font-weight: 600; margin-bottom: 2px; }
.kb-card .kb-meta { color: var(--text-dim); font-size: 12px; }
.kb-card .kb-total { font-weight: 600; margin-top: 5px; font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* ---------------- Árbol de carpetas ---------------- */
.inv-layout { display: grid; grid-template-columns: 225px 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .inv-layout { grid-template-columns: 1fr; } }
.tree { padding: 8px; }
.tree-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 7px;
  font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text);
  border: none; background: none; width: 100%; text-align: left; font-family: var(--font);
}
.tree-item .ico { color: var(--text-dim); }
.tree-item:hover { background: var(--bg); }
.tree-item.active { background: var(--accent-soft); color: var(--accent-strong); }
.tree-item.active .ico { color: var(--accent-strong); }
.tree-item .tree-count { margin-left: auto; font-size: 11px; color: var(--text-dim); font-weight: 500; }
.tree-item.child { padding-left: 30px; }

/* ---------------- Línea de disponibilidad ---------------- */
.avail-strip { display: grid; grid-auto-flow: column; gap: 2px; margin: 10px 0 4px; }
.avail-day {
  height: 32px; border-radius: 4px; display: grid; place-items: center;
  font-size: 9.5px; font-weight: 600; color: rgba(0,0,0,.5); cursor: default;
}
.avail-day.free { background: var(--ok-soft); }
.avail-day.partial { background: var(--warn-soft); }
.avail-day.full { background: #f2d0b8; }
.avail-day.over { background: var(--danger-soft); color: var(--danger); }
.avail-legend { display: flex; gap: 14px; font-size: 11.5px; color: var(--text-dim); margin-top: 8px; }
.avail-legend span { display: inline-flex; align-items: center; gap: 5px; }
.avail-legend span::before { content: ""; width: 10px; height: 10px; border-radius: 3px; }
.avail-legend .l-free::before { background: var(--ok-soft); }
.avail-legend .l-partial::before { background: var(--warn-soft); }
.avail-legend .l-full::before { background: #f2d0b8; }
.avail-legend .l-over::before { background: var(--danger-soft); }

/* ---------------- Tareas ---------------- */
.task-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px 4px;
  border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.task-item:last-child { border-bottom: none; }
.task-check {
  width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-strong);
  background: #fff; cursor: pointer; flex-shrink: 0; display: grid; place-items: center;
  font-size: 11px; color: transparent; transition: all .1s; margin-top: 1px;
}
.task-check:hover { border-color: var(--accent); }
.task-item.done .task-check { background: var(--ok); border-color: var(--ok); color: #fff; }
.task-item.done .task-title { text-decoration: line-through; color: var(--text-dim); }
.task-title { font-weight: 550; }
.task-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.task-meta .overdue { color: var(--danger); font-weight: 600; }

/* ---------------- Actividad / archivos ---------------- */
.act-item { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.act-item:last-child { border-bottom: none; }
.act-item .act-dot { color: var(--accent); font-size: 9px; padding-top: 4px; }
.act-item .act-when { color: var(--text-dim); font-size: 11.5px; white-space: nowrap; }
.file-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.file-item:last-child { border-bottom: none; }
.file-item a { color: var(--info); font-weight: 550; text-decoration: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item a:hover { text-decoration: underline; }

/* ---------------- Calendario ---------------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.cal-title { font-size: 16.5px; font-weight: 650; text-transform: capitalize; letter-spacing: -.01em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); text-align: center; padding: 6px 0; }
.cal-cell {
  min-height: 90px; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px; font-size: 12px; overflow: hidden;
}
.cal-cell.other { opacity: .35; background: transparent; }
.cal-cell.today { border-color: var(--accent); }
.cal-day-num { font-weight: 600; font-size: 11.5px; margin-bottom: 4px; color: var(--text-dim); }
.cal-cell.today .cal-day-num { color: var(--accent-strong); }
.cal-ev {
  display: block; font-size: 11px; font-weight: 550; padding: 2px 7px; margin-bottom: 3px;
  border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; text-decoration: none;
}
.cal-ev.cotizacion { background: var(--warn-soft); color: var(--warn); }
.cal-ev.confirmado { background: var(--info-soft); color: var(--info); }
.cal-ev.en_preparacion { background: var(--violet-soft); color: var(--violet); }
.cal-ev.en_curso { background: var(--accent-soft); color: var(--accent-strong); }
.cal-ev.finalizado, .cal-ev.facturado { background: var(--ok-soft); color: var(--ok); }

/* ---------------- Planificador ---------------- */
.tl-wrap { overflow-x: auto; }
.tl { min-width: 900px; }
.tl-row { display: grid; align-items: center; border-bottom: 1px solid var(--line); }
.tl-row.head { border-bottom: 1px solid var(--line-strong); position: sticky; top: 0; background: var(--card); z-index: 2; }
.tl-label {
  padding: 8px 12px; font-size: 13px; font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border-right: 1px solid var(--line-strong);
}
.tl-label .muted { font-weight: 400; }
.tl-days { display: grid; position: relative; min-height: 40px; }
.tl-daycell { border-right: 1px solid #f0efec; font-size: 10.5px; text-align: center; color: var(--text-dim); padding: 7px 0 5px; font-weight: 550; }
.tl-daycell.wknd { background: #f6f6f4; }
.tl-daycell.today { background: var(--accent-soft); color: var(--accent-strong); }
.tl-bg { position: absolute; inset: 0; display: grid; }
.tl-bg > div { border-right: 1px solid #f0efec; }
.tl-bg > div.wknd { background: #f6f6f4; }
.tl-bg > div.today { background: var(--accent-soft); }
.tl-bar {
  position: relative; z-index: 1; margin: 7px 2px; padding: 3px 9px; border-radius: 5px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; text-decoration: none; display: block; color: #fff;
}
.tl-bar.cotizacion { background: repeating-linear-gradient(45deg, #c9973b, #c9973b 6px, #bd8c31 6px, #bd8c31 12px); }
.tl-bar.confirmado { background: var(--info); }
.tl-bar.en_preparacion { background: var(--violet); }
.tl-bar.en_curso { background: var(--accent); }
.tl-bar.finalizado { background: var(--ok); }
.tl-bar.facturado { background: #83858c; }

/* ---------------- Reportes ---------------- */
.bar-row { display: grid; grid-template-columns: 110px 1fr 110px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.bar-track { background: #efefec; border-radius: 5px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 5px; min-width: 2px; }
.bar-fill.alt { background: var(--info); }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }

/* ---------------- Etiquetas ---------------- */
.labels-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.label-card {
  background: #fff; border: 1px dashed var(--line-strong); border-radius: 8px;
  padding: 12px; text-align: center;
}
.label-card .lb-name { font-size: 12px; font-weight: 650; margin-bottom: 2px; }
.label-card .lb-code { font-size: 11px; color: var(--text-dim); letter-spacing: .1em; margin-top: 2px; }
@media print {
  .labels-grid { grid-template-columns: repeat(3, 1fr); }
  .label-card { border: 1px solid #999; break-inside: avoid; }
  .page-head, .tabs, .topbar { display: none !important; }
}

/* ---------------- Documento imprimible ---------------- */
.doc-sheet {
  background: #fff; max-width: 800px; margin: 0 auto; padding: 48px 54px;
  border: 1px solid var(--line); border-radius: 4px; box-shadow: var(--shadow);
  font-size: 13.5px;
}
.doc-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 34px; }
.doc-company h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; letter-spacing: -.01em; }
.doc-company p { color: var(--text-dim); font-size: 12px; line-height: 1.55; }
.doc-type { text-align: right; }
.doc-type .doc-kind { font-size: 22px; font-weight: 700; letter-spacing: .04em; color: var(--accent-strong); }
.doc-type p { font-size: 12.5px; color: var(--text-dim); }
.doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
.doc-meta h4 { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px; }
.doc-meta p { line-height: 1.55; }
.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; font-size: 13px; }
.doc-table th {
  text-align: left; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase;
  padding: 8px 10px; background: var(--ink); color: #fff;
}
.doc-table th.num, .doc-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.doc-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.doc-totals { margin-left: auto; width: 280px; font-size: 13.5px; }
.doc-totals .trow { display: flex; justify-content: space-between; padding: 5px 10px; }
.doc-totals .trow.grand {
  font-weight: 700; font-size: 15.5px;
  background: var(--ink); color: #fff; border-radius: 8px; padding: 10px 12px; margin-top: 6px;
}
.doc-terms { margin-top: 30px; padding-top: 16px; border-top: 1px dashed var(--line-strong); font-size: 11.5px; color: var(--text-dim); line-height: 1.6; }
.doc-actions { max-width: 800px; margin: 0 auto 18px; display: flex; justify-content: space-between; gap: 10px; }

@media print {
  .sidebar, .doc-actions, #toastRoot, .topbar { display: none !important; }
  .main { padding: 0; max-width: none; }
  .doc-sheet { border: none; box-shadow: none; padding: 10px 0; max-width: none; }
  body { background: #fff; }
}

/* ---------------- Detalle proyecto ---------------- */
.proj-layout { display: grid; grid-template-columns: 1fr 320px; gap: 14px; align-items: start; }
@media (max-width: 1000px) { .proj-layout { grid-template-columns: 1fr; } }
.line-editor td { padding: 6px 8px; }
.line-editor input, .line-editor select {
  font-family: var(--font); font-size: 13px; padding: 6px 8px;
  border: 1px solid var(--line-strong); border-radius: 6px; width: 100%; background: #fff;
}
.avail-ok { color: var(--ok); font-weight: 600; font-size: 12px; }
.avail-bad { color: var(--danger); font-weight: 600; font-size: 12px; }
.muted { color: var(--text-dim); font-size: 13px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; } .mt16 { margin-top: 16px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* ---------------- Resumen financiero oscuro ---------------- */
.fin-card { background: var(--ink) !important; color: #d9dade; border-color: var(--ink) !important; }
.fin-card h3 { color: #fff; }
.fin-card .doc-totals .trow.grand { background: rgba(255,255,255,.08); color: #fff; }

/* ---------------- Login ---------------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--bg); padding: 20px;
}
.login-card {
  width: 100%; max-width: 372px; background: var(--card);
  border-radius: 14px; padding: 34px 32px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px -20px rgba(16,24,40,.25);
}
.login-card .brand-mark { margin: 0 auto 14px; width: 42px; height: 42px; font-size: 17px; }
.login-card h1 { font-size: 18px; font-weight: 650; text-align: center; letter-spacing: -.01em; }
.login-card .login-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin: 4px 0 22px; }
.login-error { background: var(--danger-soft); color: var(--danger); font-size: 13px; font-weight: 550; padding: 9px 12px; border-radius: 8px; margin-bottom: 12px; }

/* ---------------- Primeros pasos (onboarding) ---------------- */
.onboard { margin-bottom: 16px; }
.onboard h3 { margin-bottom: 4px; }
.onboard .ob-sub { font-size: 13px; color: var(--text-dim); margin-bottom: 12px; }
.ob-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 900px) { .ob-steps { grid-template-columns: 1fr 1fr; } }
.ob-step {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--card);
  text-decoration: none; color: var(--text); font-size: 13px; font-weight: 550;
  cursor: pointer; font-family: var(--font); text-align: left; transition: border-color .1s;
}
.ob-step:hover { border-color: var(--accent); }
.ob-step .ob-n {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 11.5px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent-strong);
}
.ob-step.done { opacity: .6; pointer-events: none; }
.ob-step.done .ob-n { background: var(--ok-soft); color: var(--ok); }

/* ---------------- Indicador de guardado ---------------- */
.save-state { font-size: 12.5px; color: var(--text-dim); display: inline-flex; align-items: center; gap: 6px; }
.save-state.saving { color: var(--warn); }
.save-state.saved { color: var(--ok); }

/* ---------------- Navegación inferior (móvil) ---------------- */
.bottomnav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 80;
  background: var(--card); border-top: 1px solid var(--line-strong);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  grid-template-columns: repeat(5, 1fr);
}
.bottomnav a, .bottomnav button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 2px 5px; text-decoration: none; border: none; background: none;
  font-family: var(--font); font-size: 10.5px; font-weight: 550; color: var(--text-dim);
  border-radius: 9px; cursor: pointer;
}
.bottomnav svg.ico { width: 21px; height: 21px; }
.bottomnav .active { color: var(--accent-strong); }
.bottomnav .active svg.ico { stroke-width: 2; }

/* ---------------- Hoja "Más" (móvil) ---------------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15, 17, 21, .45); z-index: 90;
  animation: fadeIn .15s ease;
}
.sheet {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--card); border-radius: 16px 16px 0 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  animation: sheetIn .2s ease; max-height: 75vh; overflow-y: auto;
}
@keyframes sheetIn { from { transform: translateY(40px); opacity: 0; } }
.sheet-handle { width: 36px; height: 4px; border-radius: 99px; background: var(--line-strong); margin: 4px auto 12px; }
.sheet-items { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-items a, .sheet-items button {
  display: flex; align-items: center; gap: 10px; padding: 13px 14px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  text-decoration: none; color: var(--text); font-size: 13.5px; font-weight: 550;
  font-family: var(--font); cursor: pointer; text-align: left;
}
.sheet-items .sheet-user {
  grid-column: 1 / -1; background: none; border: none; border-top: 1px solid var(--line);
  border-radius: 0; margin-top: 6px; padding-top: 14px; pointer-events: none;
  color: var(--text-dim); font-weight: 450;
}
.sheet-items .sheet-logout { grid-column: 1 / -1; justify-content: center; color: var(--danger); background: var(--danger-soft); border-color: transparent; }

/* ---------------- Responsive ---------------- */
.tb-brand { display: none; }
@media (max-width: 820px) {
  #app { flex-direction: column; }
  .sidebar { display: none; }
  .bottomnav { display: grid; }
  .tb-brand {
    display: grid; place-items: center; width: 34px; height: 34px; flex-shrink: 0;
    background: var(--accent); color: #fff; border-radius: 8px;
  }
  .tb-brand svg.ico { width: 18px; height: 18px; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .global-search { max-width: none; }
  .qa-label { display: none; }
  .main { padding: 16px 14px calc(84px + env(safe-area-inset-bottom)); }
  .page-title { font-size: 19px; }
  .page-actions { width: 100%; }
  .page-actions .search { flex: 1; min-width: 0; }
  .page-actions .search input { width: 100%; }
  .btn { padding: 9px 14px; }
  .btn.small { padding: 7px 11px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .grid.cols-4, .grid.cols-2 { grid-template-columns: 1fr; }
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .proj-layout { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(6, 230px) !important; }
  .inv-layout { grid-template-columns: 1fr; }
  .tree { display: flex; overflow-x: auto; gap: 4px; padding: 8px; }
  .tree-item { width: auto; white-space: nowrap; flex-shrink: 0; }
  .tree-item.child { padding-left: 9px; }
  .tree-item .tree-count { margin-left: 6px; }
  .pipeline { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .pipe-step { white-space: nowrap; flex-shrink: 0; }
  .proj-tabs, .tabs { overflow-x: auto; flex-wrap: nowrap; }
  .proj-tab, .tab { white-space: nowrap; flex-shrink: 0; }
  .cal-cell { min-height: 64px; padding: 4px; }
  .cal-ev { font-size: 9.5px; padding: 1px 4px; }
  .doc-sheet { padding: 24px 18px; }
  .doc-actions { flex-wrap: wrap; }
  .bar-row { grid-template-columns: 70px 1fr 90px; font-size: 12px; }
  .labels-grid { grid-template-columns: 1fr 1fr; }
  .modal { max-height: 86vh; }
  .stat .stat-value { font-size: 21px; }
  .ob-steps { grid-template-columns: 1fr; }
}
@media print {
  .bottomnav, .sheet-backdrop { display: none !important; }
}
