/* ValeBooking — owner portal. Swiss/minimal; palette "Hotel/Hospitality" (navy + gold). */

:root {
  --c-primary: #1E3A8A;
  --c-primary-hover: #1E40AF;
  --c-on-primary: #FFFFFF;
  --c-accent: #A16207;
  --c-bg: #F8FAFC;
  --c-surface: #FFFFFF;
  --c-text: #0F172A;
  --c-text-muted: #475569;
  --c-border: #E2E8F0;
  --c-border-strong: #CBD5E1;
  --c-muted: #F1F5F9;
  --c-error: #B91C1C;
  --c-error-bg: #FEF2F2;
  --c-ok: #15803D;
  --c-ok-bg: #F0FDF4;
  --c-warn: #92400E;
  --c-warn-bg: #FFFBEB;
  --c-warn-border: #FDE68A;
  --c-focus: #1E3A8A;

  --booked: var(--c-primary);
  --booked-stripe: rgba(255, 255, 255, .14);
  --blocked: #E2E8F0;
  --blocked-stripe: #CBD5E1;
  --blocked-text: #334155;
  --owner: #0F766E;                         /* "Uso diretto": teal, dotted (not only color) */
  --owner-dot: rgba(255, 255, 255, .28);

  --font-head: "Lexend", system-ui, sans-serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --ease: cubic-bezier(.2, 0, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font: 400 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--c-primary); }
.icon { flex: none; }
.muted { color: var(--c-text-muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; border-radius: var(--radius-sm); }

.skip-link { min-height: 44px; display: inline-flex; align-items: center; position: absolute; left: var(--s4); top: -100px; background: var(--c-surface); padding: var(--s2) var(--s4); border-radius: var(--radius-sm); z-index: 10; }
.skip-link:focus { top: var(--s2); }

/* ---- Layout ---------------------------------------------------------------- */

.topbar { background: var(--c-surface); border-bottom: 1px solid var(--c-border); position: sticky; top: 0; z-index: 5; }
.topbar__inner { max-width: 1200px; margin: 0 auto; padding: var(--s3) var(--s4); display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.topbar__actions { display: flex; align-items: center; gap: var(--s4); }
.user-name { color: var(--c-text-muted); font-weight: 500; }
.link-quiet { min-height: 44px; display: inline-flex; align-items: center; color: var(--c-text-muted); text-decoration: none; font-weight: 500; }
.link-quiet[aria-current="page"] { color: var(--c-text); box-shadow: inset 0 -2px 0 var(--c-accent); }
.link-quiet:hover { color: var(--c-text); }

.brand { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; gap: var(--s3); text-decoration: none; color: var(--c-text); }
.brand--center { justify-content: center; width: 100%; margin-bottom: var(--s5); }
.brand__logo { height: 40px; width: auto; display: block; }
.brand__logo--large { height: auto; width: 180px; max-width: 60%; }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__sub { font-size: 13px; color: var(--c-text-muted); }

.page { max-width: 1200px; margin: 0 auto; padding: var(--s6) var(--s4) var(--s8); }
.page--wide { max-width: 1440px; }
.wide .topbar__inner { max-width: 1440px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--c-accent); margin-bottom: var(--s1); }
.page-title { font-size: clamp(24px, 3vw, 32px); }
.updated { display: inline-flex; align-items: center; gap: var(--s2); color: var(--c-text-muted); font-size: 14px; }

.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---- Buttons & forms ------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s4); border-radius: var(--radius-sm);
  font: 600 15px/1 var(--font-body); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn--primary { background: var(--c-primary); color: var(--c-on-primary); }
