/* ==========================================================================
   Glor Backoffice — Design System
   ========================================================================== */

:root {
  /* Brand */
  --glor-primary: #5B3FFF;
  --glor-primary-hover: #4A30E8;
  --glor-primary-soft: #EFEBFF;
  --glor-primary-softer: #F6F4FF;

  /* Neutrals */
  --ink-900: #0F0F1A;
  --ink-700: #2A2A3A;
  --ink-600: #4A4A5A;
  --ink-500: #6B6B7B;
  --ink-400: #9494A0;
  --ink-300: #C8C8D0;
  --ink-200: #E5E5EA;
  --ink-100: #F2F2F5;
  --ink-50:  #F8F8FA;
  --canvas:  #FFFFFF;

  /* Semantic */
  --green-500: #1FA363;
  --green-50:  #E8F6EF;
  --red-500:   #DC3545;
  --red-50:    #FBEAEC;
  --amber-500: #D58A1A;
  --amber-50:  #FBF1DF;
  --blue-500:  #1F6FE5;
  --blue-50:   #E6EFFC;

  /* Geometry */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 15, 26, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 15, 26, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 15, 26, 0.10);
  --shadow-xl: 0 24px 64px rgba(15, 15, 26, 0.16);

  /* Sidebar */
  --sidebar-w: 240px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-900);
  background: var(--ink-50);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body { overflow: hidden; }

#root { height: 100vh; width: 100vw; overflow: hidden; }

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ==========================================================================
   App shell
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  background: var(--canvas);
}

/* ----- Sidebar ----- */
.sidebar {
  background: var(--canvas);
  border-right: 1px solid var(--ink-200);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  height: 100vh;
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 28px;
}
.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--glor-primary);
  display: grid;
  place-items: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.04em;
}
.sidebar-logo-divider {
  width: 1px;
  height: 18px;
  background: var(--ink-300);
}
.sidebar-logo-text {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-700);
  width: 100%;
  text-align: left;
  transition: background 120ms ease;
}
.nav-item:hover { background: var(--ink-100); }
.nav-item.active {
  background: var(--glor-primary);
  color: white;
}
.nav-item .nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--glor-primary);
  box-shadow: 0 0 0 3px var(--glor-primary-softer);
}

.nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--red-500);
  color: white;
  font-size: 11px;
  font-weight: 700;
  font-feature-settings: 'tnum';
}
.nav-item.active .nav-badge { background: white; color: var(--glor-primary); }

.topbar-notif { position: relative; }
.topbar-bell {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--ink-200);
  background: white;
  color: var(--ink-700);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 120ms;
}
.topbar-bell:hover { background: var(--ink-50); color: var(--ink-900); }
.topbar-bell-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red-500);
  color: white;
  font-size: 10.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid white;
  font-feature-settings: 'tnum';
}

.notif-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(15, 18, 30, 0.12);
  z-index: 100;
  overflow: hidden;
  animation: popIn 140ms ease-out;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.notif-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ink-100);
}
.notif-mark {
  background: none;
  border: none;
  color: var(--glor-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.notif-mark:hover { text-decoration: underline; }
.notif-list { max-height: 400px; overflow-y: auto; }
.notif-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--ink-500);
}
.notif-empty svg { color: var(--green-500); }
.notif-item {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  background: white;
  border: none;
  border-bottom: 1px solid var(--ink-100);
  text-align: left;
  cursor: pointer;
  transition: background 100ms;
}
.notif-item:last-of-type { border-bottom: none; }
.notif-item:hover { background: var(--ink-50); }
.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
}
.notif-dot.amber { background: var(--amber-500); }
.notif-dot.blue  { background: var(--blue-500); }
.notif-dot.green { background: var(--green-500); }
.notif-dot.gray  { background: var(--ink-300); }
.notif-dot.red   { background: var(--red-500); }

