/* ══════════════════════════════════════════
   ReXyo Suite — tema claro "crema"
   Compacto, visual y white-label (sin la
   estética oscura de la marca ReXyo).
   ══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  /* Fondos cálidos crema */
  --bg: #ece4d4;          /* lienzo */
  --surface: #fbf7ee;     /* tarjetas / paneles */
  --surface2: #f4ecdd;    /* inputs / chips */
  --surface3: #efe6d4;    /* hover */
  --sidebar: #fbf7ee;

  /* Texto cálido */
  --text: #2c2722;
  --muted: #8a8170;
  --dim: #b3a892;

  /* Acentos */
  --accent: #c08552;      /* caramelo / bronce */
  --accent-soft: #e7d3bd;
  --accent2: #a9764a;
  --green: #6f8f5e;
  --amber: #cd9a3f;
  --red: #c0584f;
  --blue: #6d86a8;

  --border: rgba(70,54,30,0.10);
  --border-strong: rgba(70,54,30,0.16);
  --shadow: 0 14px 36px rgba(110,84,44,0.16);
  --shadow-sm: 0 2px 8px rgba(110,84,44,0.08);
  --radius: 14px;
}
html { font-size: 15px; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Inter', system-ui, sans-serif; line-height: 1.5;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
  display: grid; grid-template-columns: 212px 1fr;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent-soft); border-radius: 99px; }

/* ══ SIDEBAR ══ */
.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1.1rem 0.85rem;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 0.25rem 0.6rem 1.4rem; display: flex; align-items: baseline; gap: 0.45rem; }
.brand-logo { font-size: 1.3rem; font-weight: 900; letter-spacing: -0.02em; }
.brand-logo span { color: var(--accent); }
.brand-sub {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--dim);
}
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.58rem 0.75rem; border-radius: 10px; border: none;
  background: transparent; color: var(--muted); font-size: 0.85rem;
  font-weight: 600; text-align: left; transition: all 0.16s; width: 100%;
}
.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--surface3); color: var(--text); }
.nav-item.active {
  background: var(--accent); color: #fff; box-shadow: var(--shadow-sm);
}
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 0.85rem; }
.reset-btn {
  width: 100%; padding: 0.5rem; border-radius: 9px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); font-size: 0.75rem; font-weight: 600; transition: all 0.16s;
}
.reset-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface3); }
.foot-note { font-size: 0.62rem; color: var(--dim); text-align: center; margin-top: 0.55rem; }

/* ══ MAIN ══ */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.85rem 1.6rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(236,228,212,0.88);
  backdrop-filter: blur(10px); z-index: 50;
}
.menu-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.2rem; }
.view-title { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.01em; }
.role-switch { margin-left: auto; display: flex; align-items: center; gap: 0.45rem; }
.role-switch-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); }
.role-select { padding: 0.4rem 1.9rem 0.4rem 0.7rem; border-radius: 9px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23c08552'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 0.45rem center; background-size: 16px; border: 1px solid var(--border-strong); color: var(--text); font-family: inherit; font-size: 0.82rem; font-weight: 600; -webkit-appearance: none; appearance: none; cursor: pointer; }
.role-select:focus { outline: none; border-color: var(--accent); }
.topbar-actions { display: flex; gap: 0.5rem; margin-left: 0.75rem; }
.content { padding: 1.5rem 1.6rem; flex: 1; }

/* ══ BUTTONS ══ */
.btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.5rem 0.95rem; border-radius: 9px; border: none;
  font-size: 0.82rem; font-weight: 600; transition: all 0.16s;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-danger { background: rgba(192,88,79,0.1); color: var(--red); border: 1px solid rgba(192,88,79,0.22); }
.btn-danger:hover { background: rgba(192,88,79,0.16); }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.76rem; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  width: 30px; height: 30px; border-radius: 8px; display: inline-flex;
  align-items: center; justify-content: center; transition: all 0.16s; font-size: 0.9rem;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface3); }

/* ══ STATS ══ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 0.85rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.95rem 1.1rem; position: relative; overflow: hidden; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 0.1rem;
}
.stat-card::before {
  content: ''; position: absolute; top: 0.95rem; right: 1.1rem; width: 34px; height: 34px;
  border-radius: 10px; background: var(--accent-soft); opacity: 0.55;
}
.stat-card.green::before { background: rgba(111,143,94,0.22); }
.stat-card.amber::before { background: rgba(205,154,63,0.22); }
.stat-card.violet::before { background: rgba(109,134,168,0.22); }
.stat-label { font-size: 0.74rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat-foot { font-size: 0.68rem; color: var(--dim); }

/* ══ PANELS ══ */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 1.1rem; box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.8rem 1.15rem; border-bottom: 1px solid var(--border);
}
.panel-title { font-size: 0.88rem; font-weight: 700; }
.panel-body { padding: 0.25rem 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }

