/* Toasts, notification settings, guest calls (staff screen and the guest's page).
   Only semantic tokens from tokens.css, so both themes work. */

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--s3));
  display: flex; flex-direction: column-reverse; gap: var(--s2);
  width: min(94vw, 400px); pointer-events: none;
}
@media (min-width: 900px) { .toasts { bottom: var(--s5); left: auto; right: var(--s5); transform: none; } }

.toast {
  --tone: var(--text-muted); --tone-soft: var(--surface-sunken);
  position: relative; overflow: hidden; pointer-events: auto;
  display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: var(--s1) var(--s3);
  padding: var(--s3) var(--s2) var(--s3) var(--s3);
  background: var(--surface-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-float);
  font-size: var(--fs-sm); line-height: 1.4;
  opacity: 0; translate: 0 10px; scale: 0.98;
  transition: opacity var(--t) var(--ease-out), translate var(--t) var(--ease-out), scale var(--t) var(--ease-out);
}
.toast.is-in { opacity: 1; translate: 0 0; scale: 1; }
.toast-success { --tone: var(--success); --tone-soft: var(--success-soft); }
.toast-danger { --tone: var(--danger); --tone-soft: var(--danger-soft); }
.toast-warning { --tone: var(--warning); --tone-soft: var(--warning-soft); }
.toast-info { --tone: var(--info); --tone-soft: var(--info-soft); }
.toast-urgent { --tone: var(--accent); --tone-soft: var(--accent-soft); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-overlay); }

.toast-icon {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--tone-soft); color: var(--tone);
}
.toast-urgent .toast-icon { animation: ring 1.6s var(--ease) infinite; }
.toast-text, .toast-main { min-width: 0; padding-top: 4px; }
.toast-main { all: unset; cursor: pointer; display: block; padding-top: 4px; border-radius: var(--r-sm); }
.toast-main:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.toast-main:hover .toast-title, .toast-main:hover .toast-message:only-child { text-decoration: underline; text-underline-offset: 2px; }
.toast-title { font-weight: 650; color: var(--text); }
.toast-message { color: var(--text-muted); overflow-wrap: anywhere; }
.toast-message:only-child { color: var(--text); }
.toast-urgent .toast-title { font-size: var(--fs-base); }

.toast-close {
  grid-column: 3; grid-row: 1;
  display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: transparent; color: var(--text-muted); cursor: pointer;
}
.toast-close:hover { background: var(--surface-sunken); color: var(--text); }
.toast-close:focus-visible { outline: 2px solid var(--focus); }

.toast-actions { grid-column: 2 / 4; grid-row: 2; display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.toast-action {
  min-height: 36px; padding: 0 var(--s4); border-radius: var(--r-pill); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: var(--fs-sm);
}
.toast-action.is-primary { background: var(--tone); border-color: var(--tone); color: var(--on-primary); }
.toast-urgent .toast-action.is-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .toast-urgent .toast-action.is-primary { color: #1b1206; }
.toast-action:disabled { opacity: 0.6; cursor: progress; }
.toast-action:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.toast-timer {
  position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--tone); opacity: 0.55;
  transform-origin: left; animation: toast-timer var(--t, 4s) linear forwards;
}
.toast-timer.is-paused { animation-play-state: paused; }
@keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes ring {
  0%, 60%, 100% { rotate: 0deg; }
  10%, 30%, 50% { rotate: -14deg; }
  20%, 40% { rotate: 14deg; }
}

/* ---------- Sign-in: password / email code ---------- */
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px;
  background: var(--surface-sunken); border: 1px solid var(--border); border-radius: var(--r-pill);
}
.segmented[hidden] { display: none; }
.segmented-option {
  min-height: 36px; border: 0; border-radius: var(--r-pill); background: transparent;
  color: var(--text-muted); font-weight: 600; font-size: var(--fs-sm); cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.segmented-option[aria-selected="true"] { background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow-card); }
