/* ============================================================
   FEX — visual system
   Aligned with firstemerald.ch: near-black background with a
   green cast, slightly lighter rounded cards, a single gold
   accent, neo-grotesque type, no ornament.
   The colours are sampled from the site, not estimated.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:        #090E0A;
  --surface:   #0E1712;
  --surface-2: #0D1311;
  --line:      #1B2620;
  --text:      #E1E6E0;
  --muted:     #8D968F;
  --gold:      #C49F58;
  --gold-dim:  #483F24;
  --ok:        #6FBF8F;
  --alert:     #D07A5E;

  --sans: 'Inter', -apple-system, 'Segoe UI', Helvetica, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --r: 12px;
  --r-lg: 16px;
  --gutter: clamp(1.25rem, 5vw, 4rem);
  --max: 1180px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: -0.005em;
  font-feature-settings: 'tnum' 1;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px;
}

.wrap { max-width: var(--max); margin: 0 auto; }
.mono { font-family: var(--mono); font-size: .84em; }
.muted { color: var(--muted); }
.hash { font-family: var(--mono); font-size: .72rem; color: var(--muted); word-break: break-all; }
.gold { color: var(--gold); }

/* ---------------------------------------------------- intestazione */

header.top {
  position: sticky; top: 0; z-index: 30;
  background: rgba(9, 14, 10, .93);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
header.top .bar {
  max-width: var(--max); margin: 0 auto;
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: .9rem var(--gutter);
}

.wordmark { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--text); }
.wordmark:hover { text-decoration: none; }
.wordmark .mark { height: 32px; width: auto; display: block; }
.wordmark .name {
  font-weight: 700; font-size: .95rem; letter-spacing: .04em;
  text-transform: uppercase; line-height: 1.15;
}
.wordmark .name em { font-style: normal; color: var(--gold); }
.wordmark .name small {
  display: block; font-size: .62rem; font-weight: 400; letter-spacing: .02em;
  text-transform: none; color: var(--muted); margin-top: 1px;
}

nav.top-nav { display: flex; gap: 1.4rem; margin-left: auto; flex-wrap: wrap; }
nav.top-nav a { font-size: .82rem; color: var(--muted); text-decoration: none; font-weight: 500; }
nav.top-nav a:hover, nav.top-nav a.on { color: var(--text); text-decoration: none; }

.phase {
  font-size: .7rem; font-weight: 500; padding: .3rem .8rem;
  border: 1px solid var(--gold-dim); color: var(--gold);
  border-radius: 999px; white-space: nowrap;
}

/* ------------------------------------------------------------ hero */

.hero { padding: clamp(2.5rem, 7vw, 5rem) var(--gutter) 2.5rem; max-width: var(--max); margin: 0 auto; }
.hero h1 {
  font-weight: 700; font-size: clamp(1.85rem, 4.2vw, 2.9rem);
  line-height: 1.13; letter-spacing: -0.025em; margin: 0 0 1.1rem; max-width: 22ch;
}
.hero h1 .alt { color: var(--gold); display: block; }
.hero .lede { max-width: 60ch; color: var(--muted); margin: 0 0 2.6rem; font-size: 1rem; }

/* ------------------------------ signature element: the vault bar */

