/* Panel de Cerberus
   Paleta: basalto ciruela (el inframundo que guarda) y bronce (la puerta). Verde musgo = activo, brasa = peligro.
   Tipos: Bricolage Grotesque para títulos, Atkinson Hyperlegible para leer formularios largos sin cansarse. */

:root {
  --bg: #1f1830;
  --panel: #2a2140;
  --panel-2: #342a4f;
  --line: #46395f;
  --text: #ede7f5;
  --muted: #a99cbf;
  --bronze: #d19a55;
  --bronze-strong: #e2ad68;
  --on-bronze: #2a1c0b;
  --moss: #7bc79a;
  --ember: #ec7259;
  --focus: #f0c27d;
  --shadow: 0 18px 40px rgba(8, 4, 16, .45);
  --radius-s: 6px;
  --radius-m: 10px;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f1f8;
    --panel: #ffffff;
    --panel-2: #eee8f6;
    --line: #d9cfe7;
    --text: #251b35;
    --muted: #6b5d80;
    --bronze: #9c6524;
    --bronze-strong: #845317;
    --on-bronze: #fff8ee;
    --moss: #2f8a57;
    --ember: #c2412a;
    --focus: #9c6524;
    --shadow: 0 18px 40px rgba(37, 27, 53, .14);
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--body); }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; }
a { color: var(--bronze-strong); }
img { display: block; }
code { font: .9em/1 ui-monospace, "Cascadia Code", Menlo, monospace; background: var(--panel-2); padding: .1em .35em; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus { left: 8px; z-index: 50; background: var(--panel); padding: 8px 12px; border-radius: var(--radius-s); }

/* ------------------------------------------------------------------ botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  font: 700 .95rem/1 var(--body); padding: .7em 1.1em; border-radius: var(--radius-s);
  border: 1px solid transparent; cursor: pointer; text-decoration: none; color: inherit; background: none;
}
.btn.primary { background: var(--bronze); color: var(--on-bronze); }
.btn.primary:hover { background: var(--bronze-strong); }
.btn.ghost { border-color: var(--line); color: var(--text); }
.btn.ghost:hover { border-color: var(--bronze); }
.btn.danger { color: var(--ember); }
.btn.danger:hover { border-color: var(--ember); }
.btn.small { font-size: .85rem; padding: .5em .8em; }
.btn.big { font-size: 1.05rem; padding: .9em 1.4em; }
.btn[disabled], .btn.busy { opacity: .55; pointer-events: none; }
.linklike { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.linklike:hover { color: var(--text); }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ------------------------------------------------------- entrada / errores */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-main { max-width: 30rem; text-align: center; display: grid; justify-items: center; gap: 1rem; }
.gate-main h1 { font-size: clamp(2rem, 6vw, 2.8rem); font-weight: 800; letter-spacing: -.02em; }
.gate-mark { margin-bottom: .25rem; }
.lead { color: var(--muted); margin: 0; font-size: 1.05rem; }
.fine { color: var(--muted); font-size: .85rem; margin: 0; }

.gate.wide { place-items: start center; }
.servers { width: min(1000px, 100%); }
.servers-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; margin: 2rem 0 1.5rem; }
.servers-head h1 { font-size: clamp(2rem, 5vw, 2.6rem); font-weight: 800; }
.who { display: flex; align-items: center; gap: .75rem; }
.who img { border-radius: 50%; }
.server-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.server { display: grid; grid-template-columns: 56px 1fr; grid-template-rows: auto auto; gap: .35rem .9rem; align-items: center;
  padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); }
.server img, .server .guild-initial { grid-row: span 2; border-radius: 16px; }
.server strong { font-family: var(--display); font-size: 1.05rem; overflow-wrap: anywhere; }
.server .btn { justify-self: start; }
.server.absent { opacity: .75; }
.guild-initial { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--panel-2);
  font: 800 1.2rem var(--display); color: var(--bronze-strong); }
.guild-initial.big { width: 56px; height: 56px; font-size: 1.5rem; }