.chip-active {
  background: var(--glor-primary) !important;
  color: white !important;
  border-color: var(--glor-primary) !important;
}
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--ink-200);
  background: white;
  color: var(--ink-700);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 100ms;
}
.chip:hover { background: var(--ink-50); }

.row-high { background: rgba(220, 38, 38, 0.04); }
.row-high:hover { background: rgba(220, 38, 38, 0.08) !important; }

/* ==========================================================================
   Currency (€ / Token)
   ========================================================================== */
.money-sub {
  font-size: 12.5px;
  color: var(--ink-500);
  font-weight: 500;
  margin-top: 2px;
}
.money-sub.lg { font-size: 13.5px; }

.currency-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--ink-200);
  background: white;
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 120ms;
}
.currency-pill:hover { background: var(--ink-50); border-color: var(--ink-300); }
.currency-pill.token {
  background: var(--glor-primary-softer);
  border-color: var(--glor-primary-soft);
  color: var(--glor-primary);
}
.currency-pill-rate {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.75;
  padding-left: 7px;
  margin-left: 1px;
  border-left: 1px solid currentColor;
}

.cur-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cur-choice-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  text-align: left;
  padding: 16px;
  border: 1.5px solid var(--ink-200);
  border-radius: var(--radius-md);
  background: white;
  cursor: pointer;
  transition: all 120ms;
}
.cur-choice-card:hover { border-color: var(--ink-300); }
.cur-choice-card.on { border-color: var(--glor-primary); background: var(--glor-primary-softer); }
.cur-choice-glyph {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--ink-100);
  color: var(--ink-700);
  font-size: 22px; font-weight: 700;
  margin-bottom: 4px;
}
.cur-choice-card.on .cur-choice-glyph { background: var(--glor-primary); color: white; }
.cur-choice-title { font-weight: 700; font-size: 15px; }
.cur-choice-desc { font-size: 12px; color: var(--ink-500); line-height: 1.4; }

.cur-preview {
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cur-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.wizard-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
.wizard-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--ink-100);
  color: var(--ink-500);
  flex-shrink: 0;
}
.wizard-dot.current { background: var(--glor-primary); color: white; }
.wizard-dot.done { background: var(--glor-primary-soft); color: var(--glor-primary); }
.wizard-line {
  width: 48px;
  height: 2px;
  background: var(--ink-200);
  border-radius: 2px;
}
.wizard-line.on { background: var(--glor-primary); }

/* Dashboard — ricariche per operatore */
.recharge-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.recharge-cell {
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.recharge-cell .tabular { font-size: 16px; margin: 2px 0; }

.cash-fund-box {
  background: var(--glor-primary-softer);
  border: 1px solid var(--glor-primary-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.cash-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.cash-check input { display: none; }
.cash-check-box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--ink-300);
  display: grid;
  place-items: center;
  color: white;
  background: white;
  transition: all 120ms;
  flex-shrink: 0;
}
.cash-check.on .cash-check-box { background: var(--green-500); border-color: var(--green-500); }
.cash-check input:disabled + .cash-check-box { opacity: 0.5; }

.tx-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: white;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 100ms;
  text-align: left;
}
.tx-row:hover { border-color: var(--glor-primary-soft); background: var(--ink-50); }
.tx-row-selected { border-color: var(--glor-primary); background: var(--glor-primary-softer); }

