/* Flyerbox Mappe - stile comune */
:root {
  --fb-orange: #ff4d01;
  --fb-orange-dark: #d84100;
  --fb-orange-soft: #fff1ea;
  --fb-peach: #ffc56e;
  --fb-dark: #232323;
  --fb-dark-2: #2f2f2f;
  --fb-grey: #5a5a5a;
  --fb-grey-2: #8a8a8a;
  --fb-line: #e6e6e6;
  --fb-bg: #f4f4f2;
  --fb-white: #ffffff;
  --fb-blue: #1e3a8a;
  --fb-green: #16a34a;
  --fb-red: #dc2626;
  --fb-radius: 12px;
  --fb-shadow: 0 6px 24px rgba(0, 0, 0, .14);
  --fb-shadow-sm: 0 2px 8px rgba(0, 0, 0, .10);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; font-family: var(--font); color: var(--fb-dark); background: var(--fb-bg); font-size: 14px; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--fb-orange-dark); }
.hidden { display: none !important; }
.muted { color: var(--fb-grey-2); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* ---- bottoni ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; border-radius: 8px;
  padding: 7px 12px; background: var(--fb-white); color: var(--fb-dark); cursor: pointer; line-height: 1.2;
  font-weight: 600; transition: background .12s, box-shadow .12s, transform .05s; white-space: nowrap; user-select: none;
}
.btn:hover { background: #f5f5f5; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--fb-orange); color: #fff; }
.btn.primary:hover { background: var(--fb-orange-dark); }
.btn.dark { background: var(--fb-dark-2); color: #fff; }
.btn.dark:hover { background: #000; }
.btn.ghost { background: transparent; border-color: var(--fb-line); }
.btn.ghost:hover { background: rgba(0,0,0,.04); }
.btn.danger { color: var(--fb-red); border-color: #f3caca; }
.btn.danger:hover { background: #fdeeee; }
.btn.sm { padding: 4px 8px; font-size: 12px; border-radius: 6px; }
.btn.icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }
.btn.active { background: var(--fb-orange-soft); border-color: var(--fb-orange); color: var(--fb-orange-dark); }
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- form ---- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 700; color: var(--fb-grey); text-transform: uppercase; letter-spacing: .03em; }
.field input[type=text], .field input[type=password], .field input[type=email], .field input[type=number], .field input[type=date], .field select, .field textarea {
  border: 1px solid var(--fb-line); border-radius: 8px; padding: 9px 10px; background: #fff; outline: none; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--fb-orange); box-shadow: 0 0 0 3px rgba(255,77,1,.15); }
.field .hint { font-size: 12px; color: var(--fb-grey-2); }
.check { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.check:hover { background: #f7f7f7; }
.check input { width: 16px; height: 16px; accent-color: var(--fb-orange); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* ---- badge / chip ---- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eee; color: var(--fb-grey); }
.badge.on { background: #e7f7ec; color: var(--fb-green); }
.badge.off { background: #f3f3f3; color: #aaa; text-decoration: line-through; }
.badge.orange { background: var(--fb-orange-soft); color: var(--fb-orange-dark); }
.badge.red { background: #fdeeee; color: var(--fb-red); }
.badge.blue { background: #e8edfb; color: var(--fb-blue); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: #fff; box-shadow: var(--fb-shadow-sm); font-size: 12px; font-weight: 600; }

/* ---- header ---- */
.topbar {
  height: 56px; background: var(--fb-dark); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.3); position: relative; z-index: 1200;
}
.topbar .logo { height: 46px; display: block; margin: 0 -6px; }
.topbar .title { font-weight: 800; letter-spacing: .02em; font-size: 15px; color: #fff; opacity: .9; border-left: 1px solid rgba(255,255,255,.25); padding-left: 12px; }
.topbar .spacer { flex: 0 0 4px; }
.topbar .btn { background: rgba(255,255,255,.08); color: #fff; border-color: transparent; }
.topbar .btn:hover { background: rgba(255,255,255,.18); }
.topbar .btn.active { background: var(--fb-orange); color: #fff; }
.topbar .btn.primary { background: var(--fb-orange); }
.topbar .btn.primary:hover { background: var(--fb-orange-dark); }

/* ---- modale ---- */
.modal-back { position: fixed; inset: 0; background: rgba(20,20,20,.45); display: flex; align-items: center; justify-content: center; z-index: 3000; padding: 16px; }
.modal { background: #fff; border-radius: 14px; box-shadow: var(--fb-shadow); width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; animation: pop .15s ease-out; }
.modal.wide { max-width: 820px; }
.modal header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--fb-line); }
.modal header h2 { margin: 0; font-size: 16px; flex: 1; }
.modal .body { padding: 16px 18px; overflow: auto; }
.modal footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--fb-line); background: #fafafa; border-radius: 0 0 14px 14px; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.modal .close { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--fb-grey-2); line-height: 1; }

/* ---- toast ---- */
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 4000; pointer-events: none; }
.toast { background: var(--fb-dark); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--fb-shadow); font-weight: 600; animation: pop .15s; max-width: 90vw; }
.toast.err { background: var(--fb-red); }
.toast.ok { background: var(--fb-green); }

/* ---- tabelle ---- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--fb-grey); padding: 8px 8px; border-bottom: 2px solid var(--fb-line); background: #fafafa; position: sticky; top: 0; }
table.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--fb-line); vertical-align: middle; }
table.tbl tr:hover td { background: #fff8f4; }
table.tbl td.actions { white-space: nowrap; text-align: right; }
table.tbl td.actions .btn { margin-left: 4px; }

/* ---- login ---- */
.login-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 10% 0%, #3a3a3a 0%, var(--fb-dark) 60%); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; box-shadow: var(--fb-shadow); width: 100%; max-width: 400px; padding: 28px; }
.login-card .logo { height: 56px; display: block; margin: 0 auto 8px; }
.login-card h1 { margin: 4px 0 18px; font-size: 18px; text-align: center; color: var(--fb-grey); font-weight: 600; }
.login-card .err { background: #fdeeee; color: var(--fb-red); padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; font-weight: 600; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }
.login-foot { text-align: center; color: rgba(255,255,255,.6); font-size: 12px; margin-top: 14px; }

/* etichette delle checkbox dentro i .field: testo normale, non maiuscolo */
.field label.check, .field .check { text-transform: none; font-size: 13px; font-weight: 500; color: var(--fb-dark); letter-spacing: 0; }
.preset .btn, .perm-grid + .preset .btn { border-color: var(--fb-line); background: #fafafa; }