/* ------------------------------------------------------------- estructura */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 14px; }
.guild-head { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); padding: 4px 6px; }
.guild-head img { border-radius: 12px; }
.guild-head strong { display: block; font-family: var(--display); font-size: 1.05rem; line-height: 1.2; overflow-wrap: anywhere; }
.guild-head small { color: var(--muted); }
.rail nav { display: grid; gap: 14px; }
.nav-overview { display: block; padding: 7px 10px; border-radius: var(--radius-s); text-decoration: none; color: var(--text); font-weight: 700; }
.nav-head h3 { font-size: .95rem; color: var(--bronze-strong); padding: 0 10px 4px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-weight: 700; }
.nav-head ul { list-style: none; margin: 0; padding: 0; }
.nav-head a { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: var(--radius-s); text-decoration: none; color: var(--text); font-size: .95rem; }
.nav-head a:hover, .nav-overview:hover { background: var(--panel-2); }
.rail a.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--bronze); }
.nav-icon { width: 1.3em; text-align: center; }
.dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.on { background: var(--moss); }
.dot.off { border: 1.5px solid var(--muted); }
.rail-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 10px 8px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.rail-foot a { color: var(--muted); }
.rail-toggle { display: none; }

.main { padding: 32px clamp(16px, 4vw, 48px) 120px; max-width: 980px; width: 100%; }
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: -.015em; }
.page-head .lead { margin-top: 4px; }

.banner { background: var(--panel-2); border-left: 3px solid var(--bronze); padding: 12px 14px; border-radius: var(--radius-s); margin: 0 0 20px; }
.banner.warn { border-left-color: var(--ember); }
.callout { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; margin-bottom: 24px; display: grid; gap: 10px; }
.callout p { margin: 0; }
.callout.danger { border-color: var(--ember); }
.aside-link { margin-top: 0; }
.empty { color: var(--muted); }

/* -------------------------------------------------------------- resumen */
.dash-head h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); }
.facts { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 10px 0 0; color: var(--muted); }
.facts b { color: var(--text); font-family: var(--display); font-size: 1.15rem; }
/* Las tres cabezas: el elemento que da nombre al bot */
.heads { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-top: 3px solid var(--bronze); margin: 8px 0 40px; }
.head-col { padding: 20px 18px 8px; }
.head-col + .head-col { border-left: 1px solid var(--line); }
.head-col h2 { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.head-sub { color: var(--muted); margin: 2px 0 14px; font-size: .92rem; }
.head-col ul { list-style: none; margin: 0; padding: 0; }
.head-col a { display: flex; align-items: center; gap: 10px; padding: 9px 4px; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--line); }
.head-col li:last-child a { border-bottom: 0; }
.head-col a:hover strong { color: var(--bronze-strong); }
.mod-text { display: grid; min-width: 0; }
.mod-text small { color: var(--muted); font-size: .82rem; }
.pill { display: inline-block; vertical-align: 2px; margin-left: 6px; font: 400 .72rem/1.3 var(--body); padding: .2em .6em; border-radius: 99px; white-space: nowrap; flex: none; }
.pill.on { color: var(--moss); border: 1px solid currentColor; }
.pill.off { color: var(--muted); border: 1px dashed currentColor; }
.history h2 { font-size: 1.3rem; margin-bottom: 10px; }
.history ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.history li { display: grid; grid-template-columns: 10.5em 9em minmax(0, 1fr); gap: 12px; align-items: baseline; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.history time { color: var(--muted); font-size: .88rem; }
.history li strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------------ formularios */
.section { margin-bottom: 34px; }
.section > h2 { font-size: 1.35rem; font-weight: 700; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.section-help { color: var(--muted); margin: 8px 0 0; font-size: .92rem; }
.fields { display: grid; }
.field { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 8px 24px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: start; }
.field-label label { font-weight: 700; }
.help { margin: 3px 0 0; color: var(--muted); font-size: .86rem; }
.field-control { display: grid; gap: 6px; justify-items: start; }
.field-error { color: var(--ember); margin: 0; font-size: .88rem; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--ember); }

input[type=text], input[type=number], input:not([type]), select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: .55em .7em; width: 100%; max-width: 100%;
}
.field-control input[type=number] { width: 7.5em; }
textarea { resize: vertical; min-height: 4.5em; }
select { cursor: pointer; }
input:disabled, select:disabled, textarea:disabled { opacity: .6; }
.with-unit { display: inline-flex; align-items: center; gap: 8px; }
.unit { color: var(--muted); }
.color-pair { display: inline-flex; gap: 8px; align-items: center; }
.color-pair input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel); }
.color-pair input[type=text] { width: 7.5em; }
.limit { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); }
.limit input { width: 5.5em !important; }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + span { background: var(--bronze); border-color: var(--bronze); }
.switch input:checked + span::after { transform: translateX(20px); background: var(--on-bronze); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.chips { display: grid; gap: 8px; width: 100%; }
.chip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip-list:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: .15em .25em .15em .7em; font-size: .9rem; }
.chip button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; line-height: 1; padding: 2px 6px; border-radius: 50%; }
.chip button:hover { color: var(--ember); }