.radio {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--ink-300);
  background: white;
  flex-shrink: 0;
  position: relative;
}
.radio-on { border-color: var(--glor-primary); }
.radio-on::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--glor-primary);
}
.notif-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  background: var(--ink-50);
  border: none;
  border-top: 1px solid var(--ink-100);
  color: var(--glor-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.notif-foot:hover { background: var(--glor-primary-softer); }

.nav-divider {
  height: 1px;
  background: var(--ink-200);
  margin: 8px 8px;
}

.sidebar-footer {
  border-top: 1px solid var(--ink-200);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sidebar-event-pill {
  background: var(--ink-100);
  border: 1px solid var(--ink-200);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 120ms;
}
.sidebar-event-pill:hover { border-color: var(--ink-300); background: var(--canvas); }
.sidebar-event-pill .ev-label { font-size: 11px; color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.sidebar-event-pill .ev-name { font-weight: 600; font-size: 13px; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.sidebar-event-pill .ev-status { font-size: 11px; color: var(--ink-500); margin-top: 2px; }

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--glor-primary);
  font-weight: 500;
  padding: 4px 12px;
  font-size: 13px;
}
.sidebar-logout:hover { text-decoration: underline; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px;
}
.sidebar-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink-900);
  color: white;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
}
.sidebar-user-email { font-size: 12px; color: var(--ink-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ----- Main content ----- */
.main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--canvas);
}

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--ink-200);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  flex-shrink: 0;
  background: var(--canvas);
}
.breadcrumb {
  font-size: 13px;
  color: var(--ink-500);
  display: flex;
  align-items: center;
  gap: 8px;
}
.breadcrumb .crumb-current { color: var(--ink-900); font-weight: 500; }
.breadcrumb .crumb-sep { color: var(--ink-300); }

.topbar-spacer { flex: 1; }

.topbar-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
}
.topbar-banner.amber { background: var(--amber-50); color: var(--amber-500); }
.topbar-banner.green { background: var(--green-50); color: var(--green-500); }
.topbar-banner .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.page {
  flex: 1;
  overflow-y: auto;
  padding: 40px 48px 64px;
}
.page-inner { max-width: 1280px; margin: 0 auto; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
}
.page-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
}
.page-subtitle {
  font-size: 14px;
  color: var(--ink-500);
  margin-top: 6px;
}

.page-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13.5px;
  transition: all 120ms;
  white-space: nowrap;
}
.btn-primary {
  background: var(--glor-primary);
  color: white;
}
.btn-primary:hover { background: var(--glor-primary-hover); }
.btn-primary:disabled { background: var(--ink-200); color: var(--ink-400); cursor: not-allowed; }

.btn-secondary {
  background: var(--canvas);
  color: var(--ink-900);
  border: 1px solid var(--ink-200);
}
.btn-secondary:not(:disabled):hover { background: var(--ink-50); border-color: var(--ink-300); }
.btn-secondary:disabled { background: var(--ink-50); color: var(--ink-400); border-color: var(--ink-200); cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--glor-primary);
  font-weight: 500;
}
.btn-ghost:not(:disabled):hover { background: var(--glor-primary-soft); }
.btn-ghost:disabled { color: var(--ink-400); cursor: not-allowed; }

.btn-danger {
  background: var(--red-500);
  color: white;
}
.btn-danger:hover { background: #C12838; }

.btn-link {
  color: var(--glor-primary);
  text-decoration: underline;
  font-weight: 500;
  background: none;
  padding: 0;
  height: auto;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-500);
  display: grid;
  place-items: center;
}
.btn-icon:not(:disabled):hover { background: var(--ink-100); color: var(--ink-900); }
.btn-icon:disabled { color: var(--ink-300); cursor: not-allowed; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }

/* ==========================================================================
   Forms
   ========================================================================== */
.input, .select, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  color: var(--ink-900);
  font-size: 14px;
  transition: border-color 120ms, box-shadow 120ms;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--glor-primary);
  box-shadow: 0 0 0 3px var(--glor-primary-soft);
}
.input:disabled, .select:disabled { background: var(--ink-100); color: var(--ink-400); cursor: not-allowed; }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-700);
}
.field-label .req { color: var(--red-500); }
.field-hint { font-size: 12px; color: var(--ink-500); }
.field-error { font-size: 12px; color: var(--red-500); display: flex; align-items: center; gap: 4px; }

.search-input-wrap {
  position: relative;
  width: 320px;
}
.search-input-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-400);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--ink-200);
  border-radius: 999px;
  background: var(--canvas);
  font-size: 13.5px;
}
.search-input:focus { outline: none; border-color: var(--glor-primary); }
.search-input::placeholder { color: var(--ink-400); }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--canvas);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card-pad-sm { padding: 16px; }