.vault-bar .track {
  display: flex; height: 72px; width: 100%;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface-2); position: relative; overflow: hidden;
}
.vault-bar .seg {
  height: 100%; border-right: 1px solid var(--bg);
  background: linear-gradient(180deg, #1E3A2C 0%, #16281F 100%);
  cursor: pointer; transition: filter .15s ease;
}
.vault-bar .seg:last-child { border-right: 0; }
.vault-bar .seg:hover { filter: brightness(1.6); }
.vault-bar .seg[data-status="1"] { background: repeating-linear-gradient(45deg, #131C17 0 5px, #0E1712 5px 10px); }
.vault-bar .seg[data-status="3"] { background: #3A1F17; }
.vault-bar .seg[data-status="4"] { background: #141A17; }

.vault-bar .claim-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--gold); }
.vault-bar .claim-line::after {
  content: attr(data-label);
  position: absolute; top: 100%; left: 0; transform: translateX(-50%);
  margin-top: .55rem; white-space: nowrap;
  font-family: var(--mono); font-size: .68rem; color: var(--gold);
}
.vault-legend {
  display: flex; gap: 1.5rem; flex-wrap: wrap; margin-top: 2.4rem;
  font-size: .74rem; color: var(--muted);
}
.vault-legend span::before {
  content: ''; display: inline-block; width: 10px; height: 10px;
  margin-right: .45rem; vertical-align: -1px; border-radius: 2px;
}
.vault-legend .l-custody::before { background: linear-gradient(180deg,#1E3A2C,#16281F); }
.vault-legend .l-registered::before { background: repeating-linear-gradient(45deg,#131C17 0 3px,#0E1712 3px 6px); }
.vault-legend .l-claim::before { background: var(--gold); width: 2px; border-radius: 0; }

/* ------------------------------------------------------- indicatori */

.figures {
  max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter);
  display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
/* six figures: three columns give two full rows instead of 4+2 */
@media (min-width: 900px) { .figures { grid-template-columns: repeat(3, 1fr); } }
.fig { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.15rem 1.25rem 1.3rem; }
.fig .k { font-size: .74rem; color: var(--muted); display: block; margin-bottom: .55rem; }
.fig .v { font-family: var(--mono); font-size: 1.45rem; font-weight: 500; line-height: 1; }
.fig .u { font-size: .72rem; color: var(--muted); margin-left: .3rem; }
.fig .note { font-size: .74rem; color: var(--muted); margin-top: .5rem; line-height: 1.45; }
.fig.good .v { color: var(--ok); }
.fig.bad .v { color: var(--alert); }

/* --------------------------------------------------------- sezioni */

section.block { max-width: var(--max); margin: 0 auto; padding: clamp(2.4rem, 5vw, 3.6rem) var(--gutter); }
section.block > h2 { font-size: clamp(1.15rem, 2.2vw, 1.5rem); font-weight: 600; letter-spacing: -0.02em; margin: 0 0 .5rem; }
section.block > h2 .alt { color: var(--gold); }
section.block > .sub { color: var(--muted); max-width: 66ch; margin: 0 0 1.8rem; font-size: .92rem; }

/* --------------------------------------------------------- tabelle */

.table-wrap { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data th {
  text-align: left; font-weight: 500; font-size: .72rem; color: var(--muted);
  padding: .85rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: rgba(196, 159, 88, .045); }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); }
.clickable { cursor: pointer; }

.pill { display: inline-block; font-size: .7rem; font-weight: 500; padding: .18rem .6rem; border: 1px solid currentColor; border-radius: 999px; }
.pill.ok { color: var(--ok); }
.pill.warn { color: var(--gold); }
.pill.bad { color: var(--alert); }
.pill.idle { color: var(--muted); }

/* ----------------------------------------------------------- card */

.cards { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(265px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.4rem; }
.card h3 { font-size: .98rem; margin: 0 0 .5rem; font-weight: 600; }
.card p { margin: 0 0 .5rem; font-size: .86rem; color: var(--muted); }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: .4rem 1rem; margin: 1rem 0 0; font-size: .82rem; }
.card dt { color: var(--muted); }
.card dd { margin: 0; font-family: var(--mono); text-align: right; }

/* -------------------------------------------------------- controlli */

button, .btn {
  font-family: var(--sans); font-size: .84rem; font-weight: 500;
  padding: .55rem 1.15rem; border: 1px solid var(--gold-dim);
  background: transparent; color: var(--gold);
  border-radius: 999px; cursor: pointer; transition: border-color .15s, background .15s;
}
button:hover, .btn:hover { border-color: var(--gold); background: rgba(196, 159, 88, .08); }
button.solid { background: var(--gold); color: var(--bg); border-color: var(--gold); font-weight: 600; }
button.solid:hover { filter: brightness(1.1); background: var(--gold); }
button.ghost { color: var(--muted); border-color: var(--line); }
button.ghost:hover { color: var(--text); border-color: var(--muted); background: transparent; }
button:disabled { opacity: .35; cursor: not-allowed; }

input, select, textarea {
  font-family: var(--mono); font-size: .82rem; padding: .55rem .75rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--text); width: 100%;
}
input::placeholder { color: #55605A; }
label.field { display: block; margin-bottom: .85rem; }
label.field span { display: block; font-size: .74rem; color: var(--muted); margin-bottom: .35rem; }

/* ------------------------------------------------------------ modale */

dialog { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0; max-width: min(720px, 92vw); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(5, 8, 6, .78); }
dialog .dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--line); }
dialog .dlg-head h3 { margin: 0; font-weight: 600; font-size: 1.1rem; letter-spacing: -0.02em; }
dialog .dlg-body { padding: 1.4rem; max-height: 68vh; overflow: auto; }
dialog .dlg-body .table-wrap { background: var(--surface-2); }
dialog pre { font-family: var(--mono); font-size: .72rem; background: var(--surface-2); padding: .9rem; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin: 1rem 0 0; color: var(--muted); }
dialog code { font-family: var(--mono); color: var(--gold); }

/* -------------------------------------------------------- log eventi */

.log { font-family: var(--mono); font-size: .74rem; max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.log div { padding: .5rem 1rem; border-bottom: 1px solid var(--line); display: flex; gap: 1rem; }
.log div:last-child { border-bottom: 0; }
.log .ev { color: var(--gold); min-width: 195px; }
.log .ct { color: var(--muted); min-width: 125px; }
.log .ar { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------- avvisi */

.notice { border: 1px solid var(--gold-dim); background: rgba(196, 159, 88, .05); border-radius: var(--r); padding: .95rem 1.15rem; font-size: .85rem; margin: 0 0 1.6rem; max-width: 74ch; color: var(--muted); }
.notice strong { color: var(--gold); font-weight: 600; }

footer.foot { border-top: 1px solid var(--line); margin-top: 2rem; }
footer.foot .inner { max-width: var(--max); margin: 0 auto; padding: 2.2rem var(--gutter) 3rem; font-size: .78rem; color: var(--muted); display: flex; gap: 1.5rem; flex-wrap: wrap; justify-content: space-between; }

/* ---------------------------------------------------------- console */

.ops-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.ops-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 1.3rem; }
.ops-panel h3 { margin: 0 0 .3rem; font-size: .95rem; font-weight: 600; }
.ops-panel h3 .n { color: var(--gold); margin-right: .4rem; }
.ops-panel p.hint { font-size: .82rem; color: var(--muted); margin: 0 0 1rem; }
.ops-out { font-family: var(--mono); font-size: .74rem; white-space: pre-wrap; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem; max-height: 340px; overflow: auto; margin-top: 1.4rem; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; }
.row > * { flex: 1 1 auto; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