.rules { width: 100%; display: grid; gap: 8px; }
.rule-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.rule { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rule input { width: 5em !important; }
.rule select { width: auto; }

.savebar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--bronze); border-radius: var(--radius-m); padding: 10px 12px 10px 18px; box-shadow: var(--shadow);
  width: max-content; max-width: calc(100vw - 32px); }
.savebar span { font-weight: 700; }
@media (prefers-reduced-motion: no-preference) {
  .savebar:not([hidden]) { animation: rise .2s ease-out; }
  @keyframes rise { from { transform: translate(-50%, 12px); opacity: 0; } }
}

/* ------------------------------------------------------------ listados */
.data-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.data-head h2 { font-size: 1.35rem; font-weight: 700; }
.data-head h2 small, .data-head h3 small { color: var(--muted); font: 400 .9rem var(--body); margin-left: 6px; }
.data-head h3 { font-size: 1.1rem; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 20px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.rows.compact .row { padding: 9px 0; }
.row.muted { opacity: .65; }
.row-main { display: grid; gap: 4px; min-width: 0; flex: 1 1 320px; }
.row-main strong small { color: var(--muted); font-weight: 400; }
.row-meta { display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: .88rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-actions select { width: 13rem; max-width: 100%; }
.tag { display: inline-block; padding: .1em .55em; border-radius: var(--radius-s); background: var(--panel-2); color: var(--text); font-size: .85rem; }
.tag.live { color: var(--moss); }
.quote { margin: 0; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.subpanel { padding: 14px 0 6px; border-bottom: 1px solid var(--line); }
.subpanel .data-head { border-bottom: 0; padding-bottom: 0; }
.status-approved strong, .status-implemented strong { color: var(--moss); }
.status-denied strong { color: var(--ember); }
.filters { display: flex; flex-wrap: wrap; gap: 4px; }
.filters a { padding: .3em .7em; border-radius: 99px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.filters a.active { background: var(--panel-2); color: var(--text); }
.filters-bar { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 12px; }
.filters-bar label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
.filters-bar select, .filters-bar input { width: 14rem; }
label.inline { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
label.inline select { width: auto; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-family: var(--display); font-weight: 700; padding: 8px 10px 8px 0; border-bottom: 2px solid var(--line); }
.table td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.muted td { color: var(--muted); }
.act-ban, .act-tempban, .act-softban { color: var(--ember); }
.act-warn { color: var(--bronze-strong); }
.pager { display: flex; align-items: center; gap: 12px; margin-top: 14px; color: var(--muted); }
.mention { color: var(--bronze-strong); }
.mention.role { color: var(--c, var(--bronze-strong)); }

/* ------------------------------------------------------------- diálogos */
.dialog { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--panel); color: var(--text); padding: 0;
  width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(10, 6, 18, .6); }
.dialog form, .inline-form { display: grid; gap: 12px; padding: 22px; }
.inline-form { padding: 14px 0 0; }
.dialog h2 { font-size: 1.35rem; }
.dialog label, .inline-form label { display: grid; gap: 4px; font-weight: 700; font-size: .92rem; }
.dialog label.check, .inline-form label.check, label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog details summary { cursor: pointer; color: var(--bronze-strong); font-weight: 700; }
.dialog details[open] { display: grid; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog-result { margin: 0; padding: 10px 12px; border-radius: var(--radius-s); background: var(--panel-2); }
.dialog-result.error { border-left: 3px solid var(--ember); }

/* --------------------------------------------------------------- avisos */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 60; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--moss); border-radius: var(--radius-s); padding: 12px 14px; box-shadow: var(--shadow); }
.toast.error { border-left-color: var(--ember); }

/* --------------------------------------------------------------- móvil */
@media (max-width: 900px) {
  .heads { grid-template-columns: 1fr; }
  .head-col + .head-col { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: fixed; inset: 0 25% 0 0; z-index: 40; transform: translateX(-102%); transition: transform .2s; height: 100%; box-shadow: var(--shadow); }
  .rail.open { transform: none; }
  .rail-toggle { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; width: 100%; padding: 12px 16px;
    background: var(--panel); color: var(--text); border: 0; border-bottom: 1px solid var(--line); font: 700 1rem var(--display); cursor: pointer; }
  .rail-toggle span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding: 20px 16px 120px; }
  .field { grid-template-columns: 1fr; }
  .two { grid-template-columns: 1fr; }
  .history li { grid-template-columns: 1fr; gap: 2px; }
  .savebar { left: 16px; right: 16px; transform: none; width: auto; flex-wrap: wrap; justify-content: flex-end; }
  .savebar span { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { .rail { transition: none; } }
