:root {
  --qt-blue: #1F3864;
  --qt-blue-dark: #162844;
  --qt-blue-soft: #e8eef6;
  --qt-bg: #f3f6fb;
  --qt-text: #142033;
  --qt-muted: #4b5563;
  --qt-danger: #9d1c1c;
  --qt-warn: #9a3412;
  --qt-radius: 12px;
  --qt-shadow: 0 8px 24px rgba(20, 32, 51, 0.08);
  color-scheme: light;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
  background: linear-gradient(180deg, #e9eef6 0%, var(--qt-bg) 40%, #eef2f8 100%);
  color: var(--qt-text);
}
[hidden] { display: none !important; }
dialog:not([open]) { display: none !important; }
body.is-authenticated #login { display: none !important; }
body:not(.is-authenticated) #app { display: none !important; }
body { margin: 0; min-height: 100vh; }
main {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}
.site-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  box-sizing: border-box;
  width: 100%;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid rgba(31, 56, 100, 0.12);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 2;
}
.brand { display: inline-flex; align-items: center; justify-self: start; text-decoration: none; }
.brand img { display: block; height: 92px; width: auto; }
.header-meta,
.site-header > h1 {
  justify-self: center;
  text-align: center;
}
.header-meta h1,
.site-header > h1 { margin: 0; font-size: 1.5rem; color: var(--qt-blue); }
#logout { justify-self: end; }
.who { margin: 0.2rem 0 0; color: var(--qt-muted); font-size: 0.9rem; }
.card, form, article, #calendar, .meetings article {
  background: #fff;
  border-radius: var(--qt-radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--qt-shadow);
  border: 1px solid rgba(31, 56, 100, 0.06);
}
label { display: block; margin: 0.65rem 0; font-weight: 600; font-size: 0.92rem; }
label.inline { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 500; margin-right: 1rem; }
input, select, textarea, button, a.button {
  font: inherit;
}
input, select, textarea {
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid #c9d3e2;
  border-radius: 8px;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(31, 56, 100, 0.35);
  border-color: var(--qt-blue);
}
textarea { min-height: 7rem; resize: vertical; }
.button, button, .toolbar a {
  background: var(--qt-blue);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.95rem;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  font-weight: 600;
}
.button:hover, button:hover, .toolbar a:hover { background: var(--qt-blue-dark); }
.button.ghost, button.ghost, .toolbar a.ghost, .toolbar button:not(.active) {
  background: transparent;
  color: var(--qt-blue);
  border: 1px solid rgba(31, 56, 100, 0.35);
}
.toolbar button.active {
  background: var(--qt-blue);
  color: #fff;
  border-color: var(--qt-blue);
}
.toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
  align-items: center;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.room-choice {
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin: 0.75rem 0;
}
.room-choice legend { padding: 0 0.35rem; color: var(--qt-blue); font-weight: 700; }
.error { color: var(--qt-danger); min-height: 1.2rem; font-weight: 500; }
.detail-notice { color: #166534; min-height: 1.2rem; margin: 0 0 0.35rem; font-weight: 700; }
button:disabled { opacity: 0.6; cursor: wait; }
.error-card { border-color: #f0c4c4; }
.hint { color: var(--qt-muted); font-size: 0.92rem; font-weight: 400; }
.meta { color: var(--qt-muted); }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.warn { color: var(--qt-warn); font-size: 0.9rem; }
.status {
  min-height: 1.25rem;
  margin: 0.5rem 0 1rem;
  color: var(--qt-blue);
  font-weight: 600;
}
.status.is-loading::before {
  content: "";
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  margin-right: 0.45rem;
  border: 2px solid rgba(31, 56, 100, 0.25);
  border-top-color: var(--qt-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -0.1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty {
  background: var(--qt-blue-soft);
  border-radius: var(--qt-radius);
  padding: 1.25rem;
  color: var(--qt-muted);
  text-align: center;
}
.meetings article h3 {
  margin: 0 0 0.35rem;
  color: var(--qt-blue);
  font-size: 1.1rem;
}
.meetings .badge {
  display: inline-block;
  background: var(--qt-blue-soft);
  color: var(--qt-blue);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  font-size: 0.8rem;
  font-weight: 700;
}
dialog {
  max-width: 640px;
  border: 0;
  border-radius: var(--qt-radius);
  padding: 1.25rem;
  box-shadow: var(--qt-shadow);
}
dialog::backdrop { background: rgba(10, 16, 28, 0.45); }
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
}
.calendar .head {
  font-weight: 700;
  text-align: center;
  font-size: 0.85rem;
  color: var(--qt-blue);
}
.calendar .day {
  min-height: 5.5rem;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.35rem;
  font-size: 0.8rem;
  background: #fff;
}
.calendar .day .num { font-weight: 700; margin-bottom: 0.25rem; color: var(--qt-blue); }
.calendar .day .event {
  display: block;
  background: var(--qt-blue-soft);
  color: var(--qt-blue-dark);
  border-radius: 4px;
  padding: 0.15rem 0.3rem;
  margin-top: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calendar-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.join-page .card { max-width: 28rem; margin-inline: auto; }
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .brand img { height: 68px; }
  .calendar .day { min-height: 4.2rem; font-size: 0.72rem; }
  .site-header {
    position: static;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .header-meta,
  .site-header > h1 {
    flex: 1 1 100%;
    text-align: right;
  }
}
@media (prefers-reduced-motion: reduce) {
  .status.is-loading::before { animation: none; }
}

/* UX agenda — sezioni, dettaglio, inviti */
.agenda-board .toolbar { margin-top: 0; }
#list-heading { margin: 0.15rem 0 0.75rem; color: var(--qt-blue); }
.create-panel form {
  background: transparent;
  box-shadow: none;
  border: 0;
  padding: 0.85rem 0 0;
  margin: 0;
}
@media (min-width: 960px) {
  body.is-authenticated main { max-width: 1240px; }
  .agenda-layout {
    display: grid;
    grid-template-columns: minmax(32rem, 38rem) minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
  }
  .agenda-layout .create-panel { margin-bottom: 0; }
}
.calendar-dialog {
  max-width: min(920px, 94vw);
  width: min(920px, 94vw);
}
.calendar-dialog h2 { margin: 0 0 0.75rem; color: var(--qt-blue); }
.calendar-dialog #calendar {
  background: transparent;
  box-shadow: none;
  border: 0;
  padding: 0;
  margin: 0;
}
.create-panel summary {
  cursor: pointer;
  list-style: none;
}
.create-panel summary h2 { display: inline; margin: 0; font-size: 1.15rem; color: var(--qt-blue); }
.create-panel summary::-webkit-details-marker { display: none; }
.choice-card {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem;
  margin: 0.5rem 0;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  font-weight: 500;
  cursor: pointer;
}
.choice-card:has(input:checked) {
  border-color: var(--qt-blue);
  background: var(--qt-blue-soft);
}
.choice-card input { width: auto; margin: 0.2rem 0 0; flex-shrink: 0; }
.choice-card strong { color: var(--qt-blue); }
.choice-card small { color: var(--qt-muted); font-weight: 400; }
.ends-preview {
  margin: 0.35rem 0;
  padding: 0.55rem 0.75rem;
  background: var(--qt-blue-soft);
  border-radius: 8px;
  color: var(--qt-blue);
  font-weight: 600;
  text-align: left;
}
.room-slot-status {
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
  font-weight: 600;
  text-align: left;
  min-height: 1.2rem;
}
.room-slot-status.ok { color: #166534; }
.room-slot-status.busy { color: var(--qt-danger); }
.room-meetings-box {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem;
  border: 1px solid #e5eaf2;
  border-radius: 10px;
  text-align: left;
  background: #fafbfd;
}
.room-meetings-box h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--qt-blue);
}
.sections .section-tab.active {
  background: var(--qt-blue);
  color: #fff;
  border-color: var(--qt-blue);
}
.meeting-row {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  text-align: left;
}
.meeting-row:hover, .meeting-row:focus {
  border-color: rgba(31, 56, 100, 0.35);
  box-shadow: 0 10px 28px rgba(20, 32, 51, 0.12);
  outline: none;
}
.detail-dialog, .invite-dialog {
  max-width: min(720px, 94vw);
  width: 100%;
  text-align: left;
  max-height: 90vh;
  overflow: auto;
}
.detail-close-row { display: flex; justify-content: flex-end; margin: 0; padding: 0; box-shadow: none; border: 0; background: transparent; }
.invite-blocks { display: grid; gap: 0.75rem; margin: 1rem 0; text-align: left; }
.invite-block {
  border: 1px solid #e5eaf2;
  border-radius: 10px;
  padding: 0.75rem;
  background: #fafbfd;
  text-align: left;
}
.invite-block-label {
  font-weight: 700;
  color: var(--qt-blue);
  margin-bottom: 0.35rem;
  text-align: left;
}
.invite-block-value {
  margin: 0 0 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--qt-text);
}
.invite-card {
  border: 1px solid #e5eaf2;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  text-align: left;
  background: #fff;
}
.invite-card > strong {
  display: block;
  color: var(--qt-blue);
  font-size: 1.05rem;
}
.invite-facts {
  display: grid;
  grid-template-columns: 8.5rem minmax(0, 1fr);
  gap: 0.35rem 0.75rem;
  margin: 0.7rem 0 0.85rem;
  text-align: left;
}
.invite-facts dt,
.invite-facts dd { margin: 0; text-align: left; }
.invite-facts dt {
  color: var(--qt-muted);
  font-weight: 600;
  font-size: 0.85rem;
}
.acceptance-pending { color: var(--qt-warn); font-weight: 700; }
.acceptance-ok { color: #166534; font-weight: 700; }
.button.small, button.small { padding: 0.35rem 0.65rem; font-size: 0.85rem; }
button.danger, .button.danger {
  background: var(--qt-danger);
  color: #fff;
  border-color: var(--qt-danger);
}
button.danger.ghost, .button.danger.ghost {
  background: transparent;
  color: var(--qt-danger);
  border: 1px solid rgba(157, 28, 28, 0.45);
}
.detail-primary {
  margin: 0.75rem 0 1rem;
  padding: 0.75rem;
  background: var(--qt-blue-soft);
  border-radius: 10px;
}
.detail-actions {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #e5eaf2;
}
.meeting-row-actions {
  margin-top: 0.5rem;
}
.meeting-row-actions button {
  pointer-events: auto;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.calendar .day .event {
  width: 100%;
  border: 0;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
@media (max-width: 720px) {
  .detail-dialog, .invite-dialog { padding: 1rem; }
  .choice-card { padding: 0.65rem; }
  .toolbar.sections { gap: 0.35rem; }
  .toolbar.sections .section-tab { flex: 1 1 auto; text-align: center; }
}