.btn--primary:hover { background: var(--c-primary-hover); }
.btn--secondary { background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.btn--secondary:hover { background: var(--c-muted); }
.btn--secondary[aria-disabled="true"] { color: var(--c-text-muted); pointer-events: none; background: var(--c-muted); }
.btn--ghost { background: transparent; color: var(--c-text); padding: 0 var(--s3); }
.btn--ghost:hover { background: var(--c-muted); }
.btn--icon { width: 44px; padding: 0; background: var(--c-surface); color: var(--c-text); border-color: var(--c-border-strong); }
.btn--icon:hover { background: var(--c-muted); }
.btn--block { width: 100%; }
.btn--sm { min-height: 36px; padding: 0 var(--s3); font-size: 14px; }
.btn--danger { background: var(--c-surface); color: var(--c-error); border-color: #FECACA; }
.btn--danger:hover { background: var(--c-error-bg); }

.field { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s4); }
.field label, .apt-picker label { font-weight: 600; font-size: 15px; }
input[type="text"], input[type="password"], input[type="email"], input[type="search"], select {
  min-height: 44px; padding: 0 var(--s3); border: 1px solid var(--c-border-strong); border-radius: var(--radius-sm);
  font: inherit; color: var(--c-text); background: var(--c-surface); width: 100%;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus, select:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(30, 58, 138, .18); }
input[aria-invalid="true"] { border-color: var(--c-error); }
input[readonly] { background: var(--c-muted); color: var(--c-text-muted); }
.field__hint { font-size: 14px; color: var(--c-text-muted); }

.alert { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s3); border-radius: var(--radius-sm); margin-bottom: var(--s4); font-size: 15px; }
.alert .icon { margin-top: 2px; }
.alert--error { background: var(--c-error-bg); color: var(--c-error); border: 1px solid #FECACA; }
.alert--ok { background: var(--c-ok-bg); color: var(--c-ok); border: 1px solid #BBF7D0; }

.badge { display: inline-flex; align-items: center; gap: var(--s1); padding: 2px var(--s2); border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--c-muted); color: var(--c-text-muted); }
.badge--ok { background: var(--c-ok-bg); color: var(--c-ok); }
.badge--error { background: var(--c-error-bg); color: var(--c-error); }
.badge--warn { background: var(--c-warn-bg); color: var(--c-warn); border: 1px solid var(--c-warn-border); }

/* ---- Login ----------------------------------------------------------------- */

.auth { min-height: 100vh; min-height: 100dvh; }
.auth__main { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--s6) var(--s4); }
.auth__panel { width: 100%; max-width: 400px; }
.auth__card { padding: var(--s6); }
.auth__title { font-size: 24px; margin-bottom: var(--s1); }
.auth__card > .muted { margin-bottom: var(--s5); }
.auth__card .btn { margin-top: var(--s2); }
.auth__help { text-align: center; margin-top: var(--s5); color: var(--c-text-muted); font-size: 14px; }

/* ---- Owner calendar -------------------------------------------------------- */

.segmented { display: inline-flex; flex-wrap: wrap; gap: var(--s1); padding: var(--s1); background: var(--c-muted); border-radius: var(--radius); margin-bottom: var(--s5); }
.segmented__item { min-height: 44px; display: inline-flex; align-items: center; padding: 0 var(--s4); border-radius: var(--radius-sm); text-decoration: none; color: var(--c-text-muted); font-weight: 600; }
.segmented__item:hover { color: var(--c-text); }
.segmented__item[aria-current="page"] { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow); }

.apt-picker { display: flex; align-items: center; gap: var(--s3); max-width: 480px; margin-bottom: var(--s5); }
.apt-picker select { flex: 1; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s4); }
.toolbar__nav { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.toolbar__range { font-size: 18px; font-weight: 500; margin-left: var(--s2); }

.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--c-text-muted); }
.legend li { display: inline-flex; align-items: center; gap: var(--s2); }
.swatch { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--c-border-strong); }
.swatch--free { background: var(--c-surface); }
.swatch--booked { background: repeating-linear-gradient(135deg, var(--booked-stripe) 0 2px, transparent 2px 6px), var(--booked); border-color: var(--booked); }
.swatch--blocked { background: repeating-linear-gradient(135deg, var(--blocked-stripe) 0 2px, var(--blocked) 2px 6px); }
.swatch--owner { background: radial-gradient(var(--owner-dot) 1px, transparent 1.5px) 0 0 / 5px 5px, var(--owner); border-color: var(--owner); }

.months { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s4); }
.month { padding: var(--s5) var(--s4) var(--s4); }
.month__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); padding: 0 var(--s1); }
.month__title { font-size: 17px; }
.month__meta { font-size: 13px; color: var(--c-text-muted); }
.month__meta strong { color: var(--c-text); font-weight: 600; }

