/* control.mad.ceo · prototipo. Tokens del sistema EJE, tema ink. */
:root {
  --canvas: #0a0a0a; --rail: #0d0d10; --surface: rgba(255,255,255,0.035); --elevated: #141414;
  --fill: rgba(255,255,255,0.04); --fill-strong: rgba(255,255,255,0.06);
  --separator: rgba(255,255,255,0.08); --border: rgba(255,255,255,0.1);
  --label: #f4f4f5; --label-2: #a1a1aa; --label-3: #71717a;
  --danger: #fb7185; --warning: #fbbf24; --success: #34d399;
  --keystore: #007aff; --keystore-2: #5ac8fa; --keystore-3: #5856d6;
  --harald: #ea580c; --harald-2: #fbbf24; --senescal: #3b82f6; --senescal-2: #22d3ee;
  --arcano: #a855f7; --arcano-2: #e879f9; --vigia: #10b981; --vigia-2: #2dd4bf;
  --radius-12: 12px; --radius-16: 16px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--canvas); color: var(--label); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--senescal-2); outline-offset: 2px; }
[hidden] { display: none !important; }

.shell { height: 100%; display: grid; grid-template-columns: 272px minmax(0, 1fr); }

/* Riel */
.rail { background: var(--rail); border-right: 1px solid var(--separator); display: flex; flex-direction: column; gap: 20px;
  padding-block: 20px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: 16px; min-height: 0; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding-inline: 6px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: conic-gradient(from 210deg, var(--keystore), var(--senescal-2), var(--vigia), var(--harald-2), var(--harald), var(--arcano), var(--keystore)); }
.brand-mark::after { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--rail); }
.brand b { display: block; font-size: 14px; }
.brand small { display: block; color: var(--label-3); font-size: 11px; margin-top: 2px; }
.back-link { display: inline-block; margin: 0 0 14px; font-size: 12.5px; color: var(--label-2); text-decoration: none; }
.back-link:hover { color: var(--label); }
.section-label { color: var(--label-3); font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; padding-inline: 8px; margin: 14px 0 6px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border-radius: var(--radius-12); border: 1px solid transparent;
  background: none; cursor: pointer; text-align: left; transition: background .15s, border-color .15s; }
.nav button:hover { background: var(--fill); }
.nav button[aria-current="page"] { background: var(--fill-strong); border-color: var(--separator); box-shadow: inset 2px 0 0 var(--accent, var(--label-2)); }
.nav img, .nav-ico { width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0; }
.nav-ico { display: grid; place-items: center; background: var(--fill-strong); color: var(--label-2); }
.nav-ico svg { width: 16px; height: 16px; }
.nav .txt { min-width: 0; }
.nav .txt b { display: block; font-weight: 600; font-size: 13.5px; }
.nav .txt span { display: block; color: var(--label-3); font-size: 11.5px; margin-top: 1px; }
[data-module="keystore"] { --accent: var(--keystore); } [data-module="harald"] { --accent: var(--harald); }
[data-module="senescal"] { --accent: var(--senescal); } [data-module="arcano"] { --accent: var(--arcano); } [data-module="vigia"] { --accent: var(--vigia); }

.guide { list-style: none; margin: 0; padding: 0 4px; display: flex; flex-direction: column; gap: 10px; counter-reset: step; }
.guide li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 8px; color: var(--label-2); font-size: 12.5px; line-height: 1.45; counter-increment: step; }
.guide li::before { content: counter(step); width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--separator); color: var(--label-3); font: 500 10.5px/18px var(--mono); text-align: center; }
.guide b { color: var(--label); font-weight: 500; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-inline: 6px; }
.rail-foot p { margin: 0; color: var(--label-3); font-size: 11.5px; line-height: 1.5; }
.reset { align-self: flex-start; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--separator); background: none; color: var(--label-2); font-size: 12px; cursor: pointer; }
.reset:hover { color: var(--label); border-color: var(--border); }
.reset[data-confirm="true"] { color: var(--danger); border-color: rgba(251, 113, 133, .4); }

/* Columna principal */
.main { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding-block: 10px; padding-left: 18px;
  padding-right: max(16px, env(safe-area-inset-right, 0px)); border-bottom: 1px solid var(--separator); background: rgba(255,255,255,.015); }
