/* ==========================================================================
   Ghislandi Ski Service — nuova UI (mockup)
   Design system condiviso. Tablet-first: target 1180×820 (landscape),
   con adattamenti per smartphone (<700px) e PC (>=1280px).
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  /* superfici */
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #e9eef4;
  --line: #dce3ea;
  --line-strong: #c5cfd9;

  /* inchiostro */
  --ink: #0e1a24;
  --ink-2: #485664;
  --ink-3: #6f7c89;

  /* marchio */
  --brand: #0b2f4a;
  --brand-2: #123f61;
  --brand-ink: #e8f0f7;
  --brand-ink-2: #9fb6ca;

  /* azione primaria */
  --accent: #1e66d0;
  --accent-hover: #1857b4;
  --accent-soft: #e4eefc;
  --accent-ink: #134a9c;

  /* stati (sempre con icona + etichetta, mai solo colore) */
  --ok: #0f7a3a;
  --ok-soft: #e1f4e8;
  --warn: #9a5b00;
  --warn-soft: #fff1d6;
  --warn-line: #f2c46b;
  --crit: #c22f2f;
  --crit-soft: #fde7e7;
  --crit-line: #f1a9a9;
  --muted: #5f6b77;
  --muted-soft: #eef1f4;

  /* grafici (palette validata: blu / arancio / acqua) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #e1e0d9;

  /* forma */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --shadow-1: 0 1px 2px rgba(14, 26, 36, 0.06), 0 1px 1px rgba(14, 26, 36, 0.04);
  --shadow-2: 0 6px 20px rgba(14, 26, 36, 0.08), 0 2px 6px rgba(14, 26, 36, 0.05);
  --shadow-3: 0 18px 48px rgba(14, 26, 36, 0.18);

  /* touch */
  --tap: 48px;
  --tap-lg: 56px;

  --rail-w: 92px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); letter-spacing: 0.02em; }
.muted { color: var(--ink-3); }
.sub { color: var(--ink-2); }
.small { font-size: 14px; }
.xs { font-size: 12.5px; }
.strong { font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* -------- icone -------- */
.ic {
  width: 24px; height: 24px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic.sm { width: 18px; height: 18px; }
.ic.lg { width: 30px; height: 30px; }
.ic.xl { width: 40px; height: 40px; }

/* ==========================================================================
   Shell: rail di navigazione + area principale
   ========================================================================== */
.app { display: flex; min-height: 100vh; }

.rail {
  position: sticky; top: 0; height: 100vh;
  width: var(--rail-w); flex: none;
  background: var(--brand);
  color: var(--brand-ink-2);
  display: flex; flex-direction: column; align-items: stretch;
  padding: 14px 10px;
  gap: 4px;
  z-index: 20;
}
.rail .logo {
  display: grid; place-items: center;
  height: 56px; margin-bottom: 10px;
}
.rail .logo-mark {
  width: 44px; height: 44px; border-radius: 13px;
  background: linear-gradient(160deg, #3b8cff, #1e66d0);
  display: grid; place-items: center; color: #fff;
  font-weight: 800; font-size: 17px; letter-spacing: -0.02em;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.15);
}
.rail .logo-text { display: none; }
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-height: 66px; border-radius: 14px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em;
  color: var(--brand-ink-2);
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--brand-ink); }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 16px; bottom: 16px;
  width: 4px; border-radius: 0 4px 4px 0; background: #5aa2ff;
}
.nav-item .count {
  position: absolute; top: 7px; right: 14px;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--crit); color: #fff; font-size: 11.5px; font-weight: 700;
  display: grid; place-items: center;
}
.rail .spacer { flex: 1; }
.rail .me {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 0 4px; color: var(--brand-ink-2); font-size: 12px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.rail .me .me-text { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* -------- top bar -------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  min-height: 76px; padding: 12px 24px;
  background: rgba(238, 242, 246, .88);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { display: flex; flex-direction: column; min-width: 0; }
.topbar h1 { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; white-space: nowrap; }
.topbar .title .sub { font-size: 13.5px; }
.topbar .grow { flex: 1; }
.topbar .back {
  width: var(--tap); height: var(--tap); border-radius: 50%;
  display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line);
}

/* campo scansione/ricerca globale — sempre in ascolto dello scanner */
.omni {
  flex: 1; max-width: 560px;
  display: flex; align-items: center; gap: 10px;
  height: var(--tap); padding: 0 8px 0 14px;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 999px; color: var(--ink-3);
  box-shadow: var(--shadow-1);
}
.omni input { flex: 1; border: 0; outline: 0; background: transparent; min-width: 0; color: var(--ink); font-size: 15.5px; }
.omni input::placeholder { color: var(--ink-3); }
.omni .ready {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok); font-size: 12.5px; font-weight: 650;
}
.omni .ready::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #18a04f; box-shadow: 0 0 0 3px rgba(24,160,79,.2); }

.content { padding: 20px 24px 28px; flex: 1; }

