/* Capa «cloud»: estructura de app web (barra superior, menú claro, paneles) sobre los tokens de styles.css */
:root {
  --fondo: #f4f6f3;
  --borde: #e3e7e1;
  --sombra: 0 1px 2px rgba(27, 37, 31, .05), 0 4px 16px -8px rgba(27, 37, 31, .12);
  --verde-suave: #e7f0ea;
  --r: 8px;
}
body { background: var(--fondo); }
.shell { grid-template-columns: 248px minmax(0, 1fr); }
.work { min-width: 0; display: flex; flex-direction: column; }

/* Menú lateral claro */
.side { background: #fff; color: var(--tinta); border-right: 1px solid var(--borde); padding: 18px 12px; }
.brand-mark { background: var(--botella); border: 0; color: #fff; width: 34px; height: 34px; font-size: 18px; border-radius: 10px; }
.brand small { color: var(--muted); }
#nav .grp { color: #8a968d; letter-spacing: .1em; margin: 16px 10px 4px; }
#nav a { color: #36433b; padding: 7px 10px; gap: 10px; justify-content: flex-start; font-size: 14px; }
#nav a svg { flex: none; color: #7b897f; }
#nav a .lbl { flex: 1; }
#nav a:hover { background: #f1f4f0; }
#nav a[aria-current="page"] { background: var(--verde-suave); color: var(--botella); }
#nav a[aria-current="page"] svg { color: var(--botella); }
#nav a .n { background: #f3e9d2; color: #7a5a14; border-radius: 99px; padding: 0 7px; font-size: 11px; }
#nav a[aria-current="page"] .n { background: #fff; color: var(--botella); }
.side-foot { color: var(--muted); }
.link { color: var(--muted); }

/* Barra superior */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px clamp(16px, 3vw, 40px); background: rgba(244, 246, 243, .85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--borde); }
.search { flex: 1; max-width: 560px; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--borde); border-radius: 10px; padding: 8px 12px; color: var(--muted); cursor: text; text-align: left; font-size: 14px; }
.search span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search:hover { border-color: #c9d2c7; }
kbd { font: 500 11px var(--mono); background: #f1f4f0; border: 1px solid var(--borde); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--borde); background: #fff; display: grid; place-items: center; cursor: pointer; color: #36433b; }
.icon-btn .dot { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 99px; background: var(--tinto); color: #fff; font: 600 10.5px/18px var(--mono); padding: 0 4px; }
.role { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--borde); border-radius: 10px; padding: 3px 4px 3px 4px; }
.role select { border: 0; padding: 4px 22px 4px 2px; background: transparent; width: auto; font-size: 13.5px; }
.avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--laton); color: #fff; display: grid; place-items: center; font: 600 12px var(--body); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--borde); border-radius: 10px; box-shadow: var(--sombra); min-width: 200px; padding: 6px; z-index: 6; }
.menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--tinta); text-decoration: none; }
.menu a:hover { background: #f1f4f0; }

/* Bloques */
main { padding-top: 24px; }
.card { border: 1px solid var(--borde); border-radius: 12px; box-shadow: var(--sombra); background: #fff; }
.btn { border-radius: 8px; }
th { border-bottom: 1px solid var(--borde); color: #7b897f; font-size: 10.5px; }
td { border-bottom: 1px solid #eef1ec; }
tfoot td { border-top: 1px solid var(--borde); }
tr.click:hover td { background: #f6f8f5; }
input, select, textarea { border-color: var(--borde); border-radius: 8px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--botella-2); box-shadow: 0 0 0 3px rgba(47, 107, 82, .15); }
.note { border-radius: 0 10px 10px 0; }
.tabs { border-bottom-color: var(--borde); }
.sheet { border-radius: 12px; }

/* Buscador ⌘K y panel lateral */
.overlay { position: fixed; inset: 0; z-index: 30; background: rgba(27, 37, 31, .35); backdrop-filter: blur(2px); }
.palette { width: min(640px, calc(100vw - 32px)); margin: 10vh auto 0; background: #fff; border-radius: 14px; box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .4); overflow: hidden; }
.palette input { border: 0; border-bottom: 1px solid var(--borde); border-radius: 0; padding: 16px 18px; font-size: 16px; box-shadow: none !important; }
.pres { max-height: 52vh; overflow: auto; padding: 6px; }
.pres h4 { font: 500 10.5px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: #8a968d; margin: 10px 10px 4px; }
.pres a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--tinta); }
.pres a small { display: block; color: var(--muted); font-size: 12.5px; }
.pres a.sel, .pres a:hover { background: var(--verde-suave); }
.pres .vacio { padding: 18px; color: var(--muted); }
.phint { border-top: 1px solid var(--borde); padding: 8px 14px; font-size: 12px; color: var(--muted); display: flex; gap: 4px; align-items: center; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #fff; box-shadow: -20px 0 50px -20px rgba(0, 0, 0, .3); overflow: auto; padding: 22px 24px 40px; animation: entra .2s ease; }
.drawer h2 { display: flex; justify-content: space-between; align-items: center; }
.drawer .close { border: 0; background: #f1f4f0; border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 18px; }
@keyframes entra { from { transform: translateX(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }

/* Ficha de cliente */
.profile { display: flex; gap: 16px; align-items: center; }
.profile .ini { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; font: 700 20px var(--display); color: #fff; background: var(--botella); flex: none; }
.profile .ini.AGE { background: var(--tinto); }
.profile .ini.COR { background: var(--botella-2); }
.profile .ini.SOC { background: var(--laton); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.contact { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #eef1ec; }
.contact .ini { width: 34px; height: 34px; border-radius: 99px; background: #eef1ec; display: grid; place-items: center; font: 600 12px var(--body); flex: none; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid #eef1ec; font-size: 14px; }
.timeline li span:first-child { color: var(--muted); font-family: var(--mono); font-size: 12px; padding-top: 2px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type="search"] { max-width: 320px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--tinta); }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; border-bottom: 1px solid var(--borde); }
  .menu-toggle { border-color: var(--borde); color: var(--tinta); }
  .search span { display: none; }
  .search { flex: 0; }
  .search kbd { display: none; }
  .role select { display: none; }
  .kv { grid-template-columns: 1fr; }
}
@media print { .topbar { display: none !important; } }
