/* Tabellone partenze: gli orari contano più del testo, lo stato si legge da lontano. */
:root {
  --ink: #16232b;
  --ink-soft: #5c6b72;
  --salt: #f1f3ef;
  --paper: #ffffff;
  --sea: #12615e;
  --lava: #b2402c;
  --amber: #c98a12;
  --stone: #d5dad3;
  --radius: 10px;
  --display: 'Space Grotesk', 'Trebuchet MS', sans-serif;
  --body: 'Public Sans', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--salt);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--display); letter-spacing: -0.015em; margin: 0; }

button { font: inherit; cursor: pointer; }

:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; }

/* L'interfaccia mostra e nasconde tutto con l'attributo `hidden`, che il
   browser rende come `display: none` — ma solo finché nessuno assegna un
   `display` a quell'elemento. `.gate` ha `display: grid`, quindi vinceva lei e
   la schermata di accesso restava sotto anche dopo un accesso riuscito: si
   vedeva il pannello caricato e la maschera di login ancora davanti, e
   sembrava che la chiave non funzionasse mentre invece funzionava.
   Qui la regola vale per tutti, non solo per `.gate`: lo stesso inganno
   toccherebbe qualunque elemento a cui si desse un `display` domani. */
[hidden] { display: none !important; }

/* ------------------------------------------------------------- accesso */

.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }

.gate-card {
  background: var(--paper);
  border: 1px solid var(--stone);
  border-radius: var(--radius);
  padding: 32px;
  width: min(420px, 100%);
}

.eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sea);
  margin: 0 0 6px;
}

.gate-card h1 { font-size: 26px; margin-bottom: 8px; }
.gate-note { color: var(--ink-soft); margin: 0 0 20px; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }

input, select, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--stone);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}

textarea { font-family: var(--body); min-height: 120px; resize: vertical; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
}

.btn-primary { background: var(--sea); color: #fff; width: 100%; margin-top: 16px; }
.btn-primary:hover { background: #0e514f; }
.btn-ghost { background: transparent; border-color: var(--stone); color: var(--ink); padding: 6px 12px; }
.btn-small { padding: 5px 10px; font-size: 13px; background: var(--paper); border: 1px solid var(--stone); border-radius: 7px; }

/* Un collegamento con l'aspetto di un pulsante: senza queste due righe si
   porta dietro la sottolineatura e l'allineamento di un testo. */
a.btn { text-decoration: none; display: inline-block; line-height: 1.5; }

.error { color: var(--lava); font-size: 14px; margin-top: 12px; }

/* -------------------------------------------------------------- guscio */

#topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--ink);
  color: #eef1ec;
  border-bottom: 3px solid var(--sea);
}

/* Il tabellone dichiara sempre se sta spedendo: in pausa cambia tutta la fascia. */
#topbar.is-paused { background: var(--lava); border-bottom-color: #7d2b1d; }

.topbar-left { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.mark { font-family: var(--display); font-weight: 700; letter-spacing: -0.02em; }
.app-name { font-family: var(--mono); font-size: 13px; opacity: 0.75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.state-label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }

.switch { background: none; border: 0; padding: 0; }
.switch-track {
  display: block;
  width: 46px;
  height: 26px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.22);
  position: relative;
  transition: background 0.18s ease;
}
.switch[aria-pressed='false'] .switch-track { background: rgba(255, 255, 255, 0.5); }
.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s ease;
}
.switch[aria-pressed='true'] .switch-knob { transform: translateX(20px); }

#tabs {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--stone);
  overflow-x: auto;
}

.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 12px 10px;
  color: var(--ink-soft);
  font-weight: 500;
  white-space: nowrap;
}
.tab.is-active { color: var(--ink); border-bottom-color: var(--sea); }

main { padding: 24px; max-width: 1000px; margin: 0 auto; }

.view-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.view-head h2 { font-size: 20px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--stone);
  background: var(--paper);
  border-radius: 99px;
  padding: 5px 14px;
  font-size: 13px;
  color: var(--ink-soft);
}
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------------------------------------------------------- tabellone */

.board { display: flex; flex-direction: column; gap: 22px; }

.day { display: flex; flex-direction: column; gap: 8px; }

.day-label {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--stone);
  padding-bottom: 6px;
}

.row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 14px;
  align-items: start;
  background: var(--paper);
  border: 1px solid var(--stone);
  border-left: 3px solid var(--stone);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.row.is-pending { border-left-color: var(--amber); }
.row.is-sent { border-left-color: var(--sea); }
.row.is-blocked, .row.is-failed { border-left-color: var(--lava); }

.row-time { font-family: var(--mono); font-size: 17px; font-weight: 500; }
.row-main { min-width: 0; }
.row-title { font-weight: 600; }
.row-meta { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.row-body { color: var(--ink-soft); font-size: 14px; margin-top: 8px; white-space: pre-wrap; }
.row-error { color: var(--lava); font-size: 13px; margin-top: 6px; }
.row-actions { display: flex; flex-direction: column; gap: 6px; }

.empty {
  background: var(--paper);
  border: 1px dashed var(--stone);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------- schede */

.cards { display: flex; flex-direction: column; gap: 12px; }

.card {
  background: var(--paper);
  border: 1px solid var(--stone);
  border-radius: var(--radius);
  padding: 16px;
}
.card h3 { font-size: 16px; margin-bottom: 4px; }
.card-meta { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.card-body { margin-top: 10px; white-space: pre-wrap; color: var(--ink-soft); font-size: 14px; }

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--stone);
  color: var(--ink-soft);
}
.tag.ok { color: var(--sea); border-color: var(--sea); }
.tag.warn { color: var(--amber); border-color: var(--amber); }
.tag.bad { color: var(--lava); border-color: var(--lava); }

.log { font-family: var(--mono); font-size: 13px; background: var(--paper); border: 1px solid var(--stone); border-radius: var(--radius); padding: 14px; }
.log div { padding: 4px 0; border-bottom: 1px solid var(--salt); color: var(--ink-soft); }
.log div:last-child { border-bottom: 0; }

@media (max-width: 640px) {
  main { padding: 16px; }
  #topbar { padding: 12px 16px; }
  #tabs { padding: 0 8px; }
  .row { grid-template-columns: 56px 1fr; }
  .row-actions { grid-column: 1 / -1; flex-direction: row; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
