/* Meridian Console — solid hex colors (no oklch) for reliable rendering */
:root {
  --bg: #f4f7f9;
  --ink: #121a22;
  --muted: #5c6b78;
  --line: #d5dee6;
  --primary: #2a5a6e;
  --primary-deep: #1a3d4d;
  --surface: #ffffff;
  --danger: #b42318;
  --ok: #067647;
  --sidebar: #152028;
  --sidebar-muted: #8b9aab;
  --sidebar-hover: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(255, 255, 255, 0.12);
  --radius: 12px;
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --shadow: 0 1px 2px rgba(18, 26, 34, 0.04), 0 8px 24px rgba(18, 26, 34, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Critical: class rules like .shell { display:flex } otherwise beat [hidden] */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body.is-login {
  overflow: hidden;
  height: 100%;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: var(--primary);
}

/* ——— Login ——— */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  background: var(--bg);
  background-image: radial-gradient(ellipse 80% 60% at 10% 0%, #d8e8ef 0%, transparent 55%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.login-brand {
  font-family: var(--display);
  font-weight: 600;
  font-size: 20px;
  color: var(--primary-deep);
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.login-sub {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.login-hint {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.login-hint code {
  font-size: 11px;
  background: #eef3f6;
  padding: 2px 6px;
  border-radius: 4px;
}

/* ——— App shell: desktop sidebar always ——— */
.shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #e8eef2;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 24px;
}

.sidebar-brand {
  font-family: var(--display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.02em;
  padding: 0 10px;
  color: #fff;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  font-weight: 500;
  font-size: 14px;
  color: var(--sidebar-muted);
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 12px 12px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
}

.nav-label {
  flex: 1;
}

.nav-count {
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 1.5rem;
  text-align: center;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 10px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
}

.sidebar-foot a {
  color: #b8c5d0;
  font-weight: 500;
  text-decoration: none;
}

.sidebar-foot a:hover {
  color: #fff;
  text-decoration: underline;
}

.linkish {
  background: none;
  border: none;
  color: var(--sidebar-muted);
  font-family: var(--font);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  padding: 0;
}

.linkish:hover {
  color: #fff;
}

/* Main */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.main-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 28px 16px;
}

.main-head h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--ink);
}

.page-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.tab-panel {
  flex: 1;
  padding: 0 28px 32px;
}

/* Applications split */
.split {
  display: flex;
  gap: 16px;
  min-height: calc(100vh - 140px);
  align-items: stretch;
}

.list-pane {
  width: 320px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.detail-pane {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 28px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.search-wrap {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}

.search-wrap input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42, 90, 110, 0.15);
}

.app-list {
  overflow-y: auto;
  flex: 1;
}

.app-row {
  width: 100%;
  text-align: left;
  font-family: var(--font);
  background: #fff;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  cursor: pointer;
  color: var(--ink);
}

.app-row:hover {
  background: #f6f9fb;
}

.app-row.active {
  background: #eef5f8;
  box-shadow: inset 3px 0 0 var(--primary);
}

.app-row strong {
  display: block;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.app-row .meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.pill {
  display: inline-block;
  margin-top: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e6f5ed;
  color: var(--ok);
}

.empty-detail,
.empty-list {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  color: var(--muted);
  text-align: center;
  padding: 32px 24px;
  font-size: 14px;
  line-height: 1.5;
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
  margin-bottom: 24px;
}

.kv span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}

.kv strong {
  font-weight: 600;
  font-size: 14px;
  word-break: break-word;
  color: var(--ink);
}

.files-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  text-decoration: none;
  color: var(--ink);
}

.file-chip:hover {
  border-color: var(--primary);
  background: #eef5f8;
}

.file-chip .fname {
  font-weight: 600;
  font-size: 14px;
}

.file-chip .meta {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
}

.file-chip .fopen {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  flex-shrink: 0;
}

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: #f8fafb;
  border-bottom: 1px solid var(--line);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

tr:last-child td {
  border-bottom: none;
}

code {
  font-size: 12px;
  background: #eef3f6;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Settings */
.settings-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px;
  align-items: start;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.settings-card.soft {
  background: #eef4f7;
  box-shadow: none;
}

.settings-card h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.card-desc {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.card-desc a {
  color: var(--primary-deep);
  font-weight: 600;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}

.field input {
  font-weight: 400;
  font-size: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42, 90, 110, 0.15);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
  cursor: pointer;
  color: var(--ink);
}

.sep {
  border: none;
  border-top: 1px solid var(--line);
  margin: 20px 0;
}

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.event-list code {
  font-weight: 700;
  font-size: 13px;
  color: var(--primary-deep);
  background: transparent;
  padding: 0;
}

.event-list span {
  font-size: 13px;
  color: var(--muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-weight: 600;
  font-size: 14px;
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary-deep);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary);
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-ghost:hover {
  background: var(--bg);
}

.toast {
  margin: 14px 0 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--ok);
}

.toast.error {
  color: var(--danger);
}

.error {
  color: var(--danger);
  font-size: 14px;
  font-weight: 500;
  margin: 8px 0 0;
}

/* Mobile: top bar, not broken pills */
@media (max-width: 900px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: column;
    padding: 12px 14px 14px;
    gap: 12px;
  }

  .sidebar-brand {
    font-size: 18px;
    padding: 4px 4px 0;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: 999px;
    background: var(--sidebar-hover);
    color: #d0dae3;
  }

  .nav-item.active {
    background: #fff;
    color: var(--sidebar);
  }

  .nav-count {
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
  }

  .nav-item.active .nav-count {
    background: rgba(21, 32, 40, 0.1);
  }

  .sidebar-foot {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 4px 0;
  }

  .main-head {
    padding: 20px 16px 12px;
  }

  .main-head h1 {
    font-size: 24px;
  }

  .tab-panel {
    padding: 0 16px 24px;
  }

  .split {
    flex-direction: column;
    min-height: 0;
  }

  .list-pane {
    width: 100%;
    max-height: 40vh;
  }

  .detail-pane {
    min-height: 300px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

/* ————————————————————— review, pipeline, agent —————————————————————
   Added with the WhatsApp agent: reviewing a package now has consequences
   (approval opens a Telegram group), so the state has to be legible at a glance. */

.review-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 0.9rem;
  margin: 0 0 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.review-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn.danger {
  color: var(--danger);
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid var(--line);
  background: #eef3f7;
  color: var(--muted);
  white-space: nowrap;
}

.status-approved,
.state-approved,
.state-telegram_sent,
.state-done {
  background: #e7f5ed;
  border-color: #b7e0c8;
  color: var(--ok);
}

.status-rejected,
.state-stopped {
  background: #fdeceb;
  border-color: #f3c3bf;
  color: var(--danger);
}

.status-in_review,
.state-form_started,
.state-submitted {
  background: #eaf1f5;
  border-color: #c3d6e0;
  color: var(--primary-deep);
}

.state-human {
  background: #fff4e5;
  border-color: #f0d5ab;
  color: #8a5a00;
}

.handover {
  display: grid;
  gap: 0.3rem;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius);
  margin: 0 0 0.9rem;
  border: 1px solid #b7e0c8;
  background: #f2fbf6;
  word-break: break-all;
}

.handover.err {
  border-color: #f3c3bf;
  background: #fdf3f2;
}

.handover .meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.handover .btn {
  justify-self: start;
  margin-top: 0.3rem;
}

/* Un bottone dentro una riga di tabella: quello a grandezza piena alzava la
   riga di venti pixel e la tabella diventava una lista di pulsanti. */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Il pacchetto completo che aspetta solo l'invio. Sta in cima alla tabella e si
   vede da lontano: e l'unica riga dove c'e qualcosa da fare adesso. */
.row-ready > td {
  background: oklch(0.97 0.03 155 / 0.55);
}

.row-ready .bar span {
  background: var(--success, #2f7d52);
}

/* Progress bars in the in-progress table */
.bar {
  width: 100%;
  max-width: 8rem;
  height: 6px;
  border-radius: 999px;
  background: #e3eaf0;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--primary);
}

td.wrap {
  max-width: 22rem;
  white-space: normal;
}

/* Agent panel */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  align-items: start;
}

.agent-status {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.agent-status .ok {
  color: var(--ok);
}

.agent-status .bad {
  color: var(--danger);
}

.agent-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.agent-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  max-height: 18rem;
  overflow-y: auto;
}

.agent-log li {
  display: grid;
  gap: 0.15rem;
  font-size: 0.82rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

.agent-log .bad {
  color: var(--danger);
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sidebar-muted);
}

.nav-dot.on {
  background: #35c07a;
}

.nav-dot.idle {
  background: #e5a83b;
}

.nav-dot.off {
  background: #7c4a45;
}

/* Conversation view */
.thread-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.thread-log {
  display: grid;
  gap: 0.6rem;
  max-height: 22rem;
  overflow-y: auto;
  padding: 0.25rem;
  margin-bottom: 1rem;
}

.bubble {
  max-width: 85%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.bubble p {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.9rem;
}

.bubble .meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.bubble.inbound {
  justify-self: start;
  background: #eef3f7;
}

.bubble.outbound {
  justify-self: end;
  background: #f2fbf6;
  border-color: #cbe7d8;
}

.thread-send {
  display: grid;
  gap: 0.5rem;
}

.thread-send textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  resize: vertical;
}

.thread-send .btn {
  justify-self: start;
}

/* The configuration card carries the most content, so it gets the widest column */
@media (min-width: 1100px) {
  .agent-grid {
    grid-template-columns: 1fr 1.5fr 1fr;
  }
}

/* Two fields side by side in the agent configuration card.
   A label that wraps to two lines must not push its input out of line with the
   neighbour, so the label grows and the inputs sit on a shared baseline. */
.field-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0 0.75rem;
  align-items: stretch;
}

