:root {
  --ink: #0d0d0d;
  --ink-2: #5c5c5c;
  --bg: #ffffff;
  --line: #e5e5e5;
  --line-soft: #f2f2f2;
  --border: #d3d3d3;
  --toolbar: #f9f9f9;
  --sidebar: #0d0d0d;
  --accent: #6950f3;
  --avatar-bg: #ebf8fe;
  --avatar-ink: #0075a8;
  --off: #f2f2f2;
  --off-stripe: rgba(222, 222, 222, 0.8);
  --now: #d4163a; /* measured on the reference */
  --appt: #9bbdfd; /* measured on the reference (service colour "jordyBlue") */
  --appt-hover: #8aaffb;
  --picked: #f0f0ff;
  --pop-shadow: 0 2px 8px rgba(19, 19, 19, 0.08), 0 4px 20px rgba(19, 19, 19, 0.12);
  --res-col: 80px;
  --appt-ink: #0d0d0d;
  --danger: #d4002a;
  --success: #12a150;

  --topbar-h: 64px;
  --sidebar-w: 72px;
  --toolbar-h: 68px;
  --head-h: 109px;
  --gutter-w: 48px;
  --lane-min: 169px;
  /* Set from JS by the zoom level: rows are always 24px, --hour = 24px × rows per hour. */
  --hour: 96px;
  --slot: 24px;

  --font: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0;
  font: 400 14px/20px var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  /* App-like: a long press must not select text or open the iOS callout (same as the reference). */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input, textarea, select { user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
/* Don't show a half-built page (no icons, no hours) while the script starts. */
html:not(.booted) .app { visibility: hidden; }
svg { display: block; }

/* ---------- Shell ---------- */
.app {
  /* 100% (not 100dvh): on iOS Safari dvh can reach under the floating toolbar. */
  height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "top top" "side main";
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  padding: 0 32px 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.brand {
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-decoration: none;
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 0; }
.icon-btn {
  width: 44px; height: 44px;
  display: inline-grid; place-items: center;
  border-radius: 8px;
}
@media (hover: hover) { .icon-btn:hover { background: rgba(19, 19, 19, 0.06); } }
.icon-btn svg { width: 24px; height: 24px; }
.avatar-user {
  width: 48px; height: 48px; margin-left: 10px;
  border-radius: 999px; border: 1px solid #fff;
  background: var(--avatar-bg); color: var(--avatar-ink);
  font: 600 14px/24px var(--font);
}

.sidebar {
  grid-area: side;
  background: var(--sidebar);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 8px 0 16px;
}
.sidebar-items { display: flex; flex-direction: column; }
.nav-item {
  height: 52px; display: grid; place-items: center; cursor: pointer; color: #fff;
}
.nav-item svg { width: 44px; height: 44px; padding: 8px; border-radius: 8px; }
.nav-item:hover svg { background: rgba(255, 255, 255, 0.12); }
.nav-item.is-active svg { background: var(--accent); }

.main { grid-area: main; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }

/* ---------- Toolbar ---------- */
.toolbar {
  height: var(--toolbar-h);
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px;
  background: var(--toolbar);
  border-bottom: 1px solid var(--line);
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pill {
  height: 36px; padding: 0 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px; background: #fff;
  font-size: 15px; font-weight: 500; line-height: 20px; white-space: nowrap;
}
.pill:hover { background: #f4f4f4; }
.pill svg { width: 20px; height: 20px; }
.pill i svg { width: 16px; height: 16px; }
.pill-icon { width: 52px; padding: 0; }
.pill-group { display: inline-flex; }
.pill-group .pill { border-radius: 0; margin-left: -1px; }
.pill-group .pill-start { border-radius: 999px 0 0 999px; margin-left: 0; }
.pill-group .pill-end { border-radius: 0 999px 999px 0; }
.pill-group .pill-icon { width: 40px; }
.pill-date { width: 175px; }
.pill-view { min-width: 86px; }
.pill-view[aria-expanded="true"] i svg { transform: rotate(180deg); }
.pill-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.pill-primary:hover { background: #2b2b2b; }
.conn { width: 8px; height: 8px; border-radius: 999px; background: var(--border); margin-right: 4px; transition: background .2s; }
.conn.is-online { background: var(--success); }
.conn.is-offline { background: var(--danger); }

/* ---------- Calendar grid ---------- */
.calendar {
  flex: 1; min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  overscroll-behavior-x: none; /* no iOS rubber-band sideways: it would pull the two dates apart */
  position: relative;
  /* No scroll bars over the agenda (as in the reference); scrolling still works. */
  scrollbar-width: none;
  /* Horizontal scrolling always stops on a whole column, never half of one. */
  scroll-snap-type: x mandatory;
  scroll-padding-left: var(--gutter-w);
}
.lane { scroll-snap-align: start; }
/* While dragging, auto-scroll moves freely; it snaps again on drop. */
body.is-dragging .calendar { scroll-snap-type: none; }
.cal-head {
  position: sticky; top: 0; z-index: 7; /* above the hours column (6) */
  display: flex; min-width: max-content;
  height: var(--head-h);
  background: #fff;
  box-shadow: 0 4px 6px -2px rgba(0, 0, 0, 0.08);
}
.cal-corner { position: sticky; left: 0; z-index: 1; width: var(--gutter-w); flex: none; background: #fff; }
.resource {
  flex: 1 0 var(--lane-min); width: var(--lane-min);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 4px 8px 0;
}
.avatar {
  width: 56px; height: 56px; border-radius: 999px; border: 1px solid #fff;
  display: grid; place-items: center;
  background: var(--avatar-bg); color: var(--avatar-ink);
  font: 600 16px/24px var(--font);
  box-shadow: 0 0 0 2px #c3e9fb;
}
.resource-name { position: relative; font-size: 13px; font-weight: 600; line-height: 16px; max-width: 100%; white-space: nowrap; }
/* ⌄ sits just right of the name so the name stays centred under the avatar. */
.resource-chevron { position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin-left: 4px; opacity: 0; }
.resource-chevron svg { width: 20px; height: 20px; }
.resource.is-hot .resource-chevron { opacity: 1; }
.resource.is-hot .avatar, .agrid-res.is-hot .avatar { background: #ceeffd; }

.cal-body { display: flex; min-width: max-content; position: relative; }
.cal-gutter {
  /* Above the current-time line (z 4) and appointments: content sliding under it must not cross the hours. */
  position: sticky; left: 0; z-index: 6;
  width: var(--gutter-w); flex: none;
  height: calc(var(--hour) * 24);
  background: #fff;
}
.hour-label {
  position: absolute; left: 0; width: var(--gutter-w);
  text-align: center;
  font-size: 13px; font-weight: 600; line-height: 11px;
}
.half-label { font-weight: 600; }

.cal-lanes {
  position: relative; display: flex; flex: 1;
  height: calc(var(--hour) * 24);
  background-color: var(--off);
  background-image: repeating-linear-gradient(45deg, transparent 0 6px, var(--off-stripe) 6px 7.5px);
}
.lane {
  position: relative;
  flex: 1 0 var(--lane-min); width: var(--lane-min);
  border-right: 1px solid var(--line);
  cursor: pointer;
}
.lane-work { position: absolute; left: 0; right: 0; background: #fff; pointer-events: none; }
.grid-lines {
  position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background-image:
    linear-gradient(to bottom, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line-soft) 1px, transparent 1px);
  background-size: 100% var(--hour), 100% var(--slot);
}
/* Empty slot under the mouse (lilac) and the slot picked by a click (white, 2px purple):
   21px tall in a 24px row, and as wide as an appointment (1px off the left edge). */
.slot-hover, .slot-picked {
  position: absolute; left: 1px; right: 0; height: calc(var(--slot) - 3px); margin-top: 1px; z-index: 2;
  border-radius: 4px; box-sizing: border-box;
  color: var(--accent); font-size: 13px; font-weight: 500; line-height: 16px;
  pointer-events: none; white-space: nowrap; overflow: hidden;
}
.slot-hover { background: var(--picked); border: 1px solid #dbddff; padding: 2px 5px 2px 8px; }
.slot-picked { background: #fff; border: 2px solid var(--accent); padding: 1px 5px 1px 7px; z-index: 3; }

/* Calendar settings drawer */
.setting { display: flex; flex-direction: column; gap: 12px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.setting-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.setting-head label { font-size: 17px; font-weight: 600; line-height: 24px; }
.setting-head span { font-size: 15px; color: var(--ink); }
.range {
  --fill: 66%;
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 24px; margin: 0; background: transparent; cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 4px; border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--line) var(--fill));
}
.range::-moz-range-track { height: 4px; border-radius: 999px; background: var(--line); }
.range::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--accent); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -6px; border-radius: 999px; background: var(--accent); border: 0;
}
.range::-moz-range-thumb { width: 16px; height: 16px; border-radius: 999px; background: var(--accent); border: 0; }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(105, 80, 243, 0.25); }

.appt {
  /* Measured on the reference: no border, 1px off the column edges, 1px gap below
     (height is set 1px short), padding 3/4/3/8, all text 13px/16px. */
  position: absolute; left: 1px; right: 0; z-index: 3;
  background: var(--appt); color: var(--appt-ink);
  border-radius: 4px; border: 0;
  padding: 3px 4px 3px 8px; overflow: hidden;
  font-size: 13px; line-height: 16px;
  cursor: pointer; text-align: left;
  transition: opacity .15s;
}
.appt { display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; }
.appt { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
/* Mouse only: on touch screens :hover sticks after a simple tap. With a finger
   the appointment is highlighted only once a long-press starts the drag (.appt-ghost). */
@media (hover: hover) and (pointer: fine) {
  .appt:hover { background: var(--appt-hover); box-shadow: inset 0 0 0 2px var(--accent); }
  .appt:hover .appt-resize::after { opacity: .7; }
}
/* Bottom edge: drag to change the duration. */
.appt-resize {
  position: absolute; left: 0; right: 0; bottom: 0; height: 10px;
  display: grid; place-items: center;
  cursor: ns-resize;
}
.appt-resize::after {
  content: ""; width: 14px; height: 5px;
  border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink);
  opacity: 0; transition: opacity .1s;
}
.appt-ghost .appt-resize::after { opacity: .7; }
/* Touch: picked up by a long-press; stays like this until touching elsewhere.
   touch-action: none so the next touch on it drags instead of scrolling. */
.appt.is-selected { background: var(--appt-hover); box-shadow: inset 0 0 0 2px var(--accent); touch-action: none; }
.appt.is-selected .appt-resize::after { opacity: .7; }
.appt-ghost {
  z-index: 7; pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--accent), 0 8px 24px rgba(19, 19, 19, 0.18);
  background: var(--appt-hover);
}
.appt.is-drag-source { opacity: 0.35; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
body.is-resizing, body.is-resizing * { cursor: ns-resize !important; user-select: none; -webkit-user-select: none; }
@media (hover: none) {
  .appt-resize { height: 16px; } /* bigger target for fingers */
}
/* "09:00 - 10:00 Cliente" on one line when it fits, the name drops below when it doesn't. */
.appt-head { display: flex; flex-wrap: wrap; column-gap: 4px; }
.appt-time { font-weight: 400; white-space: nowrap; }
.appt-client { font-weight: 600; }
.appt-service { white-space: normal; }
.appt.is-pending {
  opacity: 0.65;
  background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(255, 255, 255, 0.5) 6px 9px);
}
.appt.is-failed { background: #ffd6dd; }

.now-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--now); margin-top: -1px; z-index: 4; pointer-events: none; }
/* Measured on the reference: 48x20, 2px border, 10px radius, 13px semibold, centred. */
.now-pill {
  position: absolute; left: 0; width: var(--gutter-w); height: 20px; z-index: 5;
  transform: translateY(-50%); box-sizing: border-box;
  display: grid; place-items: center;
  border: 2px solid var(--now); border-radius: 10px; background: #fff;
  color: var(--now); font-size: 13px; font-weight: 600; line-height: 11px;
}

/* ---------- Drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(13, 13, 13, 0.3); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 21;
  width: min(480px, 100vw);
  background: #fff;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.12);
  display: flex; flex-direction: column;
  animation: drawer-in .2s ease-out;
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 24px 24px 8px 32px; }
.drawer-head h2 { margin: 0; font-size: 28px; line-height: 36px; font-weight: 600; }
/* Desktop: the close button floats outside the drawer, to its left (as in the reference). */
@media (min-width: 768px) {
  .drawer { overflow: visible; }
  .drawer-head { padding-top: 32px; }
  .drawer-head .icon-btn {
    position: absolute; left: -60px; top: 12px;
    width: 48px; height: 48px; border-radius: 999px; background: #fff;
  }
}
.drawer-body { flex: 1; overflow: auto; padding: 16px 32px; display: flex; flex-direction: column; gap: 20px; }
.drawer-foot { padding: 16px 32px calc(24px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 12px; }

.drawer-form { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 15px; font-weight: 600; }
.field input, .field select {
  height: 48px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  font-size: 15px; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(105, 80, 243, 0.2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail { display: flex; flex-direction: column; gap: 4px; }
.detail-label { font-size: 13px; color: var(--ink-2); }
.detail-value { font-size: 16px; font-weight: 600; }
.detail-card { background: var(--appt); border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }

.btn {
  height: 48px; padding: 0 24px; border-radius: 999px;
  font-size: 17px; font-weight: 600; line-height: 24px;
  display: inline-flex; align-items: center; justify-content: center; flex: 1;
  border: 1px solid var(--border); background: #fff;
}
.btn:hover { background: #f4f4f4; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #2b2b2b; }
.btn-danger { color: var(--danger); border-color: #f1b5c0; }
.btn:disabled { opacity: .5; cursor: default; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: #fff; border-radius: 999px;
  padding: 12px 20px; font-size: 15px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  max-width: calc(100vw - 32px);
}

/* ---------- Popovers: view menu and quick actions ---------- */
.popover {
  position: fixed; z-index: 25;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--pop-shadow);
  padding: 8px;
  animation: pop-in .12s ease-out;
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.popover-menu { width: 242px; }
/* Quick actions, measured on the reference: grey 40px title band edge to edge,
   then 16px/24px body; rows bleed 12px so their text lines up with the title. */
.popover-qa { width: 282px; padding: 0; overflow: hidden; }
.popover-qa .qa-body { padding: 16px 24px; }
.popover-qa .qa-body .menu-item { margin: 0 -12px; width: calc(100% + 24px); }
.menu { list-style: none; margin: 0; padding: 0; }
.menu-item {
  width: 100%; height: 40px; padding: 8px 12px; border-radius: 8px;
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 500; line-height: 20px; text-align: left;
}
.menu-item svg { width: 20px; height: 20px; }
.menu-item.is-active { background: var(--picked); }
@media (hover: hover) { .menu-item:not(.is-active):hover { background: rgba(19, 19, 19, 0.04); } }
.qa-head { display: flex; align-items: center; justify-content: space-between; height: 40px; padding: 0 4px 0 24px; background: #f2f2f2; }
.qa-title { margin: 0; font-size: 17px; font-weight: 600; line-height: 24px; }
.qa-close { width: 36px; height: 36px; border-radius: 999px; }
.qa-close svg { width: 20px; height: 20px; }

/* ---------- 3 días / Semana / Mes ---------- */
.alt-view { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; overscroll-behavior-x: none; scrollbar-width: none; background: var(--bg); }
.calendar::-webkit-scrollbar, .alt-view::-webkit-scrollbar { display: none; }

/* Swipe strip: the neighbouring date drawn next to the grid while dragging.
   Its own hours/team column is hidden: the real one stays fixed on top. */
.strip-neighbor { overflow: hidden !important; scroll-snap-type: none !important; background: var(--bg); }
.strip-neighbor .cal-gutter, .strip-neighbor .cal-corner,
.strip-neighbor .agrid-res > *, .strip-neighbor .agrid-corner, .strip-neighbor .hscroll { visibility: hidden; }
.agrid-res, .agrid-corner { position: relative; z-index: 2; }
/* Divider where the two dates meet: a fine line with a soft shadow, as in the reference. */
.strip-sep {
  position: absolute; width: 1px; z-index: 3; pointer-events: none;
  background: #dcdcdc;
  box-shadow: 0 0 8px 1px rgba(19, 19, 19, 0.08);
}
body.is-panning, body.is-panning * { user-select: none; -webkit-user-select: none; }
body.is-panning .calendar, .calendar.is-stripping { scroll-snap-type: none; }
.agrid-head, .agrid-body { display: grid; min-width: 100%; }
.agrid-head {
  position: sticky; top: 0; z-index: 3; height: 62px;
  background: #fff; box-shadow: 0 4px 6px -2px rgba(0, 0, 0, 0.08);
}
.day-head {
  margin: 0 4px; padding: 0 0 0 8px; border-radius: 12px;
  display: flex; align-items: center; gap: 4px;
}
@media (hover: hover) { .day-head:hover { background: rgba(19, 19, 19, 0.04); } }
.day-head.is-hot { background: rgba(19, 19, 19, 0.04); }
.day-num { padding: 4px 8px; font-size: 17px; font-weight: 500; line-height: 24px; }
.day-name { font-size: 15px; font-weight: 500; line-height: 20px; }
.day-head.is-today .day-num { background: var(--accent); color: #fff; border-radius: 999px; }
.agrid-body { gap: 1px; background: var(--line); grid-auto-rows: 173px; padding-top: 1px; }
.agrid-res {
  background: #fff; padding: 0 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.agrid-res .avatar { width: 40px; height: 40px; font: 600 13px/16px var(--font); }
.agrid-res-name { font-size: 13px; font-weight: 600; line-height: 16px; text-align: center; }
.acell, .mcell {
  background: #fff; padding: 6px; min-width: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 4px; cursor: pointer;
}
.acell.is-off, .mcell.is-off {
  background-color: var(--off);
  background-image: repeating-linear-gradient(45deg, transparent 0 6px, var(--off-stripe) 6px 7.5px);
}
@media (hover: hover) {
  /* Also over days off: the lilac replaces the hatching while hovered (as in the reference). */
  .acell:hover, .mcell:hover { background: var(--picked); box-shadow: inset 0 0 0 1px #c6bdfb; }
}
.acell.is-picked, .mcell.is-picked { background: var(--picked); box-shadow: inset 0 0 0 1px #c6bdfb; }
.abar {
  flex: none; height: 24px; padding: 4px; border-radius: 4px;
  background: var(--appt); color: var(--appt-ink);
  display: flex; align-items: center; gap: 4px; min-width: 0;
  font-size: 13px; line-height: 16px; text-align: left; white-space: nowrap; overflow: hidden;
}
.abar-time { font-weight: 400; flex: none; }
.abar-client { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) { .abar:hover { box-shadow: inset 0 0 0 2px var(--accent); } }
.abar.is-pending { opacity: 0.65; }
.abar.is-failed { background: #ffd6dd; }

.mgrid-head {
  position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  background: #fff; box-shadow: 0 4px 6px -2px rgba(0, 0, 0, 0.08);
}
.mgrid-wd { height: 44px; padding: 12px; font-size: 15px; font-weight: 500; line-height: 20px; }
.mgrid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: 144px;
  gap: 1px; background: var(--line); padding-top: 1px;
}
.mday { margin: 0; font-size: 13px; font-weight: 600; line-height: 20px; display: flex; align-items: center; gap: 4px; }
.mcell.is-off .mday { color: #767676; }
.today-pill {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: #fff; line-height: 20px; text-align: center;
}
.mmore { align-self: flex-start; font-size: 13px; font-weight: 600; line-height: 16px; color: var(--accent); padding: 2px 4px; }

/* ---------- Mobile-only pieces (hidden on desktop) ---------- */
.mobile-date {
  height: 48px; padding: 0 12px 0 12px; margin-left: 0;
  align-items: center; gap: 8px; border-radius: 999px;
  font-size: 17px; font-weight: 600; line-height: 24px; white-space: nowrap;
}
@media (hover: hover) { .mobile-date:hover { background: rgba(19, 19, 19, 0.06); } }
.mobile-date svg { width: 24px; height: 24px; }

.hscroll {
  position: sticky; left: 0; top: var(--head-h); z-index: 6;
  height: 0; width: 100%;
}
.hscroll::before, .hscroll-thumb {
  content: ""; position: absolute; top: 8px; height: 4px; border-radius: 999px;
}
.hscroll::before { left: calc(50% - 60px); width: 120px; background: var(--line); }
.hscroll-thumb { left: calc(50% - 60px); width: 40px; background: var(--ink); transition: opacity .2s; }

.float-actions {
  position: absolute; right: 20px; bottom: 21px; z-index: 10;
  display: flex; flex-direction: column; gap: 8px;
}
.float-btn {
  width: 48px; height: 48px; border-radius: 999px;
  background: #fff; border: 1px solid var(--border);
  display: grid; place-items: center;
  box-shadow: 0 8px 32px rgba(19, 19, 19, 0.16);
}
.float-btn svg { width: 24px; height: 24px; }

.bottom-nav {
  grid-area: bottom;
  height: calc(65px + env(safe-area-inset-bottom));
  padding: 4px 12px env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: #fff;
  justify-content: space-between; align-items: center;
}
.bottom-item { width: 70px; height: 56px; display: grid; place-items: center; border-radius: 8px; color: var(--ink); cursor: pointer; }
.bottom-item svg { width: 28px; height: 28px; }
.bottom-item.is-active { color: var(--accent); }
.bottom-add { width: 52px; height: 40px; border-radius: 999px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.bottom-add svg { width: 26px; height: 26px; }

.sheet-scrim { position: fixed; inset: 0; z-index: 22; background: rgba(19, 19, 19, 0.25); }
.date-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; top: 11px; z-index: 23;
  background: #fff; border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
.date-sheet-head { display: flex; justify-content: flex-end; padding: 16px 16px 0; }
.date-chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 20px 8px; scrollbar-width: none; }
.date-chips::-webkit-scrollbar { display: none; }
.chip {
  height: 36px; padding: 0 15px; flex: none;
  border: 1px solid var(--border); border-radius: 999px; background: #fff;
  font-size: 15px; font-weight: 500;
}
.date-months { flex: 1; overflow-y: auto; padding: 8px 20px 32px; }
.month { margin-bottom: 24px; }
.month-title { margin: 16px 0 8px; font-size: 20px; font-weight: 600; line-height: 28px; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.weekday, .day { height: 44px; display: grid; place-items: center; font-size: 15px; line-height: 20px; }
.weekday { color: #767676; }
.day span {
  width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center; font-weight: 500;
}
@media (hover: hover) { .day:hover span { background: #f2f2f2; } }
.day.is-today span { box-shadow: 0 0 0 1px var(--border) inset; }
.day.is-selected span { background: var(--accent); color: #fff; box-shadow: none; }

.only-mobile { display: none !important; }

/* ---------- Tablet ---------- */
@media (max-width: 1100px) {
  .hide-tablet { display: none !important; }
}

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
  :root {
    --topbar-h: 60px;
    --head-h: 71px;
    --gutter-w: 48px;
    /* Three team members per screen. */
    --lane-min: calc((100vw - var(--gutter-w)) / 3);
  }
  .only-mobile { display: inline-grid !important; }
  .hide-mobile { display: none !important; }
  .mobile-date { display: inline-flex !important; }
  .bottom-nav { display: flex !important; }
  .float-actions { display: flex !important; }
  .hscroll { display: block !important; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr auto;
    grid-template-areas: "top" "main" "bottom";
  }
  .sidebar, .toolbar { display: none; }
  .topbar { padding: 0 20px 0 8px; gap: 0; border-bottom: 0; }
  .topbar-actions { gap: 0; }
  .avatar-user {
    width: 32px; height: 32px; margin-left: 8px;
    background: #f0f0ff; border-color: #f0f0ff; color: var(--accent);
    font: 600 11px/14px var(--font);
  }
  .cal-head { box-shadow: 0 4px 6px -2px rgba(0, 0, 0, 0.08); }
  .resource { gap: 8px; padding: 0 4px; border-right: 1px solid var(--line-soft); }
  .avatar { width: 28px; height: 28px; font: 600 11px/14px var(--font); box-shadow: 0 0 0 2px #c3e9fb; }
  .resource-name { font-size: 11px; line-height: 12px; }
  .hour-label { text-align: left; padding-left: 10px; }
  .drawer { width: 100vw; box-shadow: none; animation-name: sheet-in; }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
  .drawer-head { padding: 16px 16px 8px 20px; flex-direction: column-reverse; align-items: stretch; gap: 8px; }
  .drawer-head .icon-btn { align-self: flex-end; }
  .drawer-head h2 { font-size: 28px; line-height: 36px; }
  .drawer-body { padding: 12px 20px; }
  .drawer-foot { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); }
  /* iOS zooms the page when focusing a field under 16px and leaves it zoomed. */
  .field input, .field select { font-size: 16px; }
}

/* ---------- Team filter menu ---------- */
.popover-team { width: 338px; padding: 8px; max-height: calc(100vh - 140px); overflow-y: auto; }
.team-search {
  display: flex; align-items: center; gap: 4px; height: 36px; margin: 8px 4px 12px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 8px;
}
.team-search:focus-within { border-color: var(--accent); }
.team-search svg { width: 20px; height: 20px; color: var(--ink-2); }
.team-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 15px; }
.menu-sep { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }
.menu-check { cursor: pointer; }
.menu-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.mini-avatar {
  width: 24px; height: 24px; border-radius: 999px; flex: none;
  display: grid; place-items: center; background: var(--avatar-bg); color: var(--avatar-ink);
  font-size: 9px; font-weight: 600; line-height: 1;
}

/* ---------- Nobody to show (measured on the reference) ---------- */
.cal-lanes.is-empty { background: #fff; }
.cal-empty, .agrid-empty { flex: 1; display: flex; justify-content: center; }
.cal-empty { position: relative; }
.cal-empty-box {
  position: sticky; top: calc(var(--head-h) + 22vh); align-self: flex-start;
  width: 446px; max-width: calc(100% - 32px); margin-top: 22vh;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.agrid-empty { padding: 22vh 16px 0; }
.cal-empty-art { width: 56px; height: 56px; margin-bottom: 16px; }
.cal-empty-title { margin: 0 0 4px; font-size: 20px; font-weight: 600; line-height: 28px; }
.cal-empty-sub { margin: 0 0 24px; font-size: 15px; line-height: 20px; color: #767676; }
.cal-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
/* As in the reference: with nobody shown, only the time pill stays (no red line across). */
.cal-lanes.is-empty .now-line { display: none; }

/* ---------- Account menu (avatar) ---------- */
.popover-account { width: 260px; }
.account-head { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px 8px; border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; }
.account-head strong { font-size: 15px; font-weight: 600; }
.account-head span { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
