:root {
  --text: #1a1a1a;
  --text-2: #55554f;
  --text-3: #85857e;
  --border: #d6d6d0;
  --border-light: #e8e8e3;
  --page: #f4f4f1;
  --white: #ffffff;
  --button: #26332d;
  --button-hover: #1a231f;
  --button-active: #0f1613;
  --free: #3b6a4c;
  --busy: #94510a;
  --danger: #a32a22;
  --focus: #1f5fbf;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--text); font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; }
h2, h3 { font-size: 16px; }
h2[tabindex="-1"]:focus { outline: none; }
.muted { color: var(--text-3); margin: 2px 0 0; font-size: 14px; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; }

/* Taps register immediately on touch screens (no double-tap-zoom delay). */
button, label, select, summary { touch-action: manipulation; }
button { -webkit-tap-highlight-color: transparent; }

/* Controls marked data-need="feature" get .no-access when the signed-in
   account's level does not include that feature (see roles.js).
   The real enforcement is in firestore.rules. */
.no-access { display: none !important; }

/* Buttons */
.btn { font: inherit; font-size: 14px; font-weight: 500; border: 1px solid transparent; border-radius: 4px; padding: 8px 14px; min-height: 40px; cursor: pointer; }
.btn:focus-visible, .tab:focus-visible, .link-btn:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--button); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--button-hover); }
.btn-primary:active:not(:disabled) { background: var(--button-active); }
.btn-secondary { background: var(--white); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--page); }
.btn-secondary:active:not(:disabled) { background: var(--border-light); }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover:not(:disabled) { background: var(--border-light); }
.btn-quiet:active:not(:disabled) { background: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active:not(:disabled) { background: #7c1f19; }
.btn-block { width: 100%; }
.btn-sm { padding: 4px 10px; min-height: 32px; font-size: 13px; }
.link-btn { background: none; border: 0; padding: 8px 4px; font: inherit; font-size: 13px; color: var(--text-2); text-decoration: underline; cursor: pointer; }
.link-btn:hover:not(:disabled) { color: var(--text); }
.link-btn:active:not(:disabled) { color: var(--text); opacity: .6; }
.link-btn:disabled { opacity: .4; cursor: not-allowed; }
.link-btn.is-danger:hover:not(:disabled) { color: var(--danger); }

/* Forms. 16px text stops iPhones zooming in when an input is tapped. */
label { display: block; font-size: 14px; font-weight: 500; }
input, select { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; color: var(--text); background: var(--white); border: 1px solid #bdbdb6; border-radius: 4px; padding: 8px 10px; min-height: 42px; }
.form-error { color: var(--danger); font-size: 14px; margin: 0; }
.form-info { color: var(--free); font-size: 14px; margin: 0; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
label.check input { width: 20px; height: 20px; min-height: 0; margin: 0; flex: none; }
.link-left { justify-self: start; padding-left: 0; }

/* Demo banner and the demo sign-in picker */
.demo-banner { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px 14px; background: #fff4d6; border-bottom: 1px solid #e6cf8a; padding: 4px 16px; font-size: 13px; text-align: center; color: #5c4a12; }
.demo-actions { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 0 12px; }
.demo-actions .link-btn { color: #5c4a12; padding: 4px 2px; min-height: 0; min-width: 0; }
.demo-people-list { display: grid; gap: 8px; }
.demo-person { display: grid; gap: 2px; width: 100%; text-align: left; font: inherit; color: var(--text); background: var(--white); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; cursor: pointer; }
.demo-person:hover { border-color: var(--text-3); background: var(--page); }
.demo-person:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.demo-person-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.demo-person small { font-size: 13px; color: var(--text-3); line-height: 1.35; }
.demo-or { display: flex; align-items: center; gap: 10px; margin: 6px 0 0; font-size: 12px; color: var(--text-3); }
.demo-or::before, .demo-or::after { content: ""; flex: 1; border-top: 1px solid var(--border-light); }
.demo-or span { flex: none; }

/* Sign in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 360px; background: var(--white); border: 1px solid var(--border); border-radius: 6px; padding: 28px; display: grid; gap: 14px; }
.auth-sub { margin: -8px 0 4px; color: var(--text-3); font-size: 14px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: -6px; }
.auth-card h1 { font-size: 18px; }

/* Top bar */
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.brand::before { content: ""; flex: none; width: 24px; height: 24px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='7' fill='%2326332d'/%3E%3Cg fill='%23ffffff'%3E%3Ccircle cx='9.5' cy='14' r='2.5'/%3E%3Ccircle cx='13.6' cy='9.3' r='2.6'/%3E%3Ccircle cx='18.4' cy='9.3' r='2.6'/%3E%3Ccircle cx='22.5' cy='14' r='2.5'/%3E%3Cellipse cx='16' cy='20.5' rx='6.2' ry='5.2'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat; }
.brand-lg { font-size: 20px; }
.brand-lg::before { width: 30px; height: 30px; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; padding: 0 24px; height: 52px; background: var(--white); border-bottom: 1px solid var(--border); }
.tabs { display: flex; gap: 20px; height: 100%; }
.tab { font: inherit; font-size: 14px; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-3); padding: 0 6px; cursor: pointer; touch-action: manipulation; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 14px; color: var(--text-2); }
.role { font-size: 12px; font-weight: 600; color: var(--text-2); border: 1px solid var(--border); border-radius: 3px; padding: 0 6px; }
.conn { font-size: 13px; color: var(--text-3); }
.conn.is-off { color: var(--busy); font-weight: 600; }
.badge { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px; background: var(--busy); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }

/* Page */
.page { max-width: 1100px; margin: 0 auto; padding: 24px 24px 56px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; }
.head-side { display: flex; align-items: center; gap: 14px; }
.head-side .muted { margin: 0; }
.panel { background: var(--white); border: 1px solid var(--border); border-radius: 6px; padding: 16px 18px; margin-top: 24px; }
.panel h2 { margin-bottom: 10px; }

/* Yards */
.yards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.yards > .muted { grid-column: 1 / -1; }
.yard { background: var(--white); border: 1px solid var(--border); border-radius: 6px; padding: 16px 18px; display: grid; gap: 10px; align-content: start; }
.yard-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.yard-head h3 { margin-right: auto; }
.status { font-size: 13px; font-weight: 600; color: var(--free); }
.is-out .status { color: var(--busy); }
.is-saving .status { color: var(--text-3); font-weight: 500; }
.occupant { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.occupant strong { font-weight: 600; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.dog { color: var(--text-2); }
.timer { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.meta { font-size: 13px; color: var(--text-3); }
.idle { color: var(--text-3); font-size: 14px; margin: 0; }
.actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }

/* Groups */
.group-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 0 24px; }
.gpill { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-light); }
.gpill > div { display: flex; justify-content: space-between; gap: 12px; flex: 1; align-items: baseline; }
.gpill-name { font-size: 14px; }
.gpill-state { font-size: 13px; color: var(--text-3); text-align: right; }
.gpill.is-out .gpill-state { color: var(--busy); font-weight: 600; }

/* Dialogs */
.dialog { border: 1px solid var(--border); border-radius: 6px; padding: 22px; width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; box-shadow: 0 8px 28px rgba(0, 0, 0, .18); color: var(--text); }
.dialog::backdrop { background: rgba(0, 0, 0, .4); }
.dialog form { display: grid; gap: 14px; }
.dialog > h2, .dialog form > h2 { font-size: 18px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.group-options { display: grid; gap: 6px; }
.gopt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-height: 46px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; font-size: 15px; font-weight: 500; }
.gopt:hover { background: var(--page); }
.gopt:active { background: var(--border-light); }
.gopt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; min-height: 0; }
.gopt.is-selected { border-color: var(--text); box-shadow: inset 0 0 0 1px var(--text); }
.gopt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.gopt .where { margin-left: auto; font-size: 13px; font-weight: 400; color: var(--busy); }
.gopt.is-disabled { cursor: not-allowed; color: var(--text-3); background: var(--page); }

.return-detail { font-size: 16px; margin: 6px 0 14px; }
.return-stats { display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 12px; border-top: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light); }
.return-stats div { padding: 10px 0; }
.return-stats dt { font-size: 13px; color: var(--text-3); }
.return-stats dd { margin: 2px 0 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Logs */
.filters { display: grid; grid-template-columns: repeat(3, minmax(0, 200px)); gap: 12px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--text-2); padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border-light); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 8px; }
.edited { font-size: 12px; color: var(--text-3); margin-left: 6px; }
.empty { color: var(--text-3); text-align: center; padding: 20px 0 6px; margin: 0; }

/* Dogs, to-dos, schedule */
textarea { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; color: var(--text); background: var(--white); border: 1px solid #bdbdb6; border-radius: 4px; padding: 8px 10px; resize: vertical; }
input[type="file"] { padding: 6px; font-size: 14px; }
.item-list { list-style: none; margin: 0; padding: 0; }
.item-list > li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-light); flex-wrap: wrap; }
.item-list > li:last-child { border-bottom: 0; }
.item-main { flex: 1; min-width: 180px; }
.item-sub { display: block; font-size: 13px; color: var(--text-3); }
.item-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.is-done .item-main > .item-text { text-decoration: line-through; color: var(--text-3); }
.dog-group h2 { display: flex; align-items: center; gap: 8px; }
.dog-group .count { font-weight: 400; color: var(--text-3); font-size: 14px; }
.dog-total { font-weight: 400; color: var(--text-3); font-size: 15px; }
.dog-group .count.is-over { font-weight: 600; color: var(--danger); }
.notice { display: inline-flex; align-items: center; gap: 6px; margin: 4px 6px 0 0; padding: 2px 8px; border-radius: 3px; background: #fbf1e3; color: #6b3c06; font-size: 13px; }
.notice.is-done { background: var(--page); color: var(--text-3); text-decoration: line-through; }
.notice.is-done .link-btn { text-decoration: underline; }
.notice .link-btn { padding: 0 2px; font-size: 12px; }
.notice-tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.inline-form { display: flex; gap: 8px; margin-bottom: 4px; }
.inline-form input { margin: 0; }
.inline-form .btn { min-height: 42px; }
label.todo-check { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 180px; font-weight: 400; cursor: pointer; }
label.todo-check input { width: 22px; height: 22px; min-height: 0; margin: 0; flex: none; }
.sched-form { margin-top: 0; margin-bottom: 0; display: grid; gap: 12px; }
.sched-fields { display: grid; grid-template-columns: 130px 1fr 1fr 2fr; gap: 12px; }
.sched-note { grid-column: 1 / -1; }
#sched-table td { white-space: normal; }
#sched-table td:first-child, #sched-table .row-actions { white-space: nowrap; }
.handoff-group { font-weight: 600; font-size: 13px; }
.handoff-text { display: block; overflow-wrap: anywhere; }
.table tr.is-now td { background: #eef5ef; font-weight: 600; }
.schedule-now { margin: 4px 0 0; font-size: 14px; color: var(--text-2); }
.schedule-now strong { color: var(--text); }
.schedule-now span { margin-right: 18px; }
.swap-preview { background: var(--surface-2, #f3f5f4); border-radius: 8px; padding: 10px 12px; margin: 12px 0 0; min-height: 3em; }
.item-list li.is-undone { opacity: 0.6; }
.badge-quiet { background: var(--text-3); }

/* Announcements, developer switches, maintenance */
.announce-banner { display: grid; gap: 8px; margin-bottom: 16px; }
.announce-item { background: #eef3fb; border: 1px solid #c5d3ea; border-radius: 6px; padding: 10px 14px; display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.announce-item.is-urgent { background: #fbeceb; border-color: #e3b5b1; }
.announce-item .announce-text { flex: 1; min-width: 200px; }
.announce-item strong, .announce-text > strong { display: block; }
.announce-item .item-sub { margin-top: 2px; }
.announce-message { margin: 6px 0 4px; font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.announce-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.announce-opts { display: grid; grid-template-columns: minmax(0, 260px) 1fr; gap: 12px; align-items: end; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; padding: 0 6px; border-radius: 3px; border: 1px solid var(--border); color: var(--text-2); margin-left: 6px; }
.tag.is-urgent { color: var(--danger); border-color: #e3b5b1; }
.yard.is-closed { background: var(--page); border-style: dashed; }
.status-closed { color: var(--text-3) !important; }
.maintenance-bar { background: var(--busy); color: #fff; padding: 6px 16px; font-size: 14px; text-align: center; }
.viewas-bar { background: #3d4f8a; color: #fff; padding: 6px 16px; font-size: 14px; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.viewas-bar[hidden], .trial-bar[hidden] { display: none; }
.trial-bar { background: var(--page); border-bottom: 1px solid var(--border); color: var(--text-2); padding: 6px 16px; font-size: 14px; text-align: center; }
.inline-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.inline-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.inline-label input { width: 80px; }
.plan-status { font-weight: 600; margin: 0 0 8px; }
.plan-actions { flex-wrap: wrap; align-items: center; }
.health-grid { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 4px 16px; margin: 0 0 12px; font-size: 14px; }
.health-grid dt { color: var(--text-3); }
.health-grid dd { margin: 0; overflow-wrap: anywhere; }
.error-list { list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.error-list li { padding: 6px 0; border-top: 1px solid var(--border-light); overflow-wrap: anywhere; }
.error-list time { color: var(--text-3); margin-right: 6px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border-light); font-weight: 500; cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch-row small { display: block; font-weight: 400; color: var(--text-3); font-size: 13px; }
input[role="switch"] { appearance: none; -webkit-appearance: none; position: relative; width: 46px; height: 26px; min-height: 0; margin: 0; padding: 0; flex: none; border-radius: 13px; border: 1px solid #a9a9a2; background: #c9c9c2; cursor: pointer; transition: background .15s; }
input[role="switch"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
input[role="switch"]:checked { background: var(--free); border-color: var(--free); }
input[role="switch"]:checked::after { transform: translateX(20px); }
input[role="switch"]:disabled { opacity: .5; cursor: not-allowed; }
.panel > label + .dialog-actions, .panel > .switch-row + label { margin-top: 10px; }

/* Accounts */
.table select { min-height: 34px; padding: 4px 8px; margin: 0; font-size: 14px; width: auto; }
.table .is-off-row td { color: var(--text-3); }
.status-on { color: var(--free); font-weight: 600; }
.status-off { color: var(--danger); font-weight: 600; }
.cell-sub { display: none; }
.you { font-size: 12px; color: var(--text-3); margin-left: 6px; }
.level-guide { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; font-size: 14px; }
.level-guide dt { font-weight: 600; }
.level-guide dd { margin: 0; color: var(--text-2); }

/* Toasts */
.toasts { position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); left: 16px; display: grid; gap: 8px; justify-items: end; z-index: 50; pointer-events: none; }
.toast { pointer-events: auto; cursor: pointer; background: var(--text); color: #fff; padding: 10px 14px; border-radius: 4px; font-size: 14px; max-width: 360px; }
.toast.is-error { background: var(--danger); }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; gap: 8px 16px; padding: 10px 14px 0; }
  .tabs { order: 3; width: 100%; height: 44px; gap: 24px; }
  .user-name { display: none; }
  .page { padding: 18px 14px 48px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .head-side { flex-wrap: wrap; }
  .filters { grid-template-columns: 1fr; }
  .yards { grid-template-columns: 1fr; }
  .toasts { justify-items: stretch; }
  .toast { max-width: none; }
  .panel { padding: 14px 12px; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px 6px; }
  .level-guide { grid-template-columns: 1fr; gap: 2px; }
  .tabs { overflow-x: auto; gap: 18px; scrollbar-width: none; }
  .tab { white-space: nowrap; }
  .schedule-now span { display: block; }
  .sched-fields { grid-template-columns: 1fr 1fr; }
  .announce-opts { grid-template-columns: 1fr; }
  .sched-note { grid-column: 1 / -1; }
  .col-email { display: none; }
  .cell-sub { display: block; font-size: 12px; color: var(--text-3); }
  .level-guide dd { margin-bottom: 8px; }
}

/* Split groups, overdue yards, dog search */
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
#split-rows { display: grid; gap: 12px; margin: 14px 0; }
.yard.is-overdue { border-color: #b3261e; box-shadow: 0 0 0 2px rgba(179, 38, 30, 0.18); }
.yard.is-overdue .timer { color: #b3261e; }
.overdue-tag { background: #b3261e; color: #fff; border-radius: 999px; font-size: 12px; font-weight: 600; padding: 2px 10px; }
.overdue-tag[hidden] { display: none; }
#dog-search { max-width: 320px; }
.dog-group .swatch { flex: none; }
.tag.is-dev { background: #3f5fa8; color: #fff; }
.announce-item.is-dev { border-left: 4px solid #3f5fa8; }

/* Developer: group names and colors */
.label-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; flex-wrap: wrap; }
.label-row .label-name { flex: 1; min-width: 160px; }
.label-row .label-color { width: 44px; height: 36px; padding: 2px; flex: none; }

/* Developer: level permissions grid, level names */
.perm-grid th:not(:first-child), .perm-grid td:not(:first-child) { text-align: center; }
.perm-grid td:first-child { white-space: normal; min-width: 180px; }
.perm-grid td small { display: block; color: var(--text-3); font-size: 12px; }
.perm-grid input[type="checkbox"] { width: 20px; height: 20px; margin: 0; cursor: pointer; }
.perm-grid td.is-changed { background: #fbf4e4; }
.perm-grid td.is-changed input { outline: 2px solid var(--busy); outline-offset: 2px; }
.perm-grid .always { color: var(--text-3); font-size: 13px; }
.level-row { display: grid; grid-template-columns: minmax(140px, 220px) 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.level-row:last-child { border-bottom: 0; }
.level-row input, .level-row textarea { margin: 0; }
.level-row .level-actions { display: flex; gap: 6px; align-items: center; }
@media (max-width: 640px) { .level-row { grid-template-columns: 1fr; } .perm-grid td:first-child { min-width: 140px; } .perm-grid th, .perm-grid td { padding-left: 6px; padding-right: 6px; } }

/* Add to group, today list, handlers */
.bulk-preview { margin: 8px 0; font-size: 14px; }
.bulk-preview .sum { font-weight: 600; margin: 0 0 6px; }
.bulk-preview ul { list-style: none; margin: 0; padding: 0; max-height: 180px; overflow: auto; display: grid; gap: 2px; }
.bulk-preview li.is-bad { color: #b3261e; }
.bulk-preview li.is-move { color: var(--text-2); }
.today-tag { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 8px; margin-left: 6px; background: #eef3fb; color: #3f5fa8; }
.today-tag.is-off { background: #f3f0ea; color: #7a6a52; }
.warn-tag { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 1px 8px; margin-left: 6px; background: #fbeceb; color: #b3261e; }
#sched-table tr.is-mine td:first-child { box-shadow: inset 3px 0 0 #3f5fa8; }
.slot-dogs { display: block; font-size: 12px; color: var(--text-2); }

/* Developer tab: options that take a value */
.option-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border-light); font-weight: 500; }
.option-row small { display: block; font-weight: 400; color: var(--text-3); font-size: 13px; }
.option-input { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.option-input input[type="number"] { width: 5rem; }
@media (max-width: 560px) { .option-row { flex-direction: column; align-items: stretch; } }

/* ---------- Add employee ---------- */
.dialog-wide { width: min(560px, calc(100vw - 32px)); }
.dialog > div[id$="-done"] { display: grid; gap: 14px; }
.dialog > div[id$="-done"][hidden] { display: none; }
.note-box { margin: 0; padding: 10px 12px; font-size: 14px; background: #efeee6; border: 1px solid var(--border); border-radius: 4px; color: var(--text-2); }
.field-hint { margin: -8px 0 0; font-size: 13px; color: var(--text-3); }
.field-hint.is-bad { color: var(--danger); }
.field-hint.is-good { color: var(--free); }
.pw-row { display: flex; gap: 8px; align-items: flex-end; }
.pw-row input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.pw-row .btn { flex: none; margin-bottom: 1px; }
.pw-meter { height: 6px; margin-top: -8px; border-radius: 3px; background: var(--border-light); overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; background: var(--danger); transition: width .15s, background .15s; }
.pw-meter span[data-score="1"] { width: 25%; background: var(--danger); }
.pw-meter span[data-score="2"] { width: 50%; background: var(--busy); }
.pw-meter span[data-score="3"] { width: 75%; background: #6c8f3a; }
.pw-meter span[data-score="4"] { width: 100%; background: var(--free); }
.cred-card { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; padding: 14px 16px; background: var(--page); border: 1px solid var(--border); border-radius: 6px; }
.cred-card dt { color: var(--text-3); font-size: 13px; }
.cred-card dd { margin: 0; font-weight: 600; word-break: break-all; }
.cred-card dd#done-user, .cred-card dd#done-pass, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.dialog-actions { flex-wrap: wrap; }
.account-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.account-tools input { flex: 2 1 200px; margin-top: 0; }
.account-tools select { flex: 1 1 140px; width: auto; margin-top: 0; }
.panel h2 .count { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 6px; }
.table .fail { color: var(--danger); font-size: 13px; }
.dialog form[hidden], .dialog .btn[hidden] { display: none; }

/* ---------- Per-person permissions ---------- */
.perms-box { border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px 12px; margin: 0; min-width: 0; }
.perms-box legend { font-size: 14px; font-weight: 600; padding: 0 6px; }
.perms-box p { margin: 0 0 8px; }
.perm-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border-light); font-size: 14px; }
.perm-row select { width: auto; min-width: 150px; margin: 0; min-height: 34px; font-size: 14px; padding: 4px 8px; }
.perm-row.is-custom { font-weight: 600; }
.tag-custom { font-size: 11px; font-weight: 600; color: var(--busy); border: 1px solid var(--busy); border-radius: 3px; padding: 0 5px; margin-left: 6px; }
@media (max-width: 520px) { .perm-row { flex-direction: column; align-items: stretch; } .perm-row select { width: 100%; } }

/* ---------- My turns, reminders, handoff notes ---------- */
.my-turns { margin-top: 0; margin-bottom: 16px; border-left: 4px solid var(--free); }
.my-turns h2 { margin-bottom: 6px; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.plain-list li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.plain-list li.is-now { font-weight: 600; }
.tag-now { font-size: 11px; font-weight: 700; color: #fff; background: var(--free); border-radius: 3px; padding: 0 6px; }
.turn-reminder { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; padding: 10px 14px; background: #fff7e0; border: 1px solid #e6cf8a; border-radius: 6px; font-weight: 600; }
.turn-reminder[hidden] { display: none; }
.handoff-form { display: grid; grid-template-columns: minmax(130px, 200px) 1fr auto; gap: 8px; margin-top: 10px; align-items: center; }
.handoff-form select, .handoff-form input { margin: 0; }
@media (max-width: 640px) { .handoff-form { grid-template-columns: 1fr; } }

/* ---------- Phones, tablets and big screens ---------- */
/* Nine tabs do not fit beside the account buttons below about 1180px, so the tabs get their own row. */
@media (max-width: 1180px) {
  .topbar { flex-wrap: wrap; height: auto; gap: 4px 16px; padding: 8px 20px 0; }
  .tabs { order: 3; width: 100%; height: 46px; gap: 22px; overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex: none; padding: 0 8px; }
  .topbar-right { flex-wrap: wrap; }
}
/* Fingers need bigger targets than a mouse: 44px high on touch screens and phones. */
@media (pointer: coarse), (max-width: 720px) {
  .btn, .btn-sm { min-height: 44px; padding-top: 8px; padding-bottom: 8px; }
  .btn-sm { padding-left: 12px; padding-right: 12px; }
  .link-btn { min-height: 44px; min-width: 44px; padding: 10px 8px; }
  input, select { min-height: 44px; }
  .table select, .perm-row select { min-height: 44px; }
  .label-row .label-color, .option-input input[type="color"] { min-height: 44px; }
  .notice .link-btn { min-height: 32px; min-width: 32px; padding: 4px; }
  label.check input { width: 24px; height: 24px; }
  label.check { min-height: 44px; }
}
.option-input input[type="color"] { width: 56px; padding: 2px; flex: none; }
.dialog-actions .btn { flex: none; }

@media (max-width: 720px) {
  body { font-size: 16px; }
  /* Dogs: one tight line per dog, with the actions beside the name. */
  .dog-group .item-list > li { flex-wrap: nowrap; gap: 4px; padding: 2px 0; }
  .dog-group .item-main { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
  .dog-group .item-actions { flex: none; gap: 0; }
  .dog-group .item-actions .link-btn { padding: 10px 6px; }
  .page-head .head-side .btn { flex: 1 1 auto; }
  #dog-search { max-width: none; }
  .filters { gap: 10px; }
  /* Dialogs fill the screen's width, and the buttons stay in reach above the keyboard. */
  .dialog { width: calc(100vw - 20px); padding: 16px; }
  .dialog-actions { position: sticky; bottom: -16px; margin: 4px -16px -16px; padding: 10px 16px; background: var(--white); border-top: 1px solid var(--border-light); }
  .dialog-actions .btn { flex: 1 1 0; }
  .bulk-preview ul { max-height: 140px; }
  /* Tables become stacked cards. */
  .table-wrap:has(.stack) { overflow: visible; }
  .table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table.stack, .table.stack tbody, .table.stack tr { display: block; width: 100%; }
  .table.stack tr { margin: 0 0 10px; padding: 6px 12px; border: 1px solid var(--border-light); border-radius: 6px; background: var(--white); }
  .table.stack th, .table.stack td { white-space: normal; }
  .table.stack td { display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 6px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .table.stack td::before { content: attr(data-label); flex: none; margin-right: auto; font-size: 12px; font-weight: 600; color: var(--text-3); text-align: left; }
  .table.stack td .cell-sub { display: none; }
  .table.stack td .you { margin-left: 8px; }
  .table.stack td[data-label=""]::before, .table.stack td:not([data-label])::before { content: none; }
  .table.stack td[colspan] { display: block; text-align: center; }
  .table.stack .row-actions { justify-content: flex-end; flex-wrap: wrap; }
  .table.stack tr.is-now { box-shadow: inset 4px 0 0 var(--free); }
  .table.stack tr.is-now td { background: transparent; }
  .yard { padding: 14px; }
  .timer { font-size: 32px; }
  .group-strip { grid-template-columns: 1fr; }
  .announce-item .announce-text { min-width: 0; }
}
/* Landscape phones and small tablets: keep the board in two columns. */
@media (min-width: 560px) and (max-width: 900px) { .yards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Printing the Dogs tab (or any tab) leaves out the buttons and the top bar. */
@media print {
  .topbar, .demo-banner, .maintenance-bar, .viewas-bar, .trial-bar, .toasts, .head-side, .filters, .item-actions, .tabs, dialog { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .page { max-width: none; padding: 0; }
  .panel, .yard, .table tr { break-inside: avoid; box-shadow: none; }
}
.page-head { flex-wrap: wrap; }
.head-side { flex-wrap: wrap; }
.head-side .btn { white-space: nowrap; }
