/* =============================================================================
   Gestionale centro cinofilo — stile
   Una sola famiglia tipografica, un solo colore d'accento, bordi sottili,
   niente ombre. I colori delle discipline arrivano dai dati.
   ============================================================================= */

:root {
  --bg: #ffffff;
  --surface: #f5f7f4;
  --surface-2: #eaeee8;
  --line: #dfe4de;
  --line-strong: #c5ccc3;
  --ink: #1c2a22;
  --ink-2: #4a5851;
  --muted: #7c8a82;
  --accent: #1f7a45;
  --accent-ink: #145a32;
  --accent-soft: #e4f2e9;
  --warn: #a8690c;
  --warn-soft: #fbf1dc;
  --danger: #b3382f;
  --danger-soft: #fae6e4;
  --info-soft: #e6eef8;
  --radius: 6px;
  --radius-lg: 10px;
  --sidebar: 224px;
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Login ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--surface);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card .hint { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.login-demo {
  margin-top: 16px; padding: 12px; border-radius: var(--radius);
  background: var(--warn-soft); color: var(--warn); font-size: 13px;
}

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface);
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 4px 10px 18px; display: flex; align-items: center; gap: 10px; }
.brand img { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; flex: none; }
.brand .name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand .role { color: var(--muted); font-size: 13px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav a.disabled { color: var(--muted); opacity: .6; pointer-events: none; }
.nav a .soon { margin-left: auto; font-size: 11px; color: var(--muted); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .spacer { flex: 1; }
.sidebar .user { padding: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.sidebar .user button { display: block; margin-top: 4px; }

.main { padding: 28px 36px 60px; max-width: 1180px; width: 100%; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.page-head > div:first-child { flex: 1 1 420px; min-width: 0; }
.page-head .sub { color: var(--muted); margin-top: 4px; max-width: 62ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--line-strong); background: var(--bg);
  cursor: pointer; font-weight: 500; line-height: 1.2; white-space: nowrap;
  transition: background .12s;
}
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--danger); border-color: #e4b8b4; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent-ink); cursor: pointer; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.field .help { font-size: 12px; color: var(--muted); }
.input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--bg);
}
.input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 72px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.search { max-width: 340px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.error-box { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: var(--radius); font-size: 14px; margin-bottom: 12px; }

/* ---------- Tables ---------- */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: auto; background: var(--bg); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; font-weight: 500; color: var(--muted); background: var(--surface); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface); }
td.num, th.num { text-align: right; }
td.muted { color: var(--muted); }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 4px; }

/* ---------- Small elements ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap;
}
.pill.ok { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.info { background: var(--info-soft); color: #2b4d80; border-color: transparent; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink);
  display: inline-grid; place-items: center; font-weight: 600; font-size: 14px; flex: none;
}
.money { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Stat strip (home) ---------- */
.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}
.stat { padding: 16px 18px 14px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .v { font-size: 30px; font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 2px; }

.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 28px; align-items: start; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.section-title .more { font-size: 13px; }

/* timeline of today's lessons */
.timeline { border-left: 2px solid var(--line); margin-left: 6px; }
.tl-item { position: relative; padding: 4px 0 18px 22px; }
.tl-item::before {
  content: ""; position: absolute; left: -7px; top: 10px;
  width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--muted)); border: 2px solid var(--bg);
}
.tl-item .when { font-weight: 600; }
.tl-item .what { color: var(--ink-2); }
.tl-item .who { color: var(--muted); font-size: 13px; }
.tl-item.done { opacity: .55; }
.tl-item.cancelled .what { text-decoration: line-through; }

/* alert list */
.alerts { display: flex; flex-direction: column; }
.alert-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.alert-row:last-child { border-bottom: 0; }
.alert-row .tag { flex: none; width: 118px; }
.alert-row .tag .pill { white-space: nowrap; }
.alert-row .who { font-weight: 500; }
.alert-row .det { color: var(--ink-2); font-size: 13.5px; }