.segmented-option:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- Switches (notification settings, duty) ---------- */
.section-title { margin-top: var(--s3); }
.switch-list { display: grid; }
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s3) 0; border-top: 1px solid var(--border); cursor: pointer;
}
.switch-row:first-child { border-top: 0; padding-top: 0; }
.switch-row.is-locked { cursor: default; }
.switch-text { display: grid; gap: 2px; min-width: 0; }
.switch-label { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.switch-note { font-size: var(--fs-xs); font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 8px; border-radius: var(--r-pill); }
.panel-body > .row { margin-top: var(--s4); align-items: center; }

.switch { position: relative; flex: none; display: inline-block; width: 46px; height: 28px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch input:disabled { cursor: not-allowed; }
.switch-track {
  position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--border-strong);
  transition: background var(--t) var(--ease);
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transition: translate var(--t) var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { translate: 18px 0; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.55; }
.switch-lg { width: 60px; height: 34px; }
.switch-lg .switch-track::after { width: 28px; height: 28px; }
.switch-lg input:checked + .switch-track::after { translate: 26px 0; }

/* ---------- Team: responsibilities ---------- */
.person .chips { flex-wrap: wrap; overflow: visible; list-style: none; margin: var(--s1) 0 0; padding: 0; }
.person .chip { cursor: default; min-height: 26px; font-size: var(--fs-xs); background: var(--primary-soft); border-color: transparent; color: var(--text); }
.person-todo { color: var(--warning); }
.resp-grid { display: grid; gap: var(--s3); }
@media (min-width: 560px) { .resp-grid { grid-template-columns: 1fr 1fr; } }
.resp-grid .check { padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.resp-grid .check:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.resp-grid .check small { display: block; margin-top: 2px; }

/* ---------- Guest calls: staff screen ---------- */
.duty-card {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s4) var(--s5); border-radius: var(--r-lg); border: 1px solid var(--border);
  background: var(--surface); box-shadow: var(--shadow-card);
}
.duty-card.is-on { background: var(--success-soft); border-color: transparent; }
.duty-main { display: flex; gap: var(--s3); align-items: flex-start; min-width: 0; }
.duty-title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; }
.duty-sub { color: var(--text-muted); font-size: var(--fs-sm); }
.duty-dot { flex: none; width: 10px; height: 10px; margin-top: 9px; border-radius: 50%; background: var(--border-strong); }
.is-on > .duty-dot, .is-on .duty-main > .duty-dot { background: var(--success); box-shadow: 0 0 0 4px rgb(46 125 79 / 0.18); }
.duty-card.is-on .switch input:checked + .switch-track { background: var(--success); }

.calls { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.call {
  display: grid; grid-template-columns: auto 1fr; gap: var(--s2) var(--s3); align-items: start;
  padding: var(--s3) var(--s4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface);
}
@media (min-width: 640px) { .call { grid-template-columns: auto 1fr auto; align-items: center; } }
.call-open { border-color: var(--accent); background: var(--accent-soft); }
.call-open .call-icon { color: var(--accent); animation: ring 1.6s var(--ease) infinite; }
.call-acknowledged .call-icon { color: var(--info); }
.call-done { opacity: 0.75; }
.call-done .call-icon { color: var(--success); }
.call-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-raised); }
.call-title { font-size: var(--fs-base); }
.call-meta { font-size: var(--fs-sm); color: var(--text-muted); }
.call-actions { grid-column: 1 / -1; display: flex; gap: var(--s2); flex-wrap: wrap; }
@media (min-width: 640px) { .call-actions { grid-column: auto; } }
.call-actions .btn { min-height: 40px; }
.calls-done .call { padding-block: var(--s2); }