.cal { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.cal th { font-size: 12px; font-weight: 600; color: var(--c-text-muted); padding-bottom: var(--s1); }
.cal th abbr { text-decoration: none; }
.cal th.is-weekend { color: var(--c-accent); }
.cal td { padding: 0; }

.day {
  display: grid; place-items: center; aspect-ratio: 1; min-height: 36px; border-radius: var(--radius-sm);
  font: 500 14px/1 var(--font-body); font-variant-numeric: tabular-nums; position: relative;
}
.day--free { background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text); }
.day--booked {
  background: repeating-linear-gradient(135deg, var(--booked-stripe) 0 2px, transparent 2px 7px), var(--booked);
  color: var(--c-on-primary); font-weight: 600;
}
.day--blocked {
  background: repeating-linear-gradient(135deg, var(--blocked-stripe) 0 2px, var(--blocked) 2px 7px);
  color: var(--blocked-text);
}
.day--owner {
  background: radial-gradient(var(--owner-dot) 1.2px, transparent 1.7px) 0 0 / 6px 6px, var(--owner);
  color: var(--c-on-primary); font-weight: 600;
}
.day--unknown { border: 1px dashed var(--c-border-strong); color: var(--c-text-muted); }
.day--free.is-past, .day--unknown.is-past { color: var(--c-text-muted); background: var(--c-muted); border-color: var(--c-muted); }
.day--booked.is-past, .day--owner.is-past, .day--blocked.is-past { opacity: .8; }
.day.is-today { box-shadow: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--c-accent); }

.note { display: flex; gap: var(--s2); align-items: flex-start; margin-top: var(--s5); color: var(--c-text-muted); font-size: 14px; }
.note .icon { margin-top: 3px; }

.empty { padding: var(--s7) var(--s5); text-align: center; display: grid; justify-items: center; gap: var(--s3); color: var(--c-text-muted); }
.empty h1 { font-size: 20px; color: var(--c-text); }

/* ---- Admin ----------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin: 0 0 var(--s5); }
.stat { padding: var(--s4) var(--s5); }
.stat dt { font-size: 14px; color: var(--c-text-muted); margin-bottom: var(--s1); }
.stat dd { margin: 0; font: 600 28px/1.2 var(--font-head); font-variant-numeric: tabular-nums; }

.panel { padding: var(--s5); margin-bottom: var(--s5); }
.panel__head { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s4); }
.panel__head .legend { margin-left: auto; }
.panel__title { font-size: 18px; }
.panel > .panel__title { margin-bottom: var(--s4); }

.grid-scroll { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--c-border); border-radius: var(--radius-sm); }
.occ { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12px; font-variant-numeric: tabular-nums; }
.occ thead th { position: sticky; top: 0; background: var(--c-surface); font-weight: 600; color: var(--c-text-muted); padding: var(--s2) 0; min-width: 26px; text-align: center; border-bottom: 1px solid var(--c-border); }
.occ thead th.is-weekend { color: var(--c-accent); }
.occ thead th.is-today { color: var(--c-on-primary); background: var(--c-accent); }
.occ__dow { display: block; font-weight: 500; font-size: 11px; }
.occ__apt { position: sticky; left: 0; z-index: 1; background: var(--c-surface); text-align: left; min-width: 190px; border-right: 1px solid var(--c-border); }
.occ thead .occ__apt { z-index: 2; padding-left: var(--s3); }
.occ tbody th a { display: flex; gap: var(--s2); align-items: baseline; padding: 5px var(--s3); text-decoration: none; color: var(--c-text); font-weight: 400; }
.occ tbody th a:hover .occ__owner { text-decoration: underline; }
.occ__num { font-weight: 600; min-width: 28px; }
.occ__owner { color: var(--c-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.occ tbody tr:nth-child(even) th, .occ tbody tr:nth-child(even) td.occ__cell--free { background: #FBFCFE; }
.occ__cell { border-bottom: 1px solid var(--c-border); border-right: 1px solid #F1F5F9; height: 28px; }
.occ__cell--booked { background: repeating-linear-gradient(135deg, var(--booked-stripe) 0 2px, transparent 2px 6px), var(--booked); }
.occ__cell--blocked { background: repeating-linear-gradient(135deg, var(--blocked-stripe) 0 2px, var(--blocked) 2px 6px); }
.occ__cell--owner { background: radial-gradient(var(--owner-dot) 1px, transparent 1.5px) 0 0 / 5px 5px, var(--owner); }
.occ__cell--unknown { background: var(--c-muted); }

.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; color: var(--c-text-muted); font-weight: 600; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--c-border); }
.table td { padding: var(--s3); border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- Admin: owners --------------------------------------------------------- */