/* ==========================================================================
   Componenti
   ========================================================================== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px 12px;
}
.card-head h2, .card-head h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.card-head .grow { flex: 1; }
.card-body { padding: 4px 20px 18px; }
.divider { height: 1px; background: var(--line); margin: 0; border: 0; }
.section-title {
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-3); margin: 0 0 10px;
}

/* bottoni */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: var(--r);
  border: 1.5px solid transparent; background: var(--surface-3); color: var(--ink);
  font-weight: 650; font-size: 15.5px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.dark { background: var(--brand); color: #fff; }
.btn.outline { background: var(--surface); border-color: var(--line-strong); }
.btn.outline:hover { border-color: var(--ink-3); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { background: var(--surface); color: var(--crit); border-color: var(--crit-line); }
.btn.success { background: #138a45; color: #fff; }
.btn.lg { min-height: var(--tap-lg); font-size: 17px; padding: 0 26px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn.icon { width: var(--tap); padding: 0; }
.btn.round { border-radius: 999px; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14.5px; border-radius: 10px; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* chip di stato */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px; border-radius: 999px;
  font-size: 13px; font-weight: 650; white-space: nowrap;
  background: var(--muted-soft); color: var(--muted);
}
.chip .ic { width: 15px; height: 15px; stroke-width: 2.3; }
.chip.rented { background: var(--accent-soft); color: var(--accent-ink); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.crit { background: var(--crit-soft); color: var(--crit); }
.chip.draft { background: transparent; color: var(--ink-2); box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.chip.lg { height: 34px; padding: 0 14px; font-size: 14px; }

/* filtri a pillole / segmented */
.segmented {
  display: inline-flex; padding: 4px; gap: 4px;
  background: var(--surface-3); border-radius: 14px;
}
.segmented button {
  min-height: 42px; padding: 0 16px; border: 0; border-radius: 10px;
  background: transparent; font-weight: 650; font-size: 14.5px; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; white-space: nowrap;
}
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.segmented .n { font-size: 12.5px; color: var(--ink-3); font-weight: 700; }
.segmented button.on .n { color: var(--accent); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  min-height: 42px; padding: 0 16px; border-radius: 999px;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14.5px; cursor: pointer; white-space: nowrap;
}
.pill.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

/* campi */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.input {
  height: var(--tap); padding: 0 14px; border-radius: var(--r);
  border: 1.5px solid var(--line-strong); background: var(--surface);
  outline: 0; width: 100%; font-size: 16px;
}
.input:focus, .input.focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(30,102,208,.15); }
textarea.input { height: auto; min-height: 88px; padding: 12px 14px; resize: vertical; }
.input-icon { position: relative; }
.input-icon .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.input-icon .input { padding-left: 44px; }
.hint { font-size: 13px; color: var(--ink-3); }

/* stepper touch per quantità */
.stepper {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 16px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface);
}
.stepper .what { display: flex; align-items: center; gap: 12px; min-width: 0; }
.stepper .what .ic { color: var(--ink-3); }
.stepper .what span { font-weight: 600; font-size: 15px; }
.stepper .ctrl { display: flex; align-items: center; gap: 4px; }
.stepper .ctrl button {
  width: 44px; height: 44px; border-radius: 12px; border: 0;
  background: var(--surface-3); display: grid; place-items: center; cursor: pointer;
}
.stepper .ctrl output { min-width: 36px; text-align: center; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper.has .ctrl output { color: var(--accent); }

/* avatar con iniziali */
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  background: #dbe7f5; color: #1d4f8a;
}
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.lg { width: 60px; height: 60px; font-size: 21px; }
.avatar.c2 { background: #f6e3d8; color: #8a3d17; }
.avatar.c3 { background: #dcf1e7; color: #146343; }
.avatar.c4 { background: #ece4f7; color: #55358f; }
.avatar.c5 { background: #f8e7c8; color: #7b5300; }

/* righe lista touch */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 14px;
  min-height: 72px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row.sel { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.row .main-txt { flex: 1; min-width: 0; }
.row .t1 { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.row .end { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }

/* icona categoria articolo */
.thing {
  width: 48px; height: 48px; border-radius: 13px; flex: none;
  display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2);
}
.thing.ski { background: #e4eefc; color: #1e66d0; }
.thing.boot { background: #f6e9df; color: #9a4a1a; }
.thing.board { background: #e6f4ee; color: #17704a; }
.thing.helmet { background: #efe8f8; color: #5b3a96; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.kpi .k-label { font-size: 14px; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .k-value { font-size: 32px; font-weight: 750; letter-spacing: -0.02em; }
.kpi .k-delta { font-size: 13px; color: var(--ink-3); }
.kpi.crit { border-color: var(--crit-line); background: linear-gradient(180deg, #fff, #fff7f7); }
.kpi.crit .k-label { color: var(--crit); }

/* banner/avvisi */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-radius: var(--r);
  background: var(--warn-soft); border: 1px solid var(--warn-line); color: #5e3a00;
}
.alert .ic { color: var(--warn); margin-top: 1px; }
.alert.crit { background: var(--crit-soft); border-color: var(--crit-line); color: #6b1a1a; }
.alert.crit .ic { color: var(--crit); }
.alert.info { background: var(--accent-soft); border-color: #b9d2f6; color: #17396b; }
.alert.info .ic { color: var(--accent); }
.alert .a-body { flex: 1; min-width: 0; }
.alert .a-title { font-weight: 700; }
.alert .a-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* master–detail */
.split { display: grid; grid-template-columns: minmax(340px, 400px) 1fr; gap: 18px; align-items: start; }
.split > .pane-list { position: sticky; top: 96px; max-height: calc(100vh - 116px); display: flex; flex-direction: column; overflow: hidden; }
.pane-list .pane-tools { padding: 14px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.pane-list .list { overflow: auto; }

/* barra azioni fissa in basso */
.actionbar {
  position: sticky; bottom: 0; z-index: 9;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; margin: 0 -24px -28px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.actionbar .grow { flex: 1; }
.actionbar .summary { display: flex; flex-direction: column; }
.actionbar .summary b { font-size: 17px; }

/* info a griglia */
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; background: var(--line); border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
.fact { background: var(--surface); padding: 12px 14px; }
.fact .f-l { font-size: 12.5px; color: var(--ink-3); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.fact .f-v { font-weight: 650; margin-top: 3px; }

/* tabella touch */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12.5px; font-weight: 700; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .06em; padding: 12px 14px;
  border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); height: 62px; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.sel td { background: var(--accent-soft); }
.table td.r, .table th.r { text-align: right; }

/* foglio laterale / overlay mockup */
.sheet {
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-3);
}
.kbd {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 6px; background: var(--surface-3); border: 1px solid var(--line-strong);
  font-size: 12px; font-weight: 700; color: var(--ink-2);
}
.progress { height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: #18a04f; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.hstack { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ==========================================================================
   Responsive
   ========================================================================== */

/* PC: sidebar estesa con etichette */
@media (min-width: 1280px) {
  :root { --rail-w: 236px; }
  .rail { padding: 18px 14px; }
  .rail .logo { justify-content: flex-start; display: flex; align-items: center; gap: 12px; padding: 0 8px; }
  .rail .logo-text { display: block; color: #fff; font-weight: 750; font-size: 15px; line-height: 1.15; }
  .rail .logo-text small { display: block; color: var(--brand-ink-2); font-weight: 500; font-size: 12px; }
  .nav-item { flex-direction: row; justify-content: flex-start; gap: 14px; min-height: 50px; padding: 0 14px; font-size: 15px; }
  .nav-item.active::before { left: -14px; top: 12px; bottom: 12px; }
  .nav-item .count { position: static; margin-left: auto; }
  .rail .me { flex-direction: row; justify-content: flex-start; padding: 14px 8px 4px; gap: 12px; }
  .rail .me .me-text { display: block; }
  .rail .me .me-text b { display: block; color: #fff; font-size: 14px; }
  .content { max-width: 1480px; width: 100%; margin: 0 auto; padding: 24px 32px 32px; }
  .topbar { padding: 12px 32px; }
  .actionbar { margin: 0 -32px -32px; padding: 14px 32px; }
}

/* tablet portrait / finestre strette */
@media (max-width: 1023px) {
  .split { grid-template-columns: minmax(300px, 340px) 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .facts { grid-template-columns: repeat(2, 1fr); }
}

/* smartphone: barra di navigazione in basso */
@media (max-width: 699px) {
  body { font-size: 15.5px; }
  .app { flex-direction: column; }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    width: auto; height: auto; flex-direction: row; justify-content: space-around;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 0;
  }
  .rail .logo, .rail .spacer, .rail .me, .nav-item.no-mobile { display: none; }
  .nav-item { flex: 1; min-height: 58px; font-size: 11px; border-radius: 12px; }
  .nav-item.active::before { display: none; }
  .nav-item .count { right: calc(50% - 26px); top: 4px; }
  .main { padding-bottom: 76px; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; min-height: 0; gap: 10px; }
  .topbar h1 { font-size: 21px; }
  .topbar .omni { order: 9; flex-basis: 100%; max-width: none; }
  .topbar .hide-sm { display: none; }
  .omni .ready span { display: none; }
  .omni .ready { padding: 0 10px; }
  .content { padding: 14px 16px 20px; }
  .split { grid-template-columns: 1fr; }
  .split > .pane-list { position: static; max-height: none; }
  .split > .pane-detail { display: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi .k-value { font-size: 26px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .actionbar { bottom: 70px; margin: 0 -16px -20px; padding: 12px 16px; }
  .actionbar .summary { display: none; }
  .actionbar .btn { flex: 1; }
  .hide-sm { display: none !important; }
}
@media (min-width: 700px) { .only-sm { display: none !important; } }

/* le colonne delle griglie possono restringersi sotto la larghezza del contenuto */
.layout > *, .lower > *, .split > *, .gallery > *, .resp > * { min-width: 0; }
@media (max-width: 1023px) { .layout { grid-template-columns: minmax(0, 1fr) !important; } }
@media (max-width: 699px) {
  .actionbar .btn { min-width: 0; padding: 0 12px; font-size: 15.5px; }
}