.kpi-section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-500);
  margin-bottom: 12px;
}

.kpi-card {
  background: var(--canvas);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 120ms;
  position: relative;
}
.kpi-card:hover { border-color: var(--ink-300); }
.kpi-label {
  font-size: 12.5px;
  color: var(--ink-500);
  font-weight: 500;
}
.kpi-info {
  position: absolute;
  top: 28px;
  right: 24px;
  display: inline-flex;
  padding: 2px;
  color: var(--ink-400);
  cursor: help;
}
.kpi-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.kpi-delta {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}
.kpi-delta.up { color: var(--green-500); }
.kpi-delta.down { color: var(--red-500); }
.kpi-delta.flat { color: var(--ink-500); }
.kpi-icon-pill {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--glor-primary-soft);
  color: var(--glor-primary);
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
  background: var(--canvas);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink-700);
  padding: 14px 20px;
  border-bottom: 1px solid var(--ink-200);
  background: var(--canvas);
  white-space: nowrap;
}
.table tbody td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ink-100);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 80ms; }
.table tbody tr:hover { background: var(--ink-50); }
.table .col-actions { text-align: right; white-space: nowrap; }
.table .row-arrow {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--glor-primary-soft);
  color: var(--glor-primary);
  transition: all 120ms;
}
.table .row-arrow:hover { background: var(--glor-primary); color: white; }

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--ink-200);
}

/* ==========================================================================
   Status pills
   ========================================================================== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill svg { width: 14px; height: 14px; }
.pill-green  { color: var(--green-500); }
.pill-red    { color: var(--red-500); }
.pill-amber  { color: var(--amber-500); }
.pill-blue   { color: var(--blue-500); }
.pill-gray   { color: var(--ink-500); }

.pill-bg-green  { background: var(--green-50); color: var(--green-500); }
.pill-bg-red    { background: var(--red-50); color: var(--red-500); }
.pill-bg-amber  { background: var(--amber-50); color: var(--amber-500); }
.pill-bg-blue   { background: var(--blue-50); color: var(--blue-500); }
.pill-bg-gray   { background: var(--ink-100); color: var(--ink-700); }
.pill-bg-violet { background: var(--glor-primary-soft); color: var(--glor-primary); }

.pos-split { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.pos-split .pill { font-size: 11px; padding: 3px 8px; }
.pos-split .pill-count { opacity: .7; }

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--ink-200);
  margin-bottom: 24px;
  align-items: center;
}
.tab {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--ink-700); }
.tab.active {
  color: var(--ink-900);
  border-bottom-color: var(--glor-primary);
  font-weight: 600;
}
.tab .count {
  font-size: 11px;
  background: var(--ink-100);
  color: var(--ink-600);
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 500;
}
.tab.active .count { background: var(--glor-primary-soft); color: var(--glor-primary); }
.tab .tab-edit-btn {
  margin-left: 4px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--ink-400);
  opacity: 0;
  transition: opacity 120ms;
}
.tab:hover .tab-edit-btn { opacity: 1; }
.tab .tab-edit-btn:hover { background: var(--ink-100); color: var(--ink-700); }

.chip-group {
  display: inline-flex;
  align-items: center;
  background: var(--ink-100);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.chip {
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-500);
  border-radius: 999px;
  white-space: nowrap;
}
.chip:hover { color: var(--ink-700); }
.chip.active {
  background: var(--canvas);
  color: var(--ink-900);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Modal
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 26, 0.36);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: fadeIn 160ms ease-out;
  padding: 32px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.modal {
  background: var(--canvas);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 64px);
  overflow: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 200ms ease-out;
}
.modal.modal-lg { max-width: 720px; }
/* xl: modali con tabelle a molte colonne (es. liste transazioni) che a 720px
   verrebbero compresse o costrette allo scroll orizzontale. Resta responsive:
   .modal ha width:100% e il backdrop ha padding 32px, quindi su viewport più
   strette si riduce a 100vw - 64px. */