.field-pair .field > span {
  flex: 1 0 auto;
}

/* "configured" next to a field whose value is deliberately never displayed */
.set-flag {
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ok);
  background: #e7f5ed;
  border: 1px solid #b7e0c8;
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  margin-left: 0.35rem;
  vertical-align: 1px;
}

/* Why the assistant said what it said, under each of its messages */
.bubble .why {
  display: block;
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  border-top: 1px dashed var(--line);
  font-size: 0.74rem;
  font-style: italic;
  color: var(--muted);
}

/* The running dossier: what the agent has learned about this person */
.dossier {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.9rem;
  background: #fbfcfd;
}

.dossier strong {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.4rem;
}

.dossier ul {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.25rem;
}

.dossier li {
  font-size: 0.85rem;
  color: var(--ink);
}

.notice-line {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius);
  background: #fff4e5;
  border: 1px solid #f0d5ab;
  font-size: 0.83rem;
  color: #8a5a00;
}

/* ——— Half finished package: the detail over the In progress table ——— */
.row-open {
  border: 0;
  background: none;
  padding: 0;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 3px;
}

.row-open:hover {
  color: var(--primary);
  text-decoration-color: currentColor;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 26, 34, 0.42);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(46rem, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 48px rgba(18, 26, 34, 0.18);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
}