.duty-list { list-style: none; margin: 0 0 var(--s3); padding: 0; display: grid; }
.duty-list li { display: grid; grid-template-columns: auto auto 1fr; gap: var(--s3); align-items: baseline; padding: var(--s2) 0; border-top: 1px solid var(--border); }
.duty-list li:first-child { border-top: 0; }
.duty-list .duty-dot { margin-top: 0; align-self: center; }
.duty-name { font-weight: 600; }
.duty-areas { color: var(--text-muted); font-size: var(--fs-sm); text-align: right; }

.qr-card { display: grid; justify-items: center; gap: var(--s2); text-align: center; }
.qr-img { width: 220px; height: 220px; padding: var(--s3); background: #fff; border-radius: var(--r-md); border: 1px solid var(--border); image-rendering: pixelated; }
.qr-name { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 600; }
.qr-help { color: var(--text-muted); }
@media print {
  body > *:not(dialog) { display: none !important; }
  dialog.modal { position: static; box-shadow: none; border: 0; }
  .modal-head, .modal-foot, .qr-card .notice { display: none !important; }
  .qr-img { width: 9cm; height: 9cm; border: 0; }
}

/* ---------- Guest calls: the guest's page ---------- */
.guest {
  min-height: 100dvh; display: grid; place-items: center; padding: var(--s5) var(--s4);
  background:
    radial-gradient(120% 60% at 50% 0%, var(--sky) 0%, transparent 70%),
    var(--bg);
}
.guest-card {
  width: min(100%, 440px); display: grid; gap: var(--s5);
  padding: var(--s6) var(--s5); border-radius: var(--r-xl); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-float);
}
.guest-brand { display: flex; align-items: center; justify-content: center; gap: var(--s2); }
.guest-brand .brand-name { font-family: var(--font-display); font-size: var(--fs-md); font-weight: 600; }
.guest-body { display: grid; gap: var(--s3); justify-items: center; text-align: center; }
.guest-place { font-size: var(--fs-sm); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.guest-title { font-family: var(--font-display); font-size: var(--fs-3xl); line-height: var(--lh-tight); font-weight: 600; }
.guest-lead { color: var(--text-muted); }
.guest-note { padding: var(--s2) var(--s4); border-radius: var(--r-pill); background: var(--success-soft); color: var(--text); font-size: var(--fs-sm); }
.guest-options { width: 100%; display: grid; gap: var(--s3); margin-top: var(--s2); }
.guest-option {
  min-height: 60px; padding: 0 var(--s5); border-radius: var(--r-lg); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-raised); color: var(--text);
  font-size: var(--fs-md); font-weight: 600;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.guest-option:active { transform: scale(0.98); }
.guest-option:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.guest-option.is-main { min-height: 76px; font-size: var(--fs-lg); background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.guest-option.is-quiet { min-height: 48px; font-size: var(--fs-base); background: transparent; }
.guest-option:disabled { opacity: 0.6; }
.guest-foot { font-size: var(--fs-sm); color: var(--text-muted); }
.guest-icon {
  display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
}
.guest-icon .icon { width: 32px; height: 32px; }
.guest-icon.is-pulse { animation: pulse 1.8s var(--ease) infinite; }
.guest-icon.is-ok { background: var(--success-soft); color: var(--success); animation: none; }
.guest-icon.is-muted { background: var(--surface-sunken); color: var(--text-muted); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--accent-soft); } 70% { box-shadow: 0 0 0 22px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- Polish for the older screens (0.12) ---------- */

/* Today: the greeting gets room to sit on one or two balanced lines, never three. */
.hero-text { max-width: min(100%, 44rem); }
.hero-greeting { text-wrap: balance; }

/* Filter chips: no thick scrollbar; a soft fade at the edge shows the row scrolls.
   Short chip groups sit side by side on wide screens instead of one per line. */
.chips { scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips:has(.chip:nth-child(6)) { mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); padding-right: var(--s5); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s5); }
.filters > * { min-width: 0; max-width: 100%; }
.filters > .chips:has(.chip:nth-child(6)) { flex: 1 1 100%; }

/* Number cards: two across on phones (four squeezed tiles were hard to read). */
@media (max-width: 599px) {
  .stats-4 { grid-template-columns: repeat(2, 1fr); }
  .stats-4 .stat { padding: var(--s3); }
  .stats-4 .stat-label { font-size: var(--fs-xs); }
}

/* Reports: one tidy toolbar. Choices on the left, the period in the middle, downloads on the right. */
.report-toolbar {
  display: grid; gap: var(--s3); align-items: center;
  padding: var(--s3) var(--s4); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-card);
}
.report-toolbar > .row:first-child .input { width: auto; min-width: 200px; flex: 1 1 200px; }
.report-toolbar .period-nav { justify-content: space-between; flex-wrap: nowrap; }
.report-toolbar .period-nav .btn { flex: none; }
.report-toolbar .period-label { flex: 1; min-width: 0; }
@media (min-width: 1100px) {
  .report-toolbar { grid-template-columns: 1fr auto auto; }
  .report-toolbar .period-nav { justify-content: center; }
}