.modal.modal-xl { max-width: 960px; }
.modal-header {
  padding: 24px 28px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.modal-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}
.modal-subtitle { color: var(--ink-500); font-size: 13px; margin-top: 4px; }
.modal-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--ink-500);
}
.modal-close:hover { background: var(--ink-100); color: var(--ink-900); }
.modal-body { padding: 20px 28px; display: flex; flex-direction: column; gap: 16px; }
/* Le tabelle nei modali possono superare la larghezza (720px lg): consenti lo scroll
   orizzontale invece di venire tagliate dall'overflow:hidden globale di .table-wrap. */
.modal-body .table-wrap { overflow-x: auto; overflow-y: hidden; }
.modal-body .table { min-width: 680px; }
.detail-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 20px; align-items: baseline; }
.modal-footer {
  padding: 20px 28px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--ink-100);
  margin-top: 4px;
}

.confirm-banner {
  background: var(--amber-50);
  color: var(--amber-500);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

/* ==========================================================================
   Toast
   ========================================================================== */
.toast-region {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--ink-900);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  animation: slideUp 180ms ease-out;
  pointer-events: all;
}
.toast.toast-success .toast-icon { color: #4ADE80; }
.toast.toast-error .toast-icon { color: #FCA5A5; }

/* ==========================================================================
   Empty state
   ========================================================================== */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  background: var(--canvas);
  border: 1px dashed var(--ink-200);
  border-radius: var(--radius-lg);
}
.empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--ink-100);
  color: var(--ink-500);
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
}
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.empty-subtitle { color: var(--ink-500); font-size: 13.5px; max-width: 360px; margin: 0 auto 16px; }

/* ==========================================================================
   Login & Event picker
   ========================================================================== */
.auth-page {
  height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--canvas);
}
.auth-left {
  background: var(--ink-900);
  color: white;
  padding: 56px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}
.auth-left .brand-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 2;
}
.auth-left .brand-mark .mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--glor-primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.04em;
}
.auth-left .brand-mark .name {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.auth-left h1 {
  font-size: 48px;
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 700;
  margin: auto 0 12px;
  position: relative;
  z-index: 2;
}
.auth-left .lead {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.7);
  max-width: 440px;
  position: relative;
  z-index: 2;
  margin-bottom: 8px;
}
.auth-left .meta {
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.45);
  position: relative;
  z-index: 2;
}
.auth-left .glow {
  position: absolute;
  bottom: -200px;
  right: -200px;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 63, 255, 0.5) 0%, transparent 60%);
  filter: blur(40px);
}

.auth-right {
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
.auth-form-wrap {
  width: 100%;
  max-width: 380px;
}
.auth-form-wrap h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.auth-form-wrap .sub {
  color: var(--ink-500);
  font-size: 14px;
  margin-bottom: 32px;
}
.auth-error {
  background: var(--red-50);
  color: var(--red-500);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.auth-blocked {
  background: var(--amber-50);
  color: var(--amber-500);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form .btn { height: 44px; }
.auth-footer {
  margin-top: 32px;
  font-size: 12px;
  color: var(--ink-400);
  text-align: center;
}

.event-picker-page {
  min-height: 100vh;
  background: var(--ink-50);
  padding: 56px 32px;
}
.event-picker-inner { max-width: 1100px; margin: 0 auto; }
.event-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 36px;
}
.event-picker-header .title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.event-picker-header .sub {
  color: var(--ink-500);
  font-size: 14px;
}
.event-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.event-card {
  background: var(--canvas);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: left;
  width: 100%;
  transition: all 160ms;
  display: flex;
  flex-direction: column;
  gap: 16px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.event-card:hover {
  border-color: var(--glor-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.event-card-img {
  width: 100%;
  aspect-ratio: 16 / 7;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--ink-200) 0%, var(--ink-100) 100%);
  position: relative;
  overflow: hidden;
}
.event-card-img.live::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, transparent 0, transparent 12px, rgba(91, 63, 255, 0.08) 12px, rgba(91, 63, 255, 0.08) 14px);
}
.event-card-name {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.event-card-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--ink-500);
}
.event-card-meta .sep { color: var(--ink-300); }
.event-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--ink-100);
}
.event-card-stat .label { font-size: 11px; color: var(--ink-500); text-transform: uppercase; letter-spacing: 0.04em; }
.event-card-stat .value { font-size: 18px; font-weight: 600; margin-top: 2px; }

