:root {
  --ink: #1d2528;
  --muted: #617074;
  --line: #d8e0df;
  --surface: #ffffff;
  --soft: #eef4f1;
  --accent: #16735f;
  --accent-strong: #0f5747;
  --warn: #b86713;
  --danger: #a63d3d;
  --blue: #2f6f9f;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: #f6f8f7;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
img, canvas { max-width: 100%; }
a { color: inherit; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 32px);
  background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  text-decoration: none;
}
.brand img {
  width: 154px;
  height: 56px;
  object-fit: contain;
}
.main-nav { display: flex; align-items: center; gap: 12px; font-size: 14px; flex-wrap: wrap; }
.main-nav a { text-decoration: none; color: var(--accent-strong); font-weight: 700; }
.nav-user { color: var(--muted); font-weight: 750; }
.nav-form { margin: 0; }
.link-button {
  min-height: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent-strong);
  font: inherit;
  font-weight: 700;
}
.menu-toggle {
  display: none;
  width: 44px;
  min-height: 44px;
  padding: 0;
  background: var(--ink);
  font-size: 22px;
}
.shell { width: min(1180px, calc(100% - 28px)); margin: 24px auto 48px; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head.compact { align-items: center; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(28px, 5vw, 44px); line-height: 1; margin-bottom: 8px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; margin-bottom: 10px; }
.muted { color: var(--muted); }
.back-link {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 850;
  text-decoration: none;
}
.messages { display: grid; gap: 8px; margin-bottom: 16px; }
.message { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--soft); border: 1px solid var(--line); }
.message.error { border-color: #e1a7a7; background: #fff1f1; }
.message.success { border-color: #a7d9c6; background: #effaf5; }
.form-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--danger);
  border: 1px solid #e1a7a7;
  background: #fff1f1;
  font-weight: 600;
}
.storage-meter { margin: 4px 0 16px; }
.storage-meter__track {
  height: 8px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
  overflow: hidden;
}
.storage-meter__fill { height: 100%; background: var(--accent); border-radius: 999px; }
.storage-meter__fill.is-warning { background: var(--warn); }
.storage-meter__fill.is-full { background: var(--danger); }
.storage-meter__label { margin: 6px 0 0; }
.compact-head {
  align-items: center;
  margin-bottom: 10px;
}
.deadline-panel { margin-bottom: 18px; }
.deadline-list {
  display: grid;
  gap: 8px;
}
.deadline-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 50px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  text-decoration: none;
}
.deadline-item strong,
.deadline-item small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deadline-item small { color: var(--muted); }
.color-swatch {
  display: inline-flex;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.85);
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(29,37,40,.18);
  flex: 0 0 auto;
}
.zone-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.deadline-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.deadline-badge.soon { background: #fff2e0; color: #7a3f00; }
.deadline-badge.today,
.deadline-badge.overdue { background: #fff1f1; color: var(--danger); }
.net-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  margin-left: auto;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
}
.net-status__icon {
  flex: none;
  width: 21px;
  height: 21px;
}
.net-status__icon path,
.net-status__icon line {
  fill: none;
  stroke: #9aa7a3;
  stroke-width: 2.2;
  stroke-linecap: round;
}
.net-status__icon circle { fill: #9aa7a3; }
.net-status__slash { visibility: hidden; }
.net-status[data-state="online"] .net-status__icon path { stroke: #1fa468; }
.net-status[data-state="online"] .net-status__icon circle { fill: #1fa468; }
.net-status[data-state="offline"] .net-status__icon path,
.net-status[data-state="offline"] .net-status__slash { stroke: #d64545; }
.net-status[data-state="offline"] .net-status__icon circle { fill: #d64545; }
.net-status[data-state="offline"] .net-status__slash { visibility: visible; }
.net-status[data-state="offline"] .net-status__icon {
  animation: net-pulse 1.4s ease-in-out infinite;
}
/* Brighter strokes on the dark floating chip of the fullscreen viewer. */
.net-status--floating[data-state="online"] .net-status__icon path { stroke: #38d68f; }
.net-status--floating[data-state="online"] .net-status__icon circle { fill: #38d68f; }
.net-status--floating[data-state="offline"] .net-status__icon path,
.net-status--floating[data-state="offline"] .net-status__slash { stroke: #ff6b6b; }
.net-status--floating[data-state="offline"] .net-status__icon circle { fill: #ff6b6b; }
@keyframes net-pulse {
  50% { opacity: .4; }
}
.net-status__count {
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}
.net-status__count[hidden] { display: none; }
.net-status--floating {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right));
  z-index: 850;
  margin: 0;
  border: 0;
  background: rgba(29,37,40,.88);
  color: #fff;
  box-shadow: 0 8px 22px rgba(15,23,26,.28);
}
.invite-link-box {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #a7d9c6;
  border-radius: 8px;
  background: #effaf5;
}
.invite-link-box input { width: 100%; }
.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.button.secondary { background: var(--ink); }
button:disabled,
.button[aria-disabled="true"] {
  opacity: .6;
  cursor: progress;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.auth-panel {
  max-width: 460px;
  margin: 8vh auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.auth-logo {
  width: 180px;
  height: 66px;
  margin-bottom: 14px;
  object-fit: contain;
}
.auth-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-weight: 800;
}
.form { display: grid; gap: 12px; }
.form.wide { max-width: 680px; }
label, legend { font-weight: 750; font-size: 14px; }
input, select, textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
textarea { resize: vertical; }
.sync-toast {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 950;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent-strong);
  color: #fff;
  font-weight: 750;
  font-size: 14px;
  box-shadow: 0 10px 26px rgba(0,0,0,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.sync-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.password-field {
  display: flex;
  gap: 6px;
  align-items: stretch;
  margin-top: 6px;
}
.password-field input {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}
.password-toggle {
  flex: 0 0 auto;
  min-height: 0;
  padding: 0 12px;
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}
.form-loading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #b8d8ce;
  border-radius: 8px;
  background: #effaf5;
  color: var(--accent-strong);
  font-weight: 850;
}
.spinner {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border: 3px solid rgba(22,115,95,.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.check { display: block; margin: 8px 0; font-weight: 600; }
.check input { width: auto; margin-right: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.profile-panel { max-width: 560px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.stats span, .status-strip span {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}
.status-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.status-strip strong { display: block; color: var(--ink); font-size: 18px; }
.inline-form, .filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}
.inline-mini-form {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto;
  gap: 6px;
  align-items: end;
}
.inline-mini-form input,
.inline-mini-form select {
  margin-top: 0;
}
.inline-mini-form button {
  min-height: 42px;
}
.list { display: grid; gap: 14px; }
.invite-row {
  display: grid;
  grid-template-columns: minmax(180px, .6fr) minmax(220px, 1fr);
  gap: 10px;
  align-items: center;
}
.floor-row { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.plans { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.plan-upload-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}
.add-plan-panel {
  margin-bottom: 16px;
}
.add-plan-panel summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
  cursor: pointer;
  list-style: none;
}
.add-plan-panel summary::-webkit-details-marker { display: none; }
.add-plan-panel[open] summary { margin-bottom: 14px; }
.wide-field { grid-column: span 2; }
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
.plan-card {
  display: grid;
  grid-template-rows: 190px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.plan-thumb {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #c8d0ce;
}
.plan-thumb img,
.plan-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
}
.plan-thumb-placeholder {
  display: grid;
  place-items: center;
  gap: 6px;
  width: 100%;
  height: 100%;
  padding: 18px;
  background: linear-gradient(135deg, #eef4f1, #ffffff);
  color: var(--accent-strong);
  text-align: center;
}
.plan-thumb-placeholder strong {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  color: var(--accent);
  font-size: 22px;
  letter-spacing: 0;
}
.plan-thumb-placeholder small {
  color: var(--muted);
  font-weight: 850;
}
.plan-card-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}
.plan-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.plan-card-head h2 { margin-bottom: 4px; }
.plan-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.plan-card-meta span {
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.plan-settings { position: relative; }
.plan-settings summary {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--soft);
  cursor: pointer;
  list-style: none;
}
.plan-settings summary::-webkit-details-marker { display: none; }
.plan-settings[open] {
  position: static;
}
.plan-settings[open] summary { background: var(--ink); color: #fff; }
.plan-settings form {
  margin-top: 10px;
  min-width: min(320px, calc(100vw - 40px));
}
.plan-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.plan-stack { display: grid; gap: 10px; margin-top: 12px; }
.doc-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.doc-edit[open] { flex-basis: 100%; }
.doc-edit > summary {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  cursor: pointer;
  list-style: none;
  font-weight: 600;
}
.doc-edit > summary::-webkit-details-marker { display: none; }
.doc-edit[open] > summary { background: var(--ink); color: #fff; border-color: var(--ink); }
.doc-edit-form { margin-top: 10px; max-width: 420px; }
.upload-progress {
  margin-top: 12px;
  height: 8px;
  border-radius: 999px;
  background: var(--soft);
  border: 1px solid var(--line);
  overflow: hidden;
}
.upload-progress__fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.15s ease;
}
.plan-manager { margin-top: 14px; }
.floor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.floor-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}
.floor-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.compact-form {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.plan-link {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--soft);
  text-decoration: none;
  font-weight: 800;
}
.plan-edit {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 72px minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: end;
}
.plan-edit input { margin-top: 0; }
.danger-button {
  background: var(--danger);
}
.danger-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.tool-button {
  width: 40px;
  min-height: 40px;
  padding: 0;
  background: var(--ink);
}
.tool-button:disabled {
  cursor: not-allowed;
  opacity: .35;
}
.page-indicator {
  min-width: 56px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

/* --- fullscreen plan viewer ------------------------------------------------ */
body.viewer-fullscreen { background: #c8d0ce; }
body.viewer-fullscreen .topbar { display: none; }
body.viewer-fullscreen .shell { width: 100%; margin: 0; }
body.viewer-fullscreen .messages {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  width: min(92vw, 420px);
  margin: 0;
  pointer-events: none;
  animation: toast-out .4s ease 3.6s forwards;
}
@keyframes toast-out { to { opacity: 0; visibility: hidden; } }
.plan-stage {
  position: fixed;
  inset: 0;
  height: 100dvh;
  overflow: hidden;
  background: #c8d0ce;
  z-index: 20;
}
.viewer-fab {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  z-index: 720;
  width: 48px;
  min-height: 48px;
  padding: 0;
  border-radius: 12px;
  background: rgba(29,37,40,.88);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
  backdrop-filter: blur(6px);
}
.viewer-context {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(70px + env(safe-area-inset-left));
  z-index: 715;
  display: grid;
  gap: 2px;
  max-width: min(62vw, 420px);
  padding: 4px 0;
  text-shadow: 0 1px 3px rgba(255,255,255,.9);
}
.viewer-context strong,
.viewer-context small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viewer-menu {
  position: absolute;
  top: calc(68px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  z-index: 710;
  width: min(86vw, 320px);
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 18px 40px rgba(0,0,0,.25);
  backdrop-filter: blur(8px);
}
.viewer-menu-head { display: grid; gap: 2px; margin-bottom: 12px; }
.viewer-menu-nav { display: grid; gap: 6px; }
.viewer-menu-nav a {
  display: flex;
  align-items: center;
  min-height: 46px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}
.viewer-controls {
  position: absolute;
  right: calc(12px + env(safe-area-inset-right, 0px));
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 700;
  display: grid;
  gap: 8px;
}
.viewer-controls .tool-button,
.viewer-pages .tool-button {
  width: 48px;
  min-height: 48px;
  border-radius: 12px;
  background: rgba(29,37,40,.88);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
}
.viewer-controls .tool-button.is-active {
  background: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(255,255,255,.85), 0 8px 22px rgba(0,0,0,.28);
}
.viewer-pages {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(29,37,40,.88);
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
}
.viewer-pages .tool-button {
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
}
.text-tool-button {
  width: auto;
  min-width: 82px;
  padding: 0 12px;
  font-size: 13px;
}
.viewer-pages .page-indicator { color: #fff; min-width: 44px; }
.emprise-toolbar {
  position: absolute;
  top: calc(72px + env(safe-area-inset-top));
  right: calc(12px + env(safe-area-inset-right, 0px));
  z-index: 690;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: min(92vw, 680px);
  padding: 6px;
  border-radius: 12px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(29,37,40,.12);
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  backdrop-filter: blur(8px);
}
.emprise-toolbar[hidden] { display: none; }
.emprise-toolbar input,
.emprise-toolbar select {
  min-height: 38px;
  max-width: 170px;
  border-radius: 8px;
  font-size: 13px;
}
.emprise-conflicts-only {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--soft);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 800;
}
@media (max-width: 720px) {
  .emprise-toolbar {
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    top: auto;
    bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    overflow-x: auto;
  }
  .emprise-toolbar input,
  .emprise-toolbar select {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
  }
}
@media (hover: none), (pointer: coarse) {
  .viewer-controls #zoomIn,
  .viewer-controls #zoomOut,
  .viewer-controls #rotatePlan {
    display: none;
  }
}
/* Side list, Google-Maps style — tablet/desktop only. */
.viewer-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 640;
  width: 332px;
  display: none;
  flex-direction: column;
  padding-top: calc(72px + env(safe-area-inset-top, 0px));
  background: rgba(255,255,255,.96);
  border-right: 1px solid var(--line);
  box-shadow: 6px 0 24px rgba(0,0,0,.12);
  backdrop-filter: blur(8px);
  transition: transform .2s ease;
}
.viewer-panel.is-collapsed { transform: translateX(-105%); }
.panel-reopen {
  position: absolute;
  display: none;
  top: 50%;
  left: calc(-8px + env(safe-area-inset-left, 0px));
  z-index: 660;
  width: 44px;
  min-width: 44px;
  height: 132px;
  min-height: 132px;
  padding: 0;
  border-radius: 0 12px 12px 0;
  background: rgba(29,37,40,.9);
  color: #fff;
  transform: translateY(-50%);
  box-shadow: 8px 0 22px rgba(0,0,0,.24);
  backdrop-filter: blur(6px);
  overflow: hidden;
  transition: left .2s ease;
}
.viewer-panel:not(.is-collapsed) + .panel-reopen { left: calc(324px + env(safe-area-inset-left, 0px)); }
.panel-reopen span {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center;
}
@media (min-width: 900px) {
  .viewer-panel { display: flex; }
  .panel-reopen:not([hidden]) { display: inline-flex; align-items: center; justify-content: center; }
}
.viewer-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 10px;
}
.panel-collapse {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
}
.panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 14px;
}
.panel-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 8px;
}
.panel-locate {
  flex: 1;
  min-width: 0;
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  text-align: left;
}
.panel-photos {
  grid-column: 1;
  display: flex;
  gap: 6px;
  min-width: 0;
  margin-left: 40px;
}
.panel-photos[hidden] { display: none; }
.panel-photos img {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}
.panel-dot {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  background: var(--danger);
}
.panel-dot.status-Ouvert { background: var(--danger); }
.panel-dot.status-A-traiter { background: var(--warn); }
.panel-dot.status-En-cours { background: var(--blue); }
.panel-dot.status-A-verifier { background: #7a52c7; }
.panel-dot.status-Leve { background: var(--accent); }
.panel-dot.status-Refuse { background: #5b6770; }
.panel-dot.status-Annule { background: #939fa3; }
.panel-dot.type-Constat { border-radius: 8px; }
.panel-dot.type-Remarque { border-style: dashed; }
.panel-dot.type-Non-conformite { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.panel-dot.priority-Haute { box-shadow: 0 0 0 3px var(--ink); }
.panel-dot.priority-Critique { box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--danger); }
.panel-text { display: grid; min-width: 0; }
.panel-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.panel-text small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-open {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}
.pin-marker .pin.pin--flash { animation: pin-flash 1.2s ease; }
@keyframes pin-flash {
  0%, 100% { box-shadow: 0 4px 12px rgba(0,0,0,.35); }
  40% { box-shadow: 0 0 0 12px rgba(47,111,159,.45), 0 4px 12px rgba(0,0,0,.35); }
}

.point-sheet {
  --sheet-system-bottom: max(env(safe-area-inset-bottom, 0px), 44px);
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--visual-viewport-bottom, 0px);
  z-index: 800;
  max-height: min(calc(var(--visual-viewport-height, 100dvh) - 16px), 600px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Generous floor: Android's virtual nav bar overlaps the viewport bottom
     and env(safe-area-inset-bottom) is 0 on some Chrome versions. */
  padding: 14px 16px calc(18px + var(--sheet-system-bottom));
  border-radius: 16px 16px 0 0;
  background: var(--surface);
  box-shadow: 0 -14px 40px rgba(0,0,0,.3);
  transform: translateY(105%);
  transition: transform .22s ease;
}
.point-sheet.is-open { transform: translateY(0); }
/* The submit button stays pinned to the visible bottom of the sheet even
   when the form scrolls, so it can never sit under the system buttons. */
.point-sheet > form.form > button[type="submit"] {
  position: sticky;
  bottom: var(--sheet-system-bottom);
  box-shadow: 0 0 0 6px var(--surface);
}
.point-sheet-head {
  position: sticky;
  top: -14px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -14px -16px 8px;
  padding: 14px 16px 8px;
  background: var(--surface);
}
.point-sheet-head h2 { margin: 0; min-width: 0; font-size: 18px; }
.sheet-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.sheet-head-actions form { margin: 0; }
.sheet-photo-button,
.sheet-danger-button {
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 900;
}
.sheet-photo-button { background: var(--ink); }
.sheet-danger-button { background: var(--danger); }
.sheet-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  text-decoration: none;
}
.sheet-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.point-sheet-head + .sheet-section-photos {
  margin-top: 0;
  padding-top: 8px;
  border-top: 0;
}
.sheet-section h3 { margin-bottom: 8px; }
.emprise-sheet .form-warning {
  margin: 4px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff2e0;
  color: #7a3f00;
  font-weight: 800;
}
.emprise-readonly {
  display: grid;
  gap: 8px;
}
.emprise-readonly h3 {
  margin: 0;
}

/* --- zone sheet: tabbed Zone / Occupations ------------------------------- */
.sheet-tabs {
  display: flex;
  gap: 3px;
  margin: 0 0 12px;
  padding: 3px;
  background: var(--soft);
  border-radius: 10px;
}
.sheet-tab {
  flex: 1;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
}
.sheet-tab.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.sheet-tab[disabled] { opacity: .45; cursor: not-allowed; }
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}
.sheet-tabpanel[hidden] { display: none; }
.sheet-hint { color: var(--muted); font-size: 12.5px; margin: 2px 0 6px; }

.occupations-list { display: grid; gap: 8px; }
.occupations-empty {
  padding: 18px 14px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
}
.occupation-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--line);
  /* The left rail carries the company colour — the at-a-glance "who". */
  border-left: 5px solid var(--occ-color, var(--blue));
  border-radius: 12px;
  background: var(--surface);
}
.occupation-card.has-conflict {
  border-color: #e3b5b5;
  box-shadow: inset 0 0 0 1px #e3b5b5;
}
.occupation-card__main { min-width: 0; display: grid; gap: 3px; }
.occupation-card__title { font-weight: 800; font-size: 14px; }
.occupation-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}
.occupation-card__actions { display: flex; gap: 4px; flex: 0 0 auto; }
.occ-icon-btn {
  width: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}
.occ-icon-btn.danger { background: #fff1f1; color: var(--danger); }

.occupations-add {
  width: 100%;
  margin-top: 10px;
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--accent);
}
.occupation-form {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--soft);
}
.occupation-form .field-row { display: flex; gap: 10px; }
.occupation-form .field-row > label { flex: 1; min-width: 0; }
.occupation-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}
.button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

/* --- report: switchable "Comptes rendus par …" panel (CSS-only tabs) ------ */
.report-breakdown .breakdown-switch {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.report-breakdown .breakdown-switch__label {
  font-weight: 800;
  color: var(--muted);
  margin-right: 4px;
}
.report-breakdown .bk-tab {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.report-breakdown .bk-pane { display: none; }
.report-breakdown .bk-pane-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
/* The checked radio reveals its pane and lights its tab (radios precede both). */
#bk-company:checked ~ .bk-pane--company,
#bk-trade:checked ~ .bk-pane--trade,
#bk-type:checked ~ .bk-pane--type,
#bk-status:checked ~ .bk-pane--status {
  display: block;
}
#bk-company:checked ~ .breakdown-switch label[for="bk-company"],
#bk-trade:checked ~ .breakdown-switch label[for="bk-trade"],
#bk-type:checked ~ .breakdown-switch label[for="bk-type"],
#bk-status:checked ~ .breakdown-switch label[for="bk-status"] {
  background: var(--accent);
  color: #fff;
}
.report-selection {
  display: grid;
  gap: 16px;
}
.report-selection-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.report-selection-head h2 {
  margin: 0 0 4px;
  font-size: 22px;
}
.report-keyword-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(160px, 220px));
  gap: 12px;
}
.report-check-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.report-check-grid fieldset {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.report-check-grid legend {
  padding: 0 4px;
  color: var(--accent);
  font-weight: 900;
}
.report-check-list {
  display: grid;
  gap: 6px;
  max-height: 230px;
  overflow: auto;
}
.report-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 7px;
  border-radius: 7px;
  background: var(--soft);
  font-weight: 800;
}
.report-check span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.report-check small {
  color: var(--muted);
  font-weight: 900;
}

.emprise-handle-icon,
.emprise-label-icon {
  background: none;
  border: 0;
}
.emprise-handle {
  position: relative;
  /* Generous, invisible hit area for comfortable touch dragging... */
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  cursor: move;
  user-select: none;
  touch-action: none;
}
/* ...with a small, semi-transparent visible square. */
.emprise-handle::before {
  content: "";
  width: 15px;
  height: 15px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.4);
  border: 1.5px solid var(--ink);
  box-sizing: border-box;
}
/* Center target dot marks the exact vertex position. */
.emprise-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 3px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}
.emprise-handle:hover::before,
.emprise-handle:focus-visible::before {
  background: rgba(255, 255, 255, 0.85);
  border-width: 2px;
}
.emprise-handle--move::before {
  border-radius: 50%;
  background: rgba(238, 244, 241, 0.6);
}
.emprise-surface,
.emprise-edit-surface {
  cursor: move;
}
.emprise-label {
  display: inline-grid;
  gap: 1px;
  max-width: 180px;
  padding: 4px 7px;
  border-radius: 2px;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  border: 1px solid rgba(29,37,40,.35);
  box-shadow: none;
  line-height: 1.12;
  text-align: left;
  pointer-events: none;
}
.emprise-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.emprise-label small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}
@media (min-width: 821px) {
  .point-sheet {
    --sheet-system-bottom: env(safe-area-inset-bottom, 0px);
    left: auto;
    right: 16px;
    bottom: 16px;
    width: 380px;
    border-radius: 14px;
    padding-bottom: 16px;
    transform: translateY(calc(100% + 24px));
  }
  .point-sheet > form.form > button[type="submit"] { bottom: 0; }
}
.plan-map {
  position: absolute;
  inset: 0;
  background: #c8d0ce;
}
.plan-map.leaflet-container {
  font: inherit;
  outline: none;
}
.plan-stage.is-drawing-zone .plan-map,
.plan-stage.is-drawing-zone .plan-map.leaflet-container {
  cursor: crosshair;
}
.viewer-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 600;
  max-width: min(92%, 420px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(29, 37, 40, .92);
  color: #fff;
  font-size: 13px;
  font-weight: 750;
  text-align: center;
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
  pointer-events: none;
}
/* Pins inside Leaflet div-icons sit statically; the marker handles placement. */
.pin-marker { background: none; border: 0; }
.pin-marker .pin {
  position: static;
  transform: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
}
.pin-marker .pin.preview { cursor: grab; }
.pin-marker .pin.pin--moving {
  box-shadow: 0 0 0 4px rgba(47,111,159,.55), 0 6px 16px rgba(0,0,0,.35);
}
.viewer-error {
  padding: 24px;
  color: var(--danger);
  font-weight: 800;
}
.pin {
  position: absolute;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%) scale(var(--pin-scale));
  transform-origin: center;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: 3px solid #fff;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(0,0,0,.24);
}
.pin.status-Ouvert { background: var(--danger); }
.pin.status-A-traiter { background: var(--warn); }
.pin.status-En-cours { background: var(--blue); }
.pin.status-A-verifier { background: #7a52c7; }
.pin.status-Leve { background: var(--accent); }
.pin.status-Refuse { background: #5b6770; }
.pin.status-Annule { background: #939fa3; }
.pin.type-Constat { border-radius: 8px; }
.pin.type-Remarque { border-style: dashed; }
.pin.type-Non-conformite { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.pin.priority-Basse { opacity: .82; }
.pin.priority-Haute { box-shadow: 0 0 0 3px var(--ink), 0 8px 20px rgba(0,0,0,.24); }
.pin.priority-Critique { box-shadow: 0 0 0 3px var(--ink), 0 0 0 6px var(--danger), 0 8px 20px rgba(0,0,0,.24); }
.pin.preview { background: var(--blue); pointer-events: none; }
.pin.offline-pin {
  background: var(--warn);
  border-style: dashed;
}
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--soft); font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.photos img,
.photo-preview-strip img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.photo-preview-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.photo-preview-strip[hidden] { display: none; }
.camera-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.photo-add-button {
  width: 100%;
  background: var(--ink);
}
.photo-item {
  position: relative;
  display: grid;
  gap: 6px;
  margin: 0;
}
.photo-item figcaption {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.mini-button {
  min-height: 34px;
  padding: 4px;
  background: var(--ink);
}
.photo-delete-button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 999px;
  background: rgba(166,61,61,.95);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 4px 12px rgba(0,0,0,.28);
}
.comment { padding: 10px 0; border-top: 1px solid var(--line); }
.report-plan {
  margin-bottom: 30px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
.report-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.report-plan-preview {
  position: relative;
  width: min(100%, 980px);
  margin: 14px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}
.report-plan-preview img,
.report-plan-preview canvas {
  display: block;
  width: 100%;
  height: auto;
}
.report-pin-layer {
  position: absolute;
  inset: 0;
}
.report-emprise-layer,
.report-emprise-label-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.report-emprise-label {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-grid;
  gap: 1px;
  max-width: 180px;
  padding: 4px 7px;
  border: 1px solid rgba(29,37,40,.35);
  border-radius: 2px;
  background: rgba(255,255,255,.92);
  color: var(--ink);
  box-shadow: none;
  line-height: 1.1;
}
.report-emprise-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}
.report-emprise-label small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}
.report-pin {
  --pin-scale: .74;
  pointer-events: none;
}
.report-sheet-preview {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 14px;
  margin: 14px 0 22px;
  align-items: stretch;
}
.report-sheet-plan {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}
.report-sheet-plan img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: contain;
}
.report-sheet-list {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.report-sheet-list h3 {
  margin-bottom: 2px;
}
.report-point-item {
  display: grid;
  gap: 5px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.report-point-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.report-point-item p {
  margin: 0;
}
.report-photos {
  display: grid;
  grid-template-columns: repeat(2, 88px);
  gap: 6px;
}

/* --- plan crop editor -------------------------------------------------------- */
.crop-area {
  position: relative;
  margin: 10px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
.crop-area img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.crop-box {
  position: absolute;
  border: 2px solid var(--accent-strong);
  /* Dim everything outside the kept area. */
  box-shadow: 0 0 0 9999px rgba(20, 28, 26, .45);
  cursor: move;
}
.crop-handle {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: var(--accent-strong);
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.crop-handle.nw { top: -13px; left: -13px; cursor: nwse-resize; }
.crop-handle.ne { top: -13px; right: -13px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -13px; left: -13px; cursor: nesw-resize; }
.crop-handle.se { bottom: -13px; right: -13px; cursor: nwse-resize; }
.crop-page-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.crop-form > .actions { margin: 14px 0; }
.report-photos img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (max-width: 820px) {
  .topbar {
    align-items: center;
    padding: 8px 10px;
  }
  .brand img { width: 140px; height: 50px; }
  .menu-toggle { display: inline-flex; }
  .main-nav {
    position: absolute;
    top: calc(100% + 6px);
    left: 10px;
    right: 10px;
    z-index: 30;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255,255,255,.98);
    box-shadow: 0 16px 34px rgba(0,0,0,.16);
    transform-origin: top right;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px) scale(.98);
    transition: opacity .16s ease, transform .16s ease;
  }
  .main-nav.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }
  .nav-user {
    padding: 8px 10px 2px;
    color: var(--muted);
  }
  .main-nav a,
  .main-nav .link-button {
    width: 100%;
    min-height: 48px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 12px;
    background: var(--soft);
    color: var(--ink);
    text-align: left;
  }
  .nav-form { margin: 0; }
  .shell { width: min(100% - 18px, 1180px); margin-top: 14px; }
  .page-head, .detail-grid { grid-template-columns: 1fr; display: grid; }
  .page-head { gap: 10px; }
  .page-head .actions,
  .page-head > .button,
  .page-head > a.button { width: 100%; }
  .actions .button { flex: 1 1 150px; }
  .button, button { min-height: 46px; }
  .inline-form, .filters { grid-template-columns: 1fr; }
  .invite-row { grid-template-columns: 1fr; }
  .plan-upload-form { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
  .plan-card { grid-template-rows: 170px auto; }
  .plan-edit { grid-template-columns: 1fr; }
  .report-selection-head,
  .report-keyword-row,
  .report-check-grid,
  .report-sheet-preview {
    grid-template-columns: 1fr;
    display: grid;
  }
  .auth-panel { margin: 18px auto; padding: 18px; }
  h1 { font-size: 30px; line-height: 1.05; }
  .card, .panel { padding: 14px; }
  .photos { grid-template-columns: 1fr 1fr; }
}

@media print {
  body {
    background: #fff;
    padding: 0;
  }
  .topbar,
  .report-actions .actions,
  .report-filters,
  .report-filter-note,
  .report-companies,
  .report-breakdown,
  .net-status,
  .messages {
    display: none !important;
  }
  .shell {
    width: 100%;
    margin: 0;
  }
  /* Keep the plan image whole and repeat table headers, but never force the
     whole (often page-tall) plan block onto one page — that only pushed point
     rows to overflow and split. Protect the rows themselves instead. */
  .report-plan-preview {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .report-table-wrap thead {
    display: table-header-group;
  }
  .report-table-wrap tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .report-table-wrap table {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .status-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .status-strip span { min-height: 64px; }
  .table-wrap {
    overflow: visible;
    background: transparent;
    border: 0;
  }
  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  thead { display: none; }
  tr {
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    overflow: hidden;
  }
  td {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }
  td:last-child { border-bottom: 0; }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }
  td[colspan] {
    display: block;
  }
  td[colspan]::before { content: ""; }
}