/* Connection cards inside a property card: flat, compact, the name on one or two lines. */
.property-card .conn { box-shadow: none; background: var(--surface-sunken); padding: var(--s3); border-radius: var(--r-md); }
.conn > div { min-width: 0; }
.conn-name { line-height: 1.3; }
.property-card .conn .btn { min-height: 34px; padding: 0 var(--s3); }

/* Test mode / switched-off note: one calm box instead of stacked warnings. */
.notice-test { background: var(--surface-sunken); border: 1px dashed var(--border-strong); color: var(--text-muted); }
.notice-test .icon { color: var(--text-muted); }
.notice-title { font-weight: 650; color: var(--text); margin-bottom: 2px; }
.notice-list { margin: 0; padding-left: 1.1em; display: grid; gap: 2px; }
.stack > .notice + .notice { margin-top: calc(-1 * var(--s2)); }

/* ---------- Owner dashboard: business at a glance ---------- */
.biz-grid { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.biz-card {
  width: 100%; height: 100%; display: grid; align-content: start; gap: 2px; text-align: left; cursor: pointer;
  padding: var(--s3) var(--s4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.biz-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.biz-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.biz-card.needs-you { border-color: var(--accent); background: var(--accent-soft); }
.biz-head { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.biz-card.needs-you .biz-head { color: var(--accent); }
.biz-value { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 600; line-height: 1.15; }
.biz-sub { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.4; }

/* ---------- Training (property staff) ---------- */
.tip-card {
  display: grid; gap: var(--s2); padding: var(--s5); border-radius: var(--r-lg);
  background: var(--primary-soft); border: 1px solid var(--border);
}
.tip-label { font-size: var(--fs-xs); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.tip-hi { font-family: var(--font-display), "Noto Serif Devanagari", serif; font-size: var(--fs-xl); line-height: 1.45; }
.tip-en { color: var(--text-muted); font-size: var(--fs-sm); }
.sop { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.sop + .sop { margin-top: var(--s3); }
.sop > summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); font-weight: 650; }
.sop > summary::-webkit-details-marker { display: none; }
.sop > summary::after { content: "+"; font-size: var(--fs-lg); color: var(--text-muted); }
.sop[open] > summary::after { content: "–"; }
.sop > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-md); }
.sop-hi { font-size: var(--fs-md); }
.sop-sub { font-weight: 400; font-size: var(--fs-sm); color: var(--text-muted); }
.sop-steps { margin: 0; padding: 0 var(--s4) var(--s4) calc(var(--s4) + 1.2em); display: grid; gap: var(--s3); }
.sop-steps li { line-height: 1.5; }
.sop-steps .sop-en { display: block; font-size: var(--fs-xs); color: var(--text-muted); }
.sop-mine { font-size: var(--fs-xs); }

@media (prefers-reduced-motion: reduce) {
  .toast, .switch-track::after { transition: none; }
  .toast-urgent .toast-icon, .call-open .call-icon, .guest-icon.is-pulse { animation: none; }
}