/* ==========================================================================
   Misc
   ========================================================================== */
.divider { height: 1px; background: var(--ink-200); }

.section-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-title .count-badge { font-size: 12px; color: var(--ink-500); font-weight: 500; }

.muted { color: var(--ink-500); }
.tabular { font-variant-numeric: tabular-nums; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1100px) {
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.flex-row { display: flex; gap: 12px; align-items: center; }

/* dot indicator for status */
.dot-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-indicator.live { background: var(--green-500); box-shadow: 0 0 0 3px var(--green-50); animation: pulse 2s ease-in-out infinite; }
.dot-indicator.draft { background: var(--ink-400); }
.dot-indicator.staging { background: var(--amber-500); }
.dot-indicator.ended { background: var(--ink-300); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--green-50); }
  50% { box-shadow: 0 0 0 6px rgba(31, 163, 99, 0.15); }
}

/* progress bar tiny */
.bar {
  height: 6px;
  background: var(--ink-100);
  border-radius: 999px;
  overflow: hidden;
}
.bar > .fill { height: 100%; background: var(--glor-primary); border-radius: 999px; }

/* dropdown menu */
.menu {
  position: absolute;
  background: var(--canvas);
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 180px;
  z-index: 50;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
  text-align: left;
  color: var(--ink-700);
}
.menu-item:hover { background: var(--ink-100); color: var(--ink-900); }
.menu-item.danger { color: var(--red-500); }
.menu-item.danger:hover { background: var(--red-50); }
.menu-divider { height: 1px; background: var(--ink-100); margin: 4px 0; }

.upload-zone {
  border: 1.5px dashed var(--ink-300);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  background: var(--ink-50);
  transition: all 120ms;
}
.upload-zone.drag { border-color: var(--glor-primary); background: var(--glor-primary-soft); }
.upload-zone .upload-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--canvas);
  border: 1px solid var(--ink-200);
  color: var(--ink-500);
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
}

.import-result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12.5px;
}
.import-result-row.ok { background: var(--green-50); color: var(--green-500); }
.import-result-row.err { background: var(--red-50); color: var(--red-500); }

/* Pagination dots */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 0 8px;
}
.pagination .nav-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-700);
}
.pagination .nav-btn:hover { background: var(--ink-100); }
.pagination .nav-btn:disabled { color: var(--ink-300); cursor: not-allowed; }
.pagination .dots { display: flex; gap: 8px; align-items: center; }
.pagination .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-200);
}
.pagination .dot.active { background: var(--glor-primary); width: 18px; border-radius: 999px; }

/* lock body when modal open */
body.modal-open { overflow: hidden; }

/* ==========================================================================
   Boot loader — animated logo (WASM startup / authorizing)
   ========================================================================== */
.boot-loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--ink-50);
  z-index: 9999;
}
.boot-logo {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--glor-primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.04em;
  box-shadow: 0 12px 32px rgba(91, 63, 255, 0.35);
  animation: bootPulse 1.4s ease-in-out infinite;
}
@keyframes bootPulse {
  0%, 100% {
    transform: scale(1) translateY(0);
    box-shadow: 0 12px 32px rgba(91, 63, 255, 0.3);
  }
  50% {
    transform: scale(1.12) translateY(-4px);
    box-shadow: 0 20px 48px rgba(91, 63, 255, 0.5);
  }
}