.ctx { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; min-width: 0; }
.field { display: flex; align-items: center; gap: 8px; }
.field label { color: var(--label-3); font-size: 11.5px; white-space: nowrap; }
.field select { appearance: none; height: 32px; padding: 0 30px 0 12px; border-radius: 10px; border: 1px solid var(--separator); background-color: var(--fill);
  cursor: pointer; font-size: 13px; max-width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='none' stroke='%23a1a1aa' stroke-width='1.6' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.field select:hover { border-color: var(--border); }
.field select option { background: var(--elevated); }
.field select:disabled { opacity: .45; cursor: not-allowed; }
.claims { margin: 0; font: 500 11px/1.4 var(--mono); color: var(--label-3); min-width: 0; overflow-wrap: anywhere; }
.claims em { font-style: normal; color: var(--label-2); }
.badge { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 11.5px; color: var(--warning);
  border: 1px solid rgba(251,191,36,.28); background: rgba(251,191,36,.06); padding: 4px 10px; border-radius: 999px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--warning); }
.stage { position: relative; min-height: 0; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: var(--canvas); }

/* Inicio */
.home { position: absolute; inset: 0; overflow-y: auto; padding: 28px max(16px, env(safe-area-inset-right, 0px)) 40px 28px;
  background: radial-gradient(60rem 30rem at 10% -10%, rgba(59,130,246,.10), transparent 60%), radial-gradient(40rem 24rem at 100% 0%, rgba(234,88,12,.07), transparent 60%); }
.home h1 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.home .lead { margin: 6px 0 0; color: var(--label-2); max-width: 62ch; }
.tiles { margin-top: 22px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tile { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: var(--radius-16); border: 1px solid var(--separator);
  background: var(--surface); text-align: left; cursor: pointer; transition: border-color .15s, background .15s; overflow: hidden; }
.tile:hover { border-color: var(--border); background: var(--fill-strong); }
.tile::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.tile[data-module="keystore"] { --accent-2: var(--keystore-2); } .tile[data-module="harald"] { --accent-2: var(--harald-2); }
.tile[data-module="senescal"] { --accent-2: var(--senescal-2); } .tile[data-module="arcano"] { --accent-2: var(--arcano-2); } .tile[data-module="vigia"] { --accent-2: var(--vigia-2); }
.tile-head { display: flex; align-items: center; gap: 10px; }
.tile-head img { width: 32px; height: 32px; border-radius: 9px; }
.tile-head b { display: block; font-size: 15px; }
.tile-head span { display: block; font-size: 12px; color: var(--label-2); }
.tile-num { font-size: 30px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 12.5px; color: var(--label-2); }
.tile-sub.is-warn { color: var(--warning); } .tile-sub.is-bad { color: var(--danger); }
.tile-bar { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--fill-strong); gap: 2px; }
.tile-bar i { display: block; height: 100%; }
.tile-open { margin-top: auto; font-size: 12.5px; color: var(--label); }
.tile-open::after { content: " →"; color: var(--label-2); }
.home h2 { margin: 30px 0 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--label-3); }
.feed { list-style: none; margin: 0; padding: 0; border: 1px solid var(--separator); border-radius: var(--radius-16); overflow: hidden; }
.feed li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; font-size: 13px; }
.feed li + li { border-top: 1px solid var(--separator); }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--accent); }
.feed .when { margin-left: auto; color: var(--label-3); font: 500 11.5px var(--mono); white-space: nowrap; }
.feed .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .who { color: var(--label-2); }
.locked { color: var(--label-3); font-size: 12.5px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .rail { border-right: 0; border-bottom: 1px solid var(--separator); flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 14px;
    padding-block: 10px; padding-right: max(16px, env(safe-area-inset-right, 0px)); overflow: visible; }
  .rail nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; order: 3; overflow-x: auto; }
  .rail .section-label, .guide-wrap, .rail-foot p, .back-link { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav button { padding: 5px 9px 5px 5px; }
  .nav .txt span { display: none; }
  .nav img, .nav-ico { width: 24px; height: 24px; }
  .rail-foot { margin: 0 0 0 auto; padding: 0; }
  .brand small { display: none; }
  .bar { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
  .badge { margin-left: 0; }
  .home { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
}
@media (max-width: 520px) {
  .brand, .claims, .badge { display: none; }
  .ctx { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 8px; }
  .field { min-width: 0; }
  .field label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .field select { width: 100%; min-width: 0; padding-right: 26px; font-size: 12.5px; }
  .tiles { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