.drawer-head .page-sub {
  margin: 0.2rem 0 0;
}

.drawer-body {
  padding: 1.2rem 1.4rem 2.4rem;
  overflow-y: auto;
}

.drawer-body h3 {
  margin: 1.5rem 0 0.6rem;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.drawer-body h3:first-child {
  margin-top: 0;
}

/* An answer nobody gave yet reads as a gap, not as a value */
.kv.is-blank strong {
  color: var(--muted);
  font-weight: 500;
}

/* Placeholder for a document slot still empty: same grid, no link */
.file-chip.is-blank {
  border-style: dashed;
  color: var(--muted);
  cursor: default;
}

.file-chip.is-blank:hover {
  border-color: var(--line);
  background: var(--bg);
}

/* Il codice fiscale si legge su richiesta: cifrato sul disco, disponibile a
   chi revisiona con un click, e ogni lettura resta registrata sul server. */
.reveal {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface, #fff);
  color: var(--muted);
  cursor: pointer;
  vertical-align: baseline;
}
.reveal:hover:not(:disabled) { color: var(--ink); border-color: var(--muted); }
.reveal:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.reveal:disabled { cursor: default; opacity: 0.6; }

/* Avvisi su Telegram */
.tg-alerts {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.7rem 0.85rem 0.85rem;
  margin: 0.2rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.tg-alerts legend {
  font-size: 0.78rem;
  color: var(--muted);
  padding: 0 0.35rem;
}
.tg-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}
.tg-toggle input { width: 1rem; height: 1rem; accent-color: var(--primary, #2b6a8f); }
.tg-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.2rem; }
.tg-chats:not(:empty) { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.1rem; }
.tg-chat {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.tg-chat:hover { border-color: var(--muted); }
.tg-chat span { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: 0.35rem; }
.form-msg.is-ok { color: var(--ok, #2d7d55); }
.form-msg.is-error { color: var(--danger, #b3392f); }

/* L'imbuto: dove si fermano i candidati, prima e dopo una modifica.
   Sta in cima a "In progress" perche e la stessa domanda vista dall'alto:
   la tabella sotto dice chi si e fermato, questa dice dove. */
.funnel {
  margin-bottom: 1.5rem;
}

.funnel h3 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
}

.funnel .card-desc {
  margin: 0 0 0.85rem;
}

.funnel-table th[scope='row'] {
  font-weight: 500;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

.funnel-table td {
  /* Le cifre incolonnate si confrontano a colpo d'occhio solo se hanno tutte
     la stessa larghezza. */
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.funnel-table td strong {
  font-size: 1.05rem;
}

.funnel-pct {
  margin-left: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.funnel-lost {
  margin-left: 0.5rem;
  color: var(--danger, #b3261e);
  font-size: 0.82rem;
  font-weight: 600;
}

/* Il gradino che ne perde di piu: e l'unica cosa da guardare per prima. */
.funnel-table td.funnel-worst {
  background: color-mix(in oklch, var(--danger, #b3261e) 8%, transparent);
  border-radius: 6px;
}

.funnel-sub {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Le destinazioni CAPI. Con due pixel la domanda non e piu "e configurato" ma
   "dove sta andando cosa", e questo elenco risponde a quella. */
.pixel-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.pixel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
}

.pixel-row > div:first-child {
  flex: 1;
  min-width: 0;
}

.pixel-row.is-default {
  border-color: var(--primary);
  background: #f2f8fa;
}

.pixel-row .linkish {
  color: var(--muted);
}

.pixel-row .linkish:hover {
  color: var(--danger);
}

.pixel-add {
  margin-bottom: 14px;
}

.pixel-add summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 10px;
}

/* Il token mostrato per intero: va a capo invece di allargare la scheda, e si
   seleziona con un doppio clic perche il gesto vero e "copialo e incollalo". */
.token-full {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-all;
  font-size: 11px;
  line-height: 1.4;
  background: #eef3f6;
  padding: 3px 6px;
  border-radius: 4px;
  user-select: all;
}

.pixel-row .pixel-show {
  font-size: 12px;
  text-decoration: underline;
}

/* Caricare nel pacchetto un documento arrivato altrove. */
.admin-upload {
  margin: 1.2rem 0 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fafbfc;
  display: grid;
  gap: 10px;
  max-width: 32rem;
}

.admin-upload .field {
  margin: 0;
}

.admin-upload input[type='file'] {
  font-size: 13px;
}

.admin-upload .btn {
  justify-self: start;
}
