/* =========================================================
   Black Empire — dashboard (usa i colori e i bottoni di style.css)
   ========================================================= */
body.admin { background: #f3efe9; }

/* ---------- Accesso ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login[hidden] { display: none; }
.login__card {
  width: min(420px, 100%); background: var(--surface); border-radius: 24px; box-shadow: var(--shadow);
  padding: clamp(1.75rem, 4vw, 2.5rem); display: grid; gap: 1.1rem;
}
.login__brand span { display: block; font-weight: 650; letter-spacing: .26em; color: var(--ink); font-size: .9375rem; }
.login__brand small { color: var(--porpora); font-weight: 600; font-size: .8125rem; }
.login__title { font-size: 1.625rem; font-weight: 450; letter-spacing: -0.02em; color: var(--ink); }
.login .link { justify-self: center; }
.login .link svg { width: 14px; height: 14px; }

/* ---------- Struttura ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.app[hidden] { display: none; }
.side {
  position: sticky; top: 0; height: 100vh; background: var(--surface);
  border-right: 1px solid var(--line); padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: 2rem;
}
.side__brand { padding: 0 .75rem; }
.side__brand span { display: block; font-weight: 650; letter-spacing: .24em; color: var(--ink); font-size: .9375rem; }
.side__brand small { color: var(--porpora); font-weight: 600; font-size: .8125rem; }
.side__nav, .side__foot { display: grid; gap: .25rem; }
.side__foot { margin-top: auto; }
.side__link {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  min-height: 44px; padding: 0 .75rem; border-radius: 12px;
  font-size: .9688rem; font-weight: 550; color: var(--text); text-align: left;
  transition: background .25s, color .25s;
}
.side__link svg { width: 20px; height: 20px; color: var(--muted); }
.side__link:hover { background: var(--bg); color: var(--ink); }
.side__link[aria-current='page'] { background: var(--porpora-soft); color: var(--porpora); }
.side__link[aria-current='page'] svg { color: var(--porpora); }
.side__count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--porpora); color: #fff; font-size: .75rem; font-weight: 650; display: grid; place-items: center; }
.side__count[hidden] { display: none; }

.main { padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 3vw, 2.5rem) 4rem; display: grid; gap: 1.25rem; align-content: start; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 1rem; }
.topbar > div { flex: 1; }
.topbar__title { font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); font-weight: 450; letter-spacing: -0.02em; color: var(--ink); line-height: 1.15; }
.topbar__date { color: var(--muted); font-size: .9375rem; }
.topbar__menu { display: none; width: 44px; height: 44px; border-radius: 12px; background: var(--surface); place-items: center; }
.topbar__menu svg { width: 22px; height: 22px; }

.demo {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  background: #fbf3df; border: 1px solid #f0e0b8; color: #5e4a1c; border-radius: 16px; padding: .85rem 1rem .85rem 1.15rem; font-size: .9063rem;
}
.demo strong { color: #3f3110; }
.demo p { max-width: 62rem; }
.demo__actions { display: flex; gap: .5rem; }
.demo .btn--ghost { background: #fff; }

.view { display: grid; gap: 1.25rem; }
.view[hidden] { display: none; }
.card { background: var(--surface); border-radius: 20px; padding: 1.35rem 1.5rem; min-width: 0; }
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card__head h2 { font-size: 1.0625rem; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.card .link { font-size: .875rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }

/* ---------- Riquadri numerici ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.tiles--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile { background: var(--surface); border-radius: 18px; padding: 1.1rem 1.25rem; display: grid; gap: .2rem; }
.tile__label { font-size: .875rem; color: var(--muted); font-weight: 500; }
.tile__value { font-size: clamp(1.75rem, 1.4rem + 1vw, 2.25rem); font-weight: 600; color: var(--ink); letter-spacing: -0.02em; line-height: 1.15; }
.tile__foot { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; font-size: .8125rem; color: var(--muted); min-height: 1.2em; }
.delta { font-weight: 650; padding: 1px 6px; border-radius: 6px; background: var(--bg); color: var(--text); }
.delta--up { background: #e5f3ea; color: #1f6b3a; }
.delta--up::before { content: '▲ '; font-size: .65em; }
.delta--down { background: #f6e6e4; color: #8f2a2a; }
.delta--down::before { content: '▼ '; font-size: .65em; }

/* ---------- Agenda ---------- */
.agenda { display: grid; }
.ag { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .8rem 0; border-top: 1px solid var(--line); }
.ag:first-child { border-top: 0; padding-top: 0; }
.ag__time { font-weight: 650; color: var(--ink); font-size: .9063rem; font-variant-numeric: tabular-nums; line-height: 1.3; }
.ag__main strong { display: block; color: var(--ink); font-weight: 600; font-size: .9688rem; }
.ag__main small { display: block; color: var(--muted); font-size: .8438rem; }
[data-pending] .ag { grid-template-columns: 84px minmax(0, 1fr) auto; }
.empty { color: var(--muted); padding: 1.25rem 0; font-size: .9375rem; }
.card--flush .empty { padding: 2rem 1.5rem; }

/* ---------- Stati e azioni ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; font-size: .78rem; font-weight: 650; padding: .3rem .6rem; border-radius: 99px; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--confermata { background: #e5f3ea; color: #1f6b3a; }
.badge--in-attesa { background: #fbf1dc; color: #7a4f00; }
.badge--annullata { background: #f1e7e6; color: #8f2a2a; }
.acts { display: flex; gap: .3rem; justify-content: flex-end; }
.act {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-width: 34px; height: 34px; padding: 0 .5rem; border-radius: 10px;
  color: var(--text); border: 1px solid var(--line); background: var(--surface); font-size: .8125rem; font-weight: 600;
  transition: background .2s, color .2s, border-color .2s;
}
.act svg { width: 16px; height: 16px; }
.act:hover { border-color: var(--porpora); color: var(--porpora); }
.act--ok { background: var(--porpora); border-color: var(--porpora); color: #fff; padding: 0 .7rem; }
.act--ok:hover { background: var(--porpora-dark); color: #fff; }

/* ---------- Tabella prenotazioni ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.toolbar--between { justify-content: space-between; }
.search { flex: 1 1 260px; display: flex; align-items: center; gap: .5rem; background: var(--surface); border-radius: 12px; padding: 0 .9rem; min-height: 44px; border: 1px solid var(--line); }
.search svg { width: 18px; height: 18px; color: var(--muted); }
.search input { flex: 1; border: 0; background: none; font: inherit; color: var(--ink); min-height: 42px; outline: none; }
.toolbar select, .modal select {
  min-height: 44px; padding: 0 2.25rem 0 .9rem; border-radius: 12px; border: 1px solid var(--line); background-color: var(--surface);
  font: inherit; font-size: .9375rem; color: var(--ink); appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%236b6365' stroke-width='1.8' stroke-linecap='round' d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center; background-size: 16px;
}
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th { text-align: left; font-size: .8125rem; font-weight: 600; color: var(--muted); padding: .9rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fbf9f6; }
.table td { padding: .9rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--text); }
.table td strong { color: var(--ink); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfaf8; }
.table .is-cancelled td { opacity: .55; }
.table .note { display: inline-block; margin-top: .25rem; font-size: .8125rem; color: var(--muted); font-style: italic; }
.table--compact td, .table--compact th { padding: .55rem .75rem; font-variant-numeric: tabular-nums; }
.demo-tag { font-size: .7rem; font-weight: 650; color: #7a4f00; background: #fbf1dc; border-radius: 6px; padding: 1px 5px; }

/* ---------- Grafici ---------- */
.seg { display: inline-flex; background: var(--surface); border-radius: 12px; padding: 4px; gap: 2px; border: 1px solid var(--line); }
.seg button { min-height: 36px; padding: 0 .9rem; border-radius: 9px; font-size: .875rem; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed='true'] { background: var(--porpora); color: #fff; }
.chart { width: 100%; overflow: hidden; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: #ece6e0; stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--porpora); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit.is-hover { fill: rgba(107, 29, 69, .06); }
.tooltip {
  position: fixed; z-index: 400; pointer-events: none;
  background: var(--ink); color: #fff; border-radius: 10px; padding: .5rem .7rem; font-size: .8125rem; line-height: 1.4;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .4);
}
.tooltip strong { font-size: .9375rem; }
.tooltip span { color: #cfc6c2; }
.tooltip[hidden] { display: none; }

.bars { display: grid; gap: .75rem; }
.bars li { display: grid; grid-template-columns: minmax(90px, 140px) minmax(0, 1fr) auto; gap: .75rem; align-items: center; font-size: .9063rem; }
.bars__label { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars__track { height: 8px; border-radius: 99px; background: #f1ebe5; overflow: hidden; }
.bars__fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--porpora); }
.bars__val { font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; min-width: 70px; }
.bars__val small { margin-left: .4rem; font-weight: 500; color: var(--muted); }
.bars__empty { color: var(--muted); font-size: .9375rem; display: block !important; }

/* ---------- Modale ---------- */
.modal { border: 0; padding: 0; border-radius: 24px; width: min(620px, calc(100% - 2rem)); background: var(--surface); box-shadow: var(--shadow); color: var(--text); }
.modal::backdrop { background: rgba(29, 26, 28, .45); }
.modal__form { padding: 1.5rem; display: grid; gap: 1.25rem; }
.modal__head { display: flex; align-items: center; justify-content: space-between; }
.modal__head h2 { font-size: 1.375rem; font-weight: 500; color: var(--ink); letter-spacing: -0.015em; }
.modal__close { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); }
.modal__close svg { width: 18px; height: 18px; }
.modal select { width: 100%; min-height: 52px; border-radius: 14px; border-width: 1.5px; background-color: var(--bg); }
.modal__foot { display: flex; justify-content: flex-end; gap: .6rem; }

/* ---------- Avviso ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 500; transform: translate(-50%, 160%);
  background: var(--ink); color: #fff; padding: .8rem 1.2rem; border-radius: 12px; font-weight: 550; font-size: .9375rem;
  transition: transform .45s var(--ease); box-shadow: 0 16px 40px -16px rgba(0, 0, 0, .5);
}
.toast.is-on { transform: translate(-50%, 0); }

/* ---------- Mobile ---------- */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles--6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 300; transform: translateX(-100%);
    transition: transform .4s var(--ease); box-shadow: 20px 0 60px -30px rgba(0, 0, 0, .4);
  }
  .side-open .side { transform: none; }
  .topbar__menu { display: grid; }
  .topbar .btn span, .topbar .btn { white-space: nowrap; }
  .grid-2 { grid-template-columns: 1fr; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
  .table td { border: 0; padding: .2rem 0; }
  .table td[data-l]::before { content: attr(data-l); display: block; font-size: .75rem; color: var(--muted); font-weight: 600; margin-top: .4rem; }
  .table .acts { justify-content: flex-start; margin-top: .6rem; }
  .ag { grid-template-columns: 56px minmax(0, 1fr); }
  .ag .badge { grid-column: 2; justify-self: start; }
  .ag .acts { grid-column: 2; justify-content: flex-start; }
  [data-pending] .ag { grid-template-columns: 56px minmax(0, 1fr); }
  .bars li { grid-template-columns: 100px minmax(0, 1fr) auto; }
}
@media (max-width: 520px) {
  .topbar { flex-wrap: wrap; }
  .topbar .btn { width: 100%; }
}
@media (max-width: 900px) {
  .side-open .app::after { content: ''; position: fixed; inset: 0; z-index: 250; background: rgba(29, 26, 28, .35); }
}