/* ══ LIST ROWS ══ */
.list-row {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.65rem 1.15rem; border-bottom: 1px solid var(--border); transition: background 0.14s;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface3); }
.avatar {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.78rem; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.row-main { min-width: 0; flex: 1; }
.row-name { font-weight: 600; font-size: 0.85rem; }
.row-sub { font-size: 0.74rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { font-size: 0.74rem; color: var(--muted); text-align: right; white-space: nowrap; }
.row-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

/* ══ BADGES ══ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.66rem; font-weight: 700; padding: 3px 9px; border-radius: 100px;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.lead { color: #7a6a8f; background: rgba(122,106,143,0.14); }
.badge.active { color: var(--green); background: rgba(111,143,94,0.16); }
.badge.inactive { color: var(--muted); background: rgba(138,129,112,0.14); }
.badge.pending { color: #b07e2e; background: rgba(205,154,63,0.18); }
.badge.confirmed { color: var(--blue); background: rgba(109,134,168,0.16); }
.badge.done { color: var(--green); background: rgba(111,143,94,0.16); }
.badge.cancelled { color: var(--red); background: rgba(192,88,79,0.14); }

/* ══ TOOLBAR ══ */
.toolbar { display: flex; gap: 0.65rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box input {
  width: 100%; padding: 0.55rem 0.85rem 0.55rem 2.2rem; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-size: 0.85rem; font-family: inherit;
}
.search-box input::placeholder { color: var(--dim); }
.search-box input:focus { outline: none; border-color: var(--accent); background: #fff; }
.search-box svg { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; fill: var(--dim); }
.filter-tabs { display: flex; gap: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.filter-tab {
  padding: 0.4rem 0.75rem; border-radius: 7px; border: none; background: transparent;
  color: var(--muted); font-size: 0.78rem; font-weight: 600; transition: all 0.14s;
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active { background: var(--accent); color: #fff; }

/* ══ EMPTY ══ */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--dim); font-size: 0.85rem; }
.empty-icon { font-size: 2.2rem; opacity: 0.6; margin-bottom: 0.4rem; }

/* ══ MODAL / FORM ══ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(44,39,34,0.4); backdrop-filter: blur(3px);
  z-index: 1000; display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); width: 100%; max-width: 440px; max-height: 92vh; overflow-y: auto;
  animation: pop 0.2s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(0.97); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.3rem; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-body { padding: 1.25rem 1.3rem; }
.modal-foot { display: flex; gap: 0.6rem; justify-content: flex-end; padding: 0.85rem 1.3rem; border-top: 1px solid var(--border); background: var(--surface2); }
.field { margin-bottom: 0.85rem; }
.field label { display: block; font-size: 0.74rem; font-weight: 600; color: var(--muted); margin-bottom: 0.32rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: 0.55rem 0.7rem; border-radius: 9px;
  background: #fff; border: 1px solid var(--border-strong); color: var(--text);
  font-size: 0.85rem; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 62px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }

/* ══ TOAST ══ */
.toast {
  position: fixed; bottom: 1.3rem; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); border: 1px solid rgba(0,0,0,0.1); color: #fbf7ee;
  padding: 0.65rem 1.1rem; border-radius: 10px; font-size: 0.82rem; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all 0.28s; z-index: 2000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ══ BADGES (facturas) ══ */
.badge.draft { color: var(--muted); background: rgba(138,129,112,0.14); }
.badge.sent { color: #b07e2e; background: rgba(205,154,63,0.18); }
.badge.paid { color: var(--green); background: rgba(111,143,94,0.16); }

/* ══ CALENDARIO ══ */
.cal-panel { padding: 0.5rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); text-align: center; padding: 0.35rem 0; }
.cal-cell { min-height: 92px; background: var(--surface2); border: 1px solid var(--border); border-radius: 9px; padding: 4px 5px; cursor: pointer; transition: background 0.14s, border-color 0.14s; display: flex; flex-direction: column; gap: 3px; overflow: hidden; }
.cal-cell:hover { background: var(--surface3); border-color: var(--border-strong); }
.cal-cell.is-blank { background: transparent; border: none; cursor: default; }
.cal-cell.is-blank:hover { background: transparent; }
.cal-cell.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-num { font-size: 0.74rem; font-weight: 700; color: var(--muted); }
.cal-cell.is-today .cal-num { color: var(--accent); }
.cal-events { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-chip { display: block; width: 100%; text-align: left; font-size: 0.66rem; font-weight: 600; padding: 2px 6px; border-radius: 6px; border: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); background: var(--accent-soft); transition: filter 0.14s; }
.cal-chip:hover { filter: brightness(0.96); }
.cal-chip.pending { background: rgba(205,154,63,0.22); }
.cal-chip.confirmed { background: rgba(109,134,168,0.22); }
.cal-chip.done { background: rgba(111,143,94,0.22); }
.cal-chip.cancelled { background: rgba(192,88,79,0.18); text-decoration: line-through; opacity: 0.7; }
.cal-more { font-size: 0.62rem; color: var(--muted); font-weight: 600; padding-left: 4px; }

/* ══ FACTURA — líneas en el formulario ══ */
.inv-empty { font-size: 0.78rem; color: var(--dim); padding: 0.6rem 0.2rem; }
.inv-item { display: grid; grid-template-columns: 1fr 56px 78px 30px; gap: 6px; margin-bottom: 6px; align-items: center; }
.inv-item input { padding: 0.45rem 0.55rem; border-radius: 8px; background: #fff; border: 1px solid var(--border-strong); color: var(--text); font-size: 0.82rem; font-family: inherit; width: 100%; }
.inv-item input:focus { outline: none; border-color: var(--accent); }
.inv-total-row { display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.2rem 0; border-top: 1px dashed var(--border-strong); margin-top: 0.6rem; font-weight: 700; }
.inv-total-row #inv-total { font-size: 1.05rem; color: var(--accent); }

/* ══ FACTURA — tabla en el detalle ══ */
.inv-table { margin-top: 1rem; border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.inv-trow { display: grid; grid-template-columns: 1fr 48px 80px 84px; gap: 6px; padding: 0.5rem 0.75rem; font-size: 0.82rem; border-bottom: 1px solid var(--border); }
.inv-trow span:nth-child(2), .inv-trow span:nth-child(3), .inv-trow span:nth-child(4) { text-align: right; }
.inv-trow:last-child { border-bottom: none; }
.inv-thead { background: var(--surface2); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.inv-tfoot { background: var(--surface2); font-weight: 700; }
.inv-tfoot span:last-child { color: var(--accent); }

@media (max-width: 560px) {
  .cal-chip { font-size: 0; padding: 3px; }
  .cal-chip::before { content: ''; display: block; height: 4px; border-radius: 2px; background: currentColor; }
  .cal-cell { min-height: 64px; }
}

/* ══ PERMISOS ══ */
.perm-banner { display: flex; gap: 0.75rem; align-items: flex-start; background: var(--accent-soft); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.9rem 1.1rem; margin-bottom: 1.25rem; font-size: 0.85rem; color: #6b5333; }
.perm-banner-icon { font-size: 1.1rem; line-height: 1.3; }
.perm-note { font-size: 0.8rem; color: var(--muted); background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.9rem; }
.perm-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.perm-group { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem 0.85rem; }
.perm-group-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.82rem; font-weight: 700; margin-bottom: 0.55rem; }
.perm-all { font-size: 0.66rem; font-weight: 600; color: var(--accent); background: transparent; border: 1px solid var(--accent-soft); border-radius: 100px; padding: 2px 8px; transition: all 0.15s; }
.perm-all:hover { background: var(--accent-soft); }
.perm-actions { display: flex; flex-direction: column; gap: 0.35rem; }
.perm-check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; cursor: pointer; color: var(--text); }
.perm-check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.perm-check input:disabled { cursor: default; }
.perm-check input:disabled + span { color: var(--muted); }
@media (max-width: 560px) { .perm-groups { grid-template-columns: 1fr; } }

/* ══ DETAIL ══ */
.detail-head { display: flex; align-items: center; gap: 0.9rem; margin-bottom: 1.25rem; }
.detail-avatar { width: 50px; height: 50px; border-radius: 13px; font-size: 1.1rem; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 0.7rem; }
.detail-item { background: var(--surface2); border: 1px solid var(--border); border-radius: 11px; padding: 0.7rem 0.9rem; }
.detail-item .k { font-size: 0.68rem; color: var(--muted); font-weight: 600; }
.detail-item .v { font-size: 0.88rem; font-weight: 600; margin-top: 0.15rem; word-break: break-word; }

/* ══ RESPONSIVE ══ */
@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 200; width: 212px;
    transform: translateX(-100%); transition: transform 0.24s; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .two-col { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 1.1rem; padding-right: 1.1rem; }
}