.page-lead { max-width: 640px; margin-top: var(--s2); }
.linkbox { padding: var(--s5); margin-bottom: var(--s5); border-color: var(--c-primary); }
.linkbox:focus { outline: none; }
.linkbox__title { display: flex; align-items: center; gap: var(--s2); font-size: 17px; margin-bottom: var(--s2); }
.linkbox__title .icon { color: var(--c-ok); }
.linkbox__row { display: flex; gap: var(--s2); margin-top: var(--s4); flex-wrap: wrap; }
.linkbox__row input { flex: 1 1 320px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }

.owners-tools { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s4); }
.field--inline { margin: 0; flex: 0 1 360px; }
.owners-summary { display: flex; gap: var(--s2); flex-wrap: wrap; }

.panel--flush { padding: 0; overflow: hidden; }
.owners thead th { background: var(--c-muted); }
.owners th, .owners td { vertical-align: top; }
.owners tbody tr.has-warning { background: var(--c-warn-bg); }
.owners tbody tr { scroll-margin-top: 96px; }
.owners tbody tr:target { background: #EFF6FF; box-shadow: inset 3px 0 0 var(--c-primary); }
.row-msg { display: flex; gap: var(--s2); align-items: flex-start; font-size: 14px; margin-top: var(--s2); }
.row-msg .icon { margin-top: 2px; }
.row-msg--ok { color: var(--c-ok); }
.row-msg--error { color: var(--c-error); }
.owners__num { font: 600 16px/1.4 var(--font-head); width: 64px; }
.owners__kross { width: 22%; }
.owners__add { width: 340px; }
.owners-empty { padding: var(--s5); text-align: center; }

.acc + .acc { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px dashed var(--c-border); }
.acc__who { display: flex; align-items: baseline; gap: var(--s1) var(--s2); flex-wrap: wrap; }
.acc__name { font-weight: 600; }
.acc__login { color: var(--c-text-muted); font-size: 14px; word-break: break-all; }
.acc__warn { display: flex; gap: var(--s2); align-items: flex-start; color: var(--c-warn); font-size: 14px; margin-top: var(--s2); }
.acc__warn .icon { margin-top: 2px; }
.acc__actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s2); }

.invite { display: flex; gap: var(--s2); }
.invite input { min-height: 36px; flex: 1; min-width: 0; }

/* ---- Small screens --------------------------------------------------------- */

@media (max-width: 640px) {
  .page { padding-top: var(--s5); }
  .topbar__inner { padding: var(--s2) var(--s4); }
  .topbar__actions { gap: var(--s3); }
  .user-name { display: none; }
  .brand__sub { display: none; }
  .topbar--admin .brand__text { display: none; }
  .btn__label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .btn--ghost { width: 44px; padding: 0; }
  .toolbar__range { width: 100%; margin: var(--s2) 0 0; font-size: 16px; }
  .month { padding: var(--s4) var(--s2) var(--s2); }
  .cal { border-spacing: 3px; }
  .day { min-height: 0; font-size: 13px; }
  .auth__card { padding: var(--s5); }
  .runs th:nth-child(3), .runs td:nth-child(3) { display: none; }
  .stats { gap: var(--s3); }
  .stat { padding: var(--s3) var(--s4); }
  .stat dd { font-size: 24px; }
  .panel { padding: var(--s4); }
  .panel__head .legend { margin-left: 0; width: 100%; }
  .occ__apt { min-width: 116px; }
  .occ__owner { max-width: 64px; }
  .topbar__actions { gap: var(--s2); }
  .btn--sm, .invite input { min-height: 44px; }
  .linkbox { padding: var(--s4); }
  .linkbox__row .btn { flex: 1; }
  .field--inline { flex-basis: 100%; }
}

/* Owners table becomes one card per apartment on narrow screens */
@media (max-width: 900px) {
  .owners thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .owners, .owners tbody, .owners tr, .owners th, .owners td { display: block; width: auto; }
  .owners tbody tr { padding: var(--s4); border-bottom: 1px solid var(--c-border); }
  .owners tbody tr:last-child { border-bottom: 0; }
  .owners tbody th, .owners tbody td { padding: 0; border: 0; }
  .owners__num { display: inline !important; margin-right: var(--s2); }
  .owners__num::before { content: "App. "; }
  .owners__kross { display: inline !important; color: var(--c-text-muted); }
  .owners__accounts { margin-top: var(--s3); }
  .owners__add { margin-top: var(--s3); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