/* ---------- Client detail ---------- */
.detail-head { display: flex; gap: 16px; align-items: center; margin-bottom: 8px; }
.detail-head .avatar { width: 52px; height: 52px; font-size: 18px; }
.detail-head .meta { color: var(--muted); font-size: 14px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 20px 0 18px; }
.tabs button {
  background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button .n { color: var(--muted); font-weight: 400; margin-left: 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px; background: var(--bg); }
.card .t { font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .d { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.card .foot { margin-top: 10px; display: flex; gap: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: var(--accent); }

/* ---------- Drawer ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(28, 42, 34, .35); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100%);
  background: var(--bg); z-index: 41; display: flex; flex-direction: column;
  border-left: 1px solid var(--line);
  animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 20px 22px; overflow: auto; flex: 1; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.drawer-foot .btn { white-space: nowrap; }
.drawer-foot .left { margin-right: auto; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius); font-size: 14px; animation: slide .18s; }
.toast.err { background: var(--danger); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 2px; }
  .brand { padding: 4px 10px; width: 100%; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 6px 10px; }
  .sidebar .spacer, .sidebar .user { display: none; }
  .main { padding: 18px 16px 40px; }
  .two-col, .row, .row-3 { grid-template-columns: 1fr; }
  th, td { padding: 9px 10px; }
}

/* ---------- Calendario ---------- */
.seg { display: inline-flex; gap: 0; }
.seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.seg .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.cal-wrap { border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg); }
.cal-head, .cal-body { display: grid; grid-template-columns: 52px repeat(7, minmax(0, 1fr)); }
.cal-head { border-bottom: 1px solid var(--line); background: var(--surface); }
.cal-day { padding: 8px 6px; text-align: center; font-size: 13px; color: var(--muted); border-left: 1px solid var(--line); }
.cal-day .dd { font-size: 16px; font-weight: 600; color: var(--ink); margin-left: 2px; }
.cal-day.oggi .dd { background: var(--accent); color: #fff; border-radius: 999px; padding: 1px 7px; }
.cal-body { max-height: 70vh; overflow-y: auto; }
.cal-gutter { position: relative; }
.cal-hour { font-size: 11px; color: var(--muted); text-align: right; padding: 2px 6px 0 0; border-top: 1px solid var(--line); box-sizing: border-box; }
.cal-col { position: relative; border-left: 1px solid var(--line); }
.cal-col.oggi { background: #fafcf9; }
.cal-cell { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); cursor: pointer; }
.cal-cell:hover { background: var(--accent-soft); }
.cal-ev { position: absolute; padding: 1px 2px; box-sizing: border-box; }
.chip {
  height: 100%; box-sizing: border-box; overflow: hidden; cursor: pointer;
  border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 12%, white);
  border-radius: 4px; padding: 3px 6px; font-size: 12px; line-height: 1.25;
}
.chip:hover { background: color-mix(in srgb, var(--c) 22%, white); }
.chip-t { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip-s { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.pieno .chip-chi { color: var(--accent-ink); font-weight: 600; }
.chip.passato { opacity: .55; }
.chip.annullato { background: var(--surface); border-left-style: dashed; border-left-color: var(--muted); }
.chip.annullato .chip-t { text-decoration: line-through; color: var(--muted); }
.day-tabs { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 14px; }
.day-tab { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 2px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); cursor: pointer; }
.day-tab .dn { font-size: 11px; color: var(--muted); }
.day-tab .dd { font-weight: 600; font-size: 16px; }
.day-tab .dc { font-size: 10px; color: var(--accent-ink); min-height: 12px; }
.day-tab.active { border-color: var(--ink); }
.day-tab.oggi .dd { color: var(--accent-ink); }
.day-list { display: flex; flex-direction: column; gap: 8px; }
.day-row .chip { height: auto; padding: 10px 12px; font-size: 14px; }
.day-row .chip-t, .day-row .chip-s { white-space: normal; }
.pren-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pren-row .grow { flex: 1; min-width: 180px; }
.pren-actions { display: flex; gap: 4px; }
.inline-form { width: 100%; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: var(--surface); border-radius: var(--radius); }
.sugg { display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden; }
.sugg-item { text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-top: 0; background: var(--bg); cursor: pointer; }
.sugg-item:first-child { border-top: 1px solid var(--line); }
.sugg-item:hover { background: var(--surface); }
.tl-item { display: block; color: inherit; }
.tl-item:hover { text-decoration: none; background: var(--surface); border-radius: var(--radius); }
@media (max-width: 860px) {
  .cal-head, .cal-body { grid-template-columns: 40px repeat(7, minmax(0, 1fr)); }
  .chip { font-size: 10px; padding: 2px 3px; }
}

/* ---------- Accesso online (scheda cliente) ---------- */
.accesso-box { margin-top: 14px; }
.accesso-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }

/* ---------- Impostazioni ---------- */
.logo-box { width: 140px; height: 140px; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); display: grid; place-items: center; background: var(--surface); overflow: hidden; }
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Assistenza superadmin ---------- */
.assistenza-bar { background: var(--ink); color: #fff; padding: 8px 16px; font-size: 13px; text-align: center; position: sticky; top: 0; z-index: 30; }
.assistenza-bar + .shell .sidebar { top: 33px; height: calc(100vh - 33px); }
