:root {
  --bg: #161a22; --panel: #262a33; --panel-2: #1d2027; --line: #3a3f4b; --text: #e8eaf0; --muted: #98a0b3;
  --accent: #5b8def; --accent-2: #3d5a8c; --danger: #d9534f; --ok: #3fb67a; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: radial-gradient(circle at 20% 10%, #20303f, var(--bg) 60%); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 36px; max-width: 420px; text-align: center; }
.login-card h1 { margin: 0 0 6px; font-size: 28px; }
.login-card p { color: var(--muted); margin: 0 0 22px; }
.err { color: #ff8b87; margin-top: 12px; }

/* layout */
.shell { display: flex; flex-direction: column; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: rgba(0,0,0,.25); border-bottom: 1px solid var(--line); }
.topbar .brand { font-weight: 700; font-size: 18px; flex: 1; }
.topbar .user { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 16px; padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.panel-head { background: var(--accent-2); padding: 10px 12px; display: flex; align-items: center; gap: 6px; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; flex: 1; }
.panel-body { overflow: auto; flex: 1; }
.editor-body { padding: 0 0 24px; }

/* botones */
.btn { background: var(--accent); border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 600; text-decoration: none; display: inline-block; color: #fff; }
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: #3a4152; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: rgba(255,255,255,.12); border: 0; border-radius: 6px; width: 30px; height: 30px; color: #fff; font-weight: 700; }
.icon-btn:hover { background: rgba(255,255,255,.25); }
.icon-btn.on { background: rgba(255,255,255,.35); }

/* lista */
.search { padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.search input { width: 100%; }
.section-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--panel-2); border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; font-weight: 700; }
.section-head .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-head .count { color: var(--muted); font-weight: 400; }
.chev { display: inline-block; width: 14px; transition: transform .15s; color: var(--muted); }
.chev.open { transform: rotate(90deg); }
.item { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; background: var(--panel-2); }
.item:hover { background: #2a303b; }
.item.active { background: #2f4a47; }
.item .t { min-width: 0; }
.item .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: #3a4152; color: var(--muted); margin-left: 6px; font-weight: 600; }
.empty { padding: 20px; color: var(--muted); text-align: center; }

/* avatares */
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; display: grid; place-items: center; font-weight: 700; color: #fff; background: #555; }
.avatar.sm { width: 24px; height: 24px; font-size: 12px; }
.avatar.lg { width: 150px; height: 150px; font-size: 56px; border: 6px solid var(--panel); background-color: #444; }

/* editor */
.banner { height: 110px; background: linear-gradient(135deg, #3f8a73, #2d6f60); position: relative; }
.hero { padding: 0 24px; margin-top: -80px; position: relative; display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.hero .change { margin-bottom: 12px; }
.title { font-size: 28px; margin: 12px 24px 4px; font-weight: 500; word-break: break-word; }
.sub { color: var(--muted); margin: 0 24px 12px; }
.form { padding: 0 24px; display: grid; gap: 16px; }
.field label, .lbl { display: block; font-weight: 600; margin-bottom: 5px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
input[type=text], input[type=number], select, textarea { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 110px; resize: vertical; }
.row { display: flex; gap: 0; }
.row > input:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1; }
.row > input:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; flex: 0 0 30%; border-left: 0; }
.brackets { display: flex; align-items: stretch; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.brackets input { border: 0; border-radius: 0; background: transparent; text-align: right; flex: 1; }
.brackets input:last-child { text-align: left; }
.brackets .mid { padding: 9px 12px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #3a4152; border-radius: 99px; padding: 3px 10px; font-size: 13px; }
.chip small { color: var(--muted); }
.preview { background: var(--panel-2); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 14px; }
.preview .who { display: flex; align-items: center; gap: 10px; }
.actions { display: flex; gap: 10px; padding: 8px 24px 0; }
.actions .grow { flex: 1; }
.members { margin: 0; padding-left: 18px; color: var(--muted); }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 10; }
.toast { background: #11141a; border: 1px solid var(--line); border-left: 4px solid var(--ok); padding: 10px 14px; border-radius: 8px; max-width: 340px; }
.toast.error { border-left-color: var(--danger); }

@media (max-width: 800px) {
  .shell { height: auto; min-height: 100vh; }
  .main { grid-template-columns: 1fr; }
  .panel { max-height: none; }
  #list-panel .panel-body { max-height: 45vh; }
  .two { grid-template-columns: 1fr; }
}

/* marca e idioma */
.brand small { font-weight: 400; color: var(--muted); font-size: 13px; }
select.lang { width: auto; padding: 5px 8px; font-size: 13px; border-radius: 8px; max-width: 190px; }
.login-lang { position: absolute; top: 12px; right: 12px; }
.login { position: relative; }
.tagline { color: var(--muted); margin: 0 0 14px; font-size: 14px; letter-spacing: .04em; }
.login-card h1 { margin-bottom: 0; }

/* barra superior en pantallas estrechas */
.topbar { flex-wrap: wrap; }
.topbar .user span { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 800px) {
  .brand small { display: none; }
  select.lang { max-width: 150px; }
  .topbar .user span { max-width: 90px; }
  .topbar { gap: 8px; padding: 8px 12px; }
}

/* usuario en la barra superior: nombre visible + círculo con su imagen */
.topbar .user { gap: 10px; color: var(--text); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: #444; border: 2px solid var(--line); }

/* tags: campo + casillas debajo + autocompletado */
.tagfield { position: relative; }
.tagmenu { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; z-index: 5; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; max-height: 240px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.tagmenu .opt { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px; cursor: pointer; }
.tagmenu .opt:hover, .tagmenu .opt.active { background: #2f4a47; }
.tagmenu .forget, .chip .x { background: none; border: 0; color: var(--muted); padding: 0 4px; font-size: 16px; line-height: 1; }
.tagmenu .forget:hover, .chip .x:hover { color: #ff8b87; }
.chip .x { margin-left: 4px; }
.tagchips { margin-top: 8px; min-height: 30px; align-items: center; }
.tagcount { text-align: right; }

/* fondo: textura de grano muy sutil (SVG de ruido en línea, sin ficheros ni scripts) */
#app { position: relative; z-index: 1; }
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .09;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.1 -.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
}

/* logo: sin recuadro. Contorno blanco tipo pegatina que sigue la silueta (para que el negro se lea sobre el tema oscuro) */
.brand { display: flex; align-items: center; gap: 10px; }
.logo-mark, .login-logo {
  --o: 1.5px;
  filter: drop-shadow(var(--o) 0 0 #fff) drop-shadow(calc(var(--o) * -1) 0 0 #fff) drop-shadow(0 var(--o) 0 #fff) drop-shadow(0 calc(var(--o) * -1) 0 #fff);
}
.logo-mark { flex: none; width: 46px; height: 46px; background: url('/logo.png') center / contain no-repeat; margin: 2px 4px 2px 2px; }
.login-logo { --o: 3px; width: 210px; height: 210px; object-fit: contain; margin: 0 auto 10px; display: block; }
