/* My Drawings — mobile-first, app-like. Desktop expands; it does not drive the layout. */

:root {
  --md-bg: #070b14;
  --md-bg-2: #0b1220;
  --md-surface: #121a28;
  --md-card: #171f2e;
  --md-card-press: #1d2738;
  --md-line: rgba(148, 163, 184, 0.16);
  --md-text: #f1f5f9;
  --md-muted: #94a3b8;
  --md-faint: #64748b;
  --md-accent: #38bdf8;
  --md-accent-2: #22c55e;
  --md-danger: #f87171;
  --md-warn: #fbbf24;
  --md-touch: 48px;
  --md-radius: 14px;
  --md-header: 56px;
  --md-safe-t: env(safe-area-inset-top, 0px);
  --md-safe-b: env(safe-area-inset-bottom, 0px);
  --md-safe-l: env(safe-area-inset-left, 0px);
  --md-safe-r: env(safe-area-inset-right, 0px);
  --md-pad: 16px;
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--md-bg);
  color: var(--md-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  min-height: 100svh;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

img { max-width: 100%; }

.md-app {
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 480px at 50% -120px, rgba(56, 189, 248, 0.12), transparent 60%),
    var(--md-bg);
}

.md-screen { display: none; flex: 1; min-height: 0; flex-direction: column; }
.md-screen.is-active { display: flex; }

.md-icon {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.md-icon-lg { width: 26px; height: 26px; }

/* ---------- Boot splash ---------- */
.md-boot {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--md-bg);
  padding-bottom: 8vh;
}
.md-boot.is-done { display: none; }
.md-boot-mark {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(160deg, #0ea5e9, #22c55e);
  display: grid;
  place-items: center;
  color: #041018;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: 1.35rem;
}
.md-boot p { margin: 0; color: var(--md-muted); font-size: 0.92rem; }
.md-spin {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(148, 163, 184, 0.25);
  border-top-color: var(--md-accent);
  border-radius: 50%;
  animation: md-spin 0.7s linear infinite;
}
@keyframes md-spin { to { transform: rotate(360deg); } }

/* ---------- PIN ---------- */
.md-pin {
  padding: calc(28px + var(--md-safe-t)) var(--md-pad) calc(24px + var(--md-safe-b));
  align-items: center;
  justify-content: center;
  text-align: center;
}
.md-pin-brand {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 28px;
}
.md-pin h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 600;
}
.md-pin-hint {
  margin: 0 0 28px;
  color: var(--md-muted);
  font-size: 0.92rem;
}
.md-pin-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 12px;
}
.md-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.55);
  background: transparent;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}
.md-dot.is-on {
  background: var(--md-text);
  border-color: var(--md-text);
}
.md-pin-wrap { position: relative; width: min(280px, 100%); }
.md-pin-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 52px;
  font-size: 24px;
  letter-spacing: 12px;
  text-align: center;
}
.md-pin-tap {
  height: 52px;
  border-radius: var(--md-radius);
  border: 1px solid var(--md-line);
  background: var(--md-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--md-faint);
  font-size: 0.85rem;
  margin-bottom: 20px;
}
.md-pin.is-shake .md-pin-dots { animation: md-shake 0.38s ease; }
@keyframes md-shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.md-register {
  text-align: left;
}
.md-register .md-pin-brand,
.md-register h2,
.md-register .md-pin-hint {
  text-align: center;
}
.md-reg-form {
  width: min(320px, 100%);
  margin: 0 auto;
}
.md-reg-form .mg-field input {
  width: 100%;
}
.md-register .md-btn-primary {
  width: 100%;
  margin-top: 4px;
  box-sizing: border-box;
}
.md-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.md-choice label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 72px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--md-line);
  background: var(--md-surface);
  cursor: pointer;
}
.md-choice input { accent-color: var(--md-accent); }
.md-choice strong { font-size: 0.92rem; }
.md-choice span { font-size: 0.75rem; color: var(--md-muted); }
.md-file-name { font-size: 0.8rem; color: var(--md-muted); }
.md-success-code {
  margin: 12px 0 18px;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.md-pin-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-top: 10px;
}
.md-pin-actions[hidden] { display: none !important; }
.md-pin-actions-quiet {
  margin-top: 4px;
  opacity: 0.72;
}
.md-pin-actions-quiet .md-link { font-size: 0.8rem; }
.md-advanced {
  width: min(360px, 100%);
  margin: 18px auto 8px;
  text-align: left;
  color: var(--md-muted);
}
.md-advanced summary {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--md-muted);
}
.md-advanced .md-success-code { font-size: 1.4rem; }
#cs-done { width: min(360px, 100%); }
#cs-done .md-btn { margin-top: 10px; }
.md-floor .md-pin-hint { margin-bottom: 16px; }
.md-floor-search {
  width: min(320px, 100%);
  margin: 0 0 14px;
}
.md-floor-search[hidden] { display: none !important; }
.md-floor-grid {
  width: min(320px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-height: min(52vh, 420px);
  overflow: auto;
}
.md-floor-btn {
  min-height: 56px;
  padding: 12px 10px;
  border-radius: 14px;
  border: 1px solid var(--md-line);
  background: var(--md-surface);
  color: var(--md-text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.md-floor-btn:active { background: rgba(255, 255, 255, 0.08); }
.md-floor-btn.is-on {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.14);
  color: #e0f2fe;
}
.md-floor-btn.md-floor-wide {
  grid-column: 1 / -1;
}
.md-link {
  background: none;
  border: none;
  color: var(--md-muted);
  font-size: 0.84rem;
  min-height: 40px;
  padding: 0 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
a.md-link { color: var(--md-accent); }
.md-admin-link {
  margin-top: 28px;
  text-align: center;
}
.md-admin-link button {
  background: none;
  border: none;
  color: var(--md-faint);
  font-size: 0.78rem;
  min-height: 40px;
  padding: 0 10px;
}
.md-error {
  min-height: 1.2em;
  margin: 0 0 16px;
  color: var(--md-danger);
  font-size: 0.88rem;
}
.md-btn {
  min-height: var(--md-touch);
  min-width: var(--md-touch);
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.md-btn-primary {
  width: min(280px, 100%);
  background: linear-gradient(135deg, #0ea5e9, #22c55e);
  color: #041018;
  text-decoration: none;
}
.md-btn-primary:disabled {
  opacity: 0.4;
}
.md-btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--md-text);
  border: 1px solid var(--md-line);
}
.md-btn-block { width: 100%; }
.md-demo {
  margin-top: 22px;
  font-size: 0.78rem;
  color: var(--md-faint);
}

/* ---------- Header ---------- */
.md-header {
  flex: 0 0 auto;
  padding: calc(8px + var(--md-safe-t)) 10px 8px;
  padding-left: calc(10px + var(--md-safe-l));
  padding-right: calc(10px + var(--md-safe-r));
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: calc(var(--md-header) + var(--md-safe-t));
  border-bottom: 1px solid var(--md-line);
  background: rgba(7, 11, 20, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.md-header-text { flex: 1; min-width: 0; }
.md-header-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.md-header-sub {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--md-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.md-header-sep {
  color: var(--md-faint);
  flex: 0 0 auto;
}
.md-floor-chip {
  flex: 0 0 auto;
  margin: 0;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.12);
  color: #e0f2fe;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.3;
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.md-floor-chip:active { background: rgba(56, 189, 248, 0.22); }
#project-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.md-icon-btn {
  width: var(--md-touch);
  height: var(--md-touch);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--md-text);
  flex: 0 0 auto;
}
.md-icon-btn:active { background: rgba(255, 255, 255, 0.08); }
.md-update-btn {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.32);
  color: #e0f2fe;
}
.md-update-btn:active { background: rgba(56, 189, 248, 0.24); }
.md-update-btn:disabled { opacity: 0.55; }
.md-update-btn[hidden] { display: none !important; }
#btn-switch-site {
  background: rgba(167, 139, 250, 0.14);
  border-color: rgba(167, 139, 250, 0.36);
  color: #ede9fe;
}
.md-offline {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--md-warn);
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 999px;
  padding: 4px 8px;
  margin-right: 2px;
  white-space: nowrap;
}
.md-offline.is-on { display: inline-flex; }
.md-offline i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--md-warn);
}

/* ---------- List body ---------- */
.md-main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px var(--md-pad) calc(20px + var(--md-safe-b));
  padding-left: calc(var(--md-pad) + var(--md-safe-l));
  padding-right: calc(var(--md-pad) + var(--md-safe-r));
}

.md-search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--md-touch);
  padding: 0 14px;
  border-radius: 14px;
  background: var(--md-surface);
  border: 1px solid var(--md-line);
  margin-bottom: 12px;
}
.md-search svg { color: var(--md-muted); flex: 0 0 auto; }
.md-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 16px; /* iOS: avoid zoom */
  height: var(--md-touch);
}
.md-search input::placeholder { color: var(--md-faint); }

.md-cats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin: 0 -4px 14px;
  padding: 0 4px 4px;
  scroll-snap-type: x proximity;
}
.md-cats::-webkit-scrollbar { display: none; }
.md-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--md-line);
  background: var(--md-surface);
  color: var(--md-muted);
  font-size: 0.84rem;
  font-weight: 600;
}
.md-chip[data-tone] { color: #f8fafc; }
.md-chip.is-on:not([data-tone]) {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
}
.md-chip.is-on[data-tone] {
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42), 0 0 0 2px rgba(255, 255, 255, 0.16);
  filter: brightness(1.1);
}

.md-list-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 12px;
}
.md-list-tool-btns {
  display: flex;
  gap: 8px;
}
.md-list-tool-btns .md-btn-all { flex: 1; min-width: 0; }
.md-btn-add {
  color: #dcfce7;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.3);
}
.md-btn-add:active { background: rgba(34, 197, 94, 0.22); }
.md-btn-add[hidden] { display: none !important; }
.md-count {
  margin: 0;
  font-size: 0.78rem;
  color: var(--md-faint);
}
.md-btn-all {
  min-height: 44px;
  width: 100%;
  border-radius: 12px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  color: #e0f2fe;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.28);
}
.md-btn-all:active { background: rgba(56, 189, 248, 0.22); }
.md-btn-all.is-ready {
  color: var(--md-accent-2);
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.28);
}
.md-btn-all.is-busy { color: var(--md-accent); }
.md-btn-all:disabled { opacity: 0.45; }

.md-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.md-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--md-card);
  border: 1px solid var(--md-line);
  border-radius: var(--md-radius);
  padding: 14px 10px 14px 14px;
}
.md-card:active { background: var(--md-card-press); }
.md-card-body { flex: 1; min-width: 0; }
.md-card-title {
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 4px;
}
.md-card-num {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 550;
  line-height: 1.3;
  color: var(--md-muted);
}
.md-card-meta {
  margin: 0;
  font-size: 0.78rem;
  color: var(--md-muted);
}
.md-dl {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--md-muted);
  background: rgba(255, 255, 255, 0.04);
}
.md-dl.is-ready { color: var(--md-accent-2); background: rgba(34, 197, 94, 0.12); }
.md-dl.is-busy { color: var(--md-accent); font-size: 0.68rem; font-weight: 700; }

.md-empty {
  text-align: center;
  padding: 42px 12px;
  color: var(--md-muted);
}
.md-empty h3 { margin: 0 0 6px; color: var(--md-text); font-size: 1rem; }
.md-empty p { margin: 0; font-size: 0.88rem; }

.md-install {
  display: none;
  margin: 14px 0 4px;
  padding: 12px 14px;
  border-radius: var(--md-radius);
  background: var(--md-surface);
  border: 1px solid var(--md-line);
  gap: 10px;
  align-items: center;
}
.md-install.is-on { display: flex; }
.md-install p { margin: 0; flex: 1; font-size: 0.86rem; line-height: 1.35; }
.md-install strong { display: block; font-size: 0.92rem; margin-bottom: 2px; }

/* ---------- Drawing Viewer ---------- */
.md-viewer {
  background: #05080f;
  position: relative;
}
.dv-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(6px + var(--md-safe-t)) 6px 6px;
  padding-left: calc(6px + var(--md-safe-l));
  padding-right: calc(6px + var(--md-safe-r));
  background: linear-gradient(180deg, rgba(5, 8, 15, 0.92), rgba(5, 8, 15, 0.55) 70%, transparent);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.dv-top-text { flex: 1; min-width: 0; }
.dv-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(255,255,255,0.028) 1px, transparent 1px) 0 0 / 28px 28px,
    #070b12;
}
.dv-plane {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  background: #fff;
}
.dv-plane canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
}
.dv-detail {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transform-origin: 0 0;
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: transparent;
}
.dv-detail.is-on { opacity: 1; }
.dv-detail-hud {
  position: absolute;
  left: 8px;
  bottom: 58px;
  z-index: 7;
  margin: 0;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(2, 6, 14, 0.72);
  color: #7dd3fc;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.dv-edge-hit {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 28px;
  z-index: 4;
  touch-action: none;
  /* Keep pan usable; only captures swipes that start on this edge */
}
.dv-wt-peek {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 132px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transform: translateX(100%);
  background: linear-gradient(270deg, rgba(7, 14, 26, 0.94), rgba(7, 14, 26, 0.72) 70%, transparent);
  border-left: 1px solid rgba(56, 189, 248, 0.28);
  transition: none;
}
.dv-wt-peek.is-armed {
  /* driven by --dv-wt-peek via JS */
  transform: translateX(calc(100% - var(--dv-wt-peek, 0px)));
}
.dv-wt-peek-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7dd3fc;
}
.dv-status {
  position: absolute;
  inset: 0;
  z-index: 3;
  margin: 0;
  display: grid;
  place-items: center;
  color: var(--md-muted);
  font-size: 0.92rem;
  pointer-events: none;
}
.dv-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 52px;
  padding: 6px 8px calc(8px + var(--md-safe-b));
  padding-left: calc(8px + var(--md-safe-l));
  padding-right: calc(8px + var(--md-safe-r));
  background: linear-gradient(0deg, rgba(5, 8, 15, 0.94), rgba(5, 8, 15, 0.55) 75%, transparent);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.dv-bar .md-icon-btn { width: 44px; height: 44px; }
.dv-bar-spacer { flex: 1; }
.dv-page {
  min-width: 3.2rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--md-muted);
}
.dv-bar .md-icon-btn:disabled { opacity: 0.28; }
.md-viewer.is-chrome-hidden .dv-top,
.md-viewer.is-chrome-hidden .dv-bar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
}
.md-viewer.is-chrome-hidden .dv-bar { transform: translateY(8px); }
.md-viewer.is-fs .dv-top { padding-top: calc(4px + var(--md-safe-t)); }

.md-sheet-dl {
  display: grid;
  grid-template-columns: 7.2rem 1fr;
  gap: 6px 10px;
  margin: 8px 12px 4px;
  font-size: 0.88rem;
}
.md-sheet-dl dt { color: var(--md-faint); margin: 0; }
.md-sheet-dl dd { margin: 0; font-weight: 600; }

/* ---------- Manage ---------- */
.mg-block { margin-bottom: 22px; }
.mg-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.mg-users-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 650;
  color: #5b6573;
  flex: 0 0 auto;
}
.mg-users-filter span { white-space: nowrap; }
.mg-users-filter select {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #d7dee8;
  background: #fff;
  color: #1b2433;
  font: inherit;
  font-weight: 650;
}
.mg-block-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.mg-block h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
}
.mg-user-detail {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--md-line);
  background: var(--md-surface);
  font-size: 0.9rem;
  line-height: 1.45;
}
.mg-user-detail p { margin: 0 0 4px; }
.mg-user-detail p:last-child { margin-bottom: 0; }
.mg-user-detail strong { font-weight: 700; }
.mg-main-account {
  margin: 14px 0 16px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid #dbe4ee;
  background: #f4f7fb;
}
.mg-main-account-label {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}
.mg-main-account-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1b2433;
}
.mg-main-account-email {
  margin: 2px 0 0;
  font-size: 0.88rem;
  color: #5b6573;
}
.mg-users-table-wrap {
  margin-top: 8px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.mg-users-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e6ebf2;
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.88rem;
}
.mg-users-table.is-wide { min-width: 1140px; }
.mg-users-table th,
.mg-users-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid #eef2f6;
  vertical-align: middle;
}
.mg-users-table th {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  background: #f8fafc;
}
.mg-users-table tbody tr:last-child td { border-bottom: 0; }
.mg-users-table tbody tr.is-closed { background: #fff7f7; }
.mg-users-table td strong {
  display: block;
  font-weight: 700;
  color: #1b2433;
}
.mg-user-email {
  display: block;
  margin-top: 2px;
  color: #64748b;
  font-size: 0.82rem;
  word-break: break-word;
}
.mg-user-access {
  min-width: 168px;
}
.mg-user-access .mg-user-days,
.mg-user-access .mg-user-btn,
.mg-user-access .mg-user-closed {
  display: block;
  width: 100%;
  margin: 0 0 6px;
}
.mg-user-access .mg-user-btn:last-child,
.mg-user-access .mg-user-days:last-child { margin-bottom: 0; }
.mg-user-days {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #d7dee8;
  background: #fff;
  color: #1b2433;
  font: inherit;
}
.mg-user-btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 0;
  background: #eef4f8;
  color: #1b4f72;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.mg-user-btn.is-danger {
  background: #fde8e8;
  color: #b91c1c;
}
.mg-user-closed {
  font-weight: 700;
  color: #b45309;
  line-height: 1.35;
}
.mg-user-admin {
  display: block;
  margin: 0 0 6px;
  font-weight: 700;
  color: #0f766e;
}
.mg-host-code {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed var(--md-line);
  background: var(--md-surface);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
}
.mg-cats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.mg-cat-row,
.mg-group {
  border: 1px solid transparent;
  color: var(--md-text);
}
.mg-cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 8px 8px 8px 14px;
  border-radius: 14px;
}
.mg-cat-name {
  font-weight: 750;
  font-size: 0.95rem;
  min-width: 0;
}
.mg-cat-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}
.mg-cat-actions button {
  min-width: 40px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 10px;
  background: rgba(7, 11, 20, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.82rem;
  font-weight: 700;
}
.mg-cat-actions button:disabled {
  opacity: 0.32;
  cursor: default;
}
.mg-search { margin-bottom: 14px; }
.mg-group {
  margin-bottom: 12px;
  padding: 8px;
  border-radius: 16px;
}
.mg-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 10px;
}
.mg-group-head h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.mg-group-head span {
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(241, 245, 249, 0.72);
}
.mg-group .mg-item {
  background: rgba(7, 11, 20, 0.42);
  border-color: rgba(255, 255, 255, 0.08);
}
.md-chip[data-tone="0"],
.mg-cat-row[data-tone="0"],
.mg-group[data-tone="0"] {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.42), rgba(14, 116, 144, 0.16) 58%, rgba(15, 23, 42, 0.55));
  border-color: rgba(56, 189, 248, 0.32);
}
.md-chip[data-tone="1"],
.mg-cat-row[data-tone="1"],
.mg-group[data-tone="1"] {
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.38), rgba(6, 95, 70, 0.18) 58%, rgba(15, 23, 42, 0.55));
  border-color: rgba(52, 211, 153, 0.3);
}
.md-chip[data-tone="2"],
.mg-cat-row[data-tone="2"],
.mg-group[data-tone="2"] {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.4), rgba(91, 33, 182, 0.18) 58%, rgba(15, 23, 42, 0.55));
  border-color: rgba(167, 139, 250, 0.32);
}
.md-chip[data-tone="3"],
.mg-cat-row[data-tone="3"],
.mg-group[data-tone="3"] {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.38), rgba(146, 64, 14, 0.2) 58%, rgba(15, 23, 42, 0.55));
  border-color: rgba(251, 191, 36, 0.32);
}
.md-chip[data-tone="4"],
.mg-cat-row[data-tone="4"],
.mg-group[data-tone="4"] {
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.4), rgba(157, 23, 77, 0.18) 58%, rgba(15, 23, 42, 0.55));
  border-color: rgba(244, 114, 182, 0.3);
}
.md-chip[data-tone="5"],
.mg-cat-row[data-tone="5"],
.mg-group[data-tone="5"] {
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.42), rgba(49, 46, 129, 0.22) 58%, rgba(15, 23, 42, 0.55));
  border-color: rgba(129, 140, 248, 0.32);
}
.md-chip[data-tone="6"],
.mg-cat-row[data-tone="6"],
.mg-group[data-tone="6"] {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.38), rgba(17, 94, 89, 0.2) 58%, rgba(15, 23, 42, 0.55));
  border-color: rgba(45, 212, 191, 0.3);
}
.md-chip[data-tone="7"],
.mg-cat-row[data-tone="7"],
.mg-group[data-tone="7"] {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.4), rgba(154, 52, 18, 0.2) 58%, rgba(15, 23, 42, 0.55));
  border-color: rgba(251, 146, 60, 0.32);
}
.mg-add-row {
  display: flex;
  gap: 8px;
}
.mg-add-row input,
.mg-field input,
.mg-field select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--md-line);
  background: var(--md-surface);
  color: var(--md-text);
  padding: 0 12px;
  font-size: 16px;
}
.mg-field input:disabled,
.mg-field select:disabled { opacity: 0.5; }
.mg-field select { appearance: auto; }
.mg-add-row .md-btn { width: auto; min-width: 72px; }
.mg-add-dwg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.14);
  color: #e0f2fe;
  font-weight: 700;
  font-size: 0.84rem;
}
.mg-item {
  background: var(--md-card);
  border: 1px solid var(--md-line);
  border-radius: var(--md-radius);
  padding: 12px;
  margin-bottom: 8px;
}
.mg-item.is-on {
  border-color: #1b4f72;
  box-shadow: inset 0 0 0 1px #1b4f72;
}
.mg-item-title { margin: 0 0 2px; font-weight: 800; font-size: 1.05rem; }
.mg-item-num { margin: 0 0 4px; font-size: 0.9rem; color: var(--md-muted); }
.mg-item-meta { margin: 0 0 10px; font-size: 0.76rem; color: var(--md-muted); }
.mg-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mg-item-actions button {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 650;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--md-line);
}
.mg-item-actions .is-preview {
  background: rgba(167, 139, 250, 0.14);
  border-color: rgba(167, 139, 250, 0.3);
  color: #ede9fe;
}
.mg-item-actions .is-update {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.3);
  color: #e0f2fe;
}
.mg-item-actions .is-danger { color: var(--md-danger); }
.mg-form h2 { margin: 0 0 6px; font-size: 1.05rem; }
.mg-form-note { margin: 0 0 14px; color: var(--md-muted); font-size: 0.84rem; line-height: 1.4; }
.mg-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.mg-field[hidden] { display: none !important; }
.mg-field span { font-size: 0.78rem; color: var(--md-faint); font-weight: 650; }
.mg-field input[type="file"] { padding: 10px; }
.mg-floors { border: 0; padding: 0; margin: 0 0 12px; }
.mg-loc-picker { position: relative; }
.mg-loc-picker input { width: 100%; }
.mg-loc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}
.mg-loc-chips:empty { display: none; }
.mg-loc-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 6px 8px 6px 10px;
  border-radius: 999px;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.22);
  color: #0c4a6e;
  font-size: 0.8rem;
  font-weight: 650;
}
.mg-loc-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 650;
  color: inherit;
}
.mg-loc-chip button {
  flex: none;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
}
.mg-loc-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 4px);
  z-index: 8;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid #d7dee8;
  background: #fff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
}
.mg-loc-suggest button {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #1b2433;
  font: inherit;
  font-size: 0.9rem;
}
.mg-loc-suggest button.is-on,
.mg-loc-suggest button:hover { background: #e0f2fe; }
.mg-site-form { display: flex; flex-direction: column; gap: 0; margin-bottom: 12px; }
.mg-site-form[hidden] { display: none !important; }
.mg-floors-hint {
  font-size: 0.72rem !important;
  font-weight: 500 !important;
  color: var(--md-faint);
}
.mg-file-name { font-size: 0.78rem; color: var(--md-muted); }
.mg-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.mg-form-actions .md-btn-primary { width: auto; flex: 1; }
.mg-form-actions .md-btn-ghost { width: auto; }

/* ---------- Activity ---------- */
.md-activity { padding-bottom: 24px; }
.md-activity-loading {
  margin: 24px 0;
  color: var(--md-muted);
  font-size: 0.9rem;
}
.md-activity-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--md-line);
}
.md-activity-item p {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.45;
  font-weight: 500;
}

/* ---------- Sheets ---------- */
.md-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.5);
}
.md-backdrop.is-on { display: block; }
.md-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  background: #141c2b;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  padding: 10px 12px calc(16px + var(--md-safe-b));
  transform: translateY(110%);
  transition: transform 0.22s ease;
}
.md-sheet.is-on { transform: translateY(0); }
.md-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.35);
  margin: 4px auto 10px;
}
.md-sheet h3 {
  margin: 0 12px 8px;
  font-size: 0.95rem;
}
.md-sheet-item {
  width: 100%;
  min-height: var(--md-touch);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: 12px;
  text-align: left;
  font-size: 0.95rem;
}
.md-sheet-item:active { background: rgba(255, 255, 255, 0.06); }
.md-sheet-item.is-on { color: #e0f2fe; }
.md-sheet-item:disabled { opacity: 0.55; }
.md-sheet-item.is-danger { color: var(--md-danger); }
.md-sheet-note {
  margin: 8px 12px 0;
  font-size: 0.8rem;
  color: var(--md-muted);
  line-height: 1.4;
}

/* ---------- Wall Types catalog ---------- */
.wt-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 24px;
}
.wt-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  background: var(--md-card);
  border: 1px solid var(--md-line);
  border-radius: var(--md-radius);
  padding: 12px 14px;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.wt-card:active { background: var(--md-card-press); }
.wt-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.28);
  color: #7dd3fc;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.wt-code.is-lining {
  background: rgba(167, 139, 250, 0.14);
  border-color: rgba(167, 139, 250, 0.28);
  color: #c4b5fd;
}
.wt-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.3;
}
.wt-card-chevron {
  width: 18px;
  height: 18px;
  stroke: var(--md-faint);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wt-detail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 28px;
}
.wt-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.wt-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--md-line);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--md-muted);
}
.wt-pill.is-system {
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.28);
  background: rgba(56, 189, 248, 0.12);
}
.wt-section {
  background: var(--md-card);
  border: 1px solid var(--md-line);
  border-radius: var(--md-radius);
  padding: 14px;
}
.wt-section h2 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--md-faint);
}
.wt-perf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.wt-perf-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
}
.wt-perf-item dt {
  margin: 0;
  font-size: 0.72rem;
  color: var(--md-faint);
  font-weight: 650;
}
.wt-perf-item dd {
  margin: 4px 0 0;
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--md-text);
  line-height: 1.25;
  word-break: break-word;
}
.wt-build-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
}
.wt-build-list > div {
  display: grid;
  gap: 2px;
}
.wt-build-list dt {
  margin: 0;
  font-size: 0.72rem;
  color: var(--md-faint);
  font-weight: 650;
}
.wt-build-list dd {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--md-text);
}
.wt-detail-figure {
  margin: 0;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--md-line);
  border-radius: var(--md-radius);
  overflow: hidden;
  background: #0a101c;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: zoom-in;
}
.wt-detail-figure img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
}
.wt-detail-caption {
  display: block;
  padding: 10px 12px;
  font-size: 0.78rem;
  color: var(--md-muted);
}
.wt-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(2, 6, 14, 0.96);
  display: flex;
  flex-direction: column;
  touch-action: none;
  overscroll-behavior: none;
}
.wt-lightbox[hidden] { display: none !important; }
.wt-lightbox-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: calc(8px + var(--md-safe-t)) 10px 8px;
  background: rgba(2, 6, 14, 0.88);
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
}
.wt-lightbox-hint {
  margin: 0;
  padding-left: 6px;
  font-size: 0.78rem;
  color: var(--md-muted);
  min-width: 0;
}
.wt-lightbox-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}
.wt-lightbox-actions .md-icon-btn {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}
.wt-lightbox-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}
.wt-lightbox-stage.is-dragging { cursor: grabbing; }
.wt-lightbox-plane {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
}
.wt-lightbox-plane img {
  display: block;
  width: auto;
  height: auto;
  max-width: none;
  background: #fff;
  border-radius: 4px;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* ---------- Desktop / tablet expansion ---------- */
@media (min-width: 768px) {
  .md-main { padding-top: 16px; }
  .md-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .md-pin-brand { font-size: 1.7rem; }
}

@media (min-width: 1100px) {
  .md-list { grid-template-columns: 1fr 1fr 1fr; }
  .md-main {
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
  }
}

@media (display-mode: standalone) {
  .md-install { display: none !important; }
}

/* ---------- Company admin dashboard ---------- */
.md-app:has(#screen-manage.is-active) {
  background: #eef1f5;
}
.ad-screen {
  background: #eef1f5;
  color: #1a2332;
  width: 100%;
}
.ad-screen.is-active {
  display: flex !important;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: #eef1f5;
}
.ad-shell {
  display: flex;
  flex: 1 1 auto;
  align-items: stretch;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: #eef1f5;
}
.ad-sidebar {
  display: none;
  flex: 0 0 176px;
  width: 176px;
  background: #1b2433;
  color: #fff;
  padding: calc(18px + var(--md-safe-t)) 12px calc(18px + var(--md-safe-b));
  flex-direction: column;
  align-items: stretch;
  z-index: 4;
}
.ad-logo {
  width: 72px;
  height: 72px;
  margin: 4px auto 18px;
  color: #fff;
  display: grid;
  place-items: center;
}
.ad-logo svg { width: 58px; height: 58px; }
.ad-menu-label {
  margin: 0 10px 10px;
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: rgba(255,255,255,0.55);
}
.ad-nav { display: flex; flex-direction: column; gap: 2px; }
.ad-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  color: #fff;
  padding: 10px 10px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.ad-nav button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ad-nav button span { font-size: 0.72rem; font-weight: 600; }
.ad-nav button.is-on,
.ad-nav button:hover { background: rgba(255,255,255,0.1); }
.ad-nav-line {
  display: block;
  height: 1px;
  margin: 10px 8px;
  background: rgba(255,255,255,0.18);
}
.ad-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.ad-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: calc(10px + var(--md-safe-t)) 22px 10px 20px;
  border-bottom: 1px solid #edf0f4;
}
.ad-burger {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #1b2433;
}
.ad-burger svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}
.ad-welcome {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: #2b3444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ad-company {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: #5b6573;
  white-space: nowrap;
}
.ad-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: #1b2433;
  overflow: hidden;
}
.ad-avatar svg {
  width: 22px;
  height: 22px;
}
.ad-content {
  flex: 1 1 auto;
  overflow: auto;
  padding: 22px 22px calc(24px + var(--md-safe-b));
  background: #f7f8fb;
}
.ad-panel { min-height: 280px; }
.ad-home {
  background: #fff;
  border-radius: 8px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}
.ad-role {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #5b6573;
}
.ad-home-site {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1b2433;
}
.ad-home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.ad-home-actions .md-btn { width: auto; }
.ad-home-steps {
  margin: 4px 0 0;
  padding-left: 1.2em;
  color: #5b6573;
  font-size: 0.92rem;
  line-height: 1.55;
}
.ad-home-steps[hidden] { display: none; }
.ad-stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  color: #1b2433;
}
.ad-stats strong {
  display: inline-block;
  min-width: 2.2em;
  font-size: 1.7rem;
  font-weight: 800;
}
.ad-access-code {
  margin: 18px 0 22px;
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #1b2433;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all;
}
#mg-access-input {
  max-width: 280px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
}
#mg-access-error.is-ok {
  color: #0f766e;
}
.ad-settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.ad-settings-actions .md-btn { width: auto; }
.ad-scrim {
  position: fixed;
  inset: 0;
  background: rgba(7, 11, 20, 0.45);
  z-index: 3;
}
.ad-screen .mg-block h2 { color: #1b2433; }
.ad-screen .mg-form-note { color: #64748b; }
.ad-screen .mg-add-row input,
.ad-screen .mg-field input,
.ad-screen .mg-field select,
.ad-screen .md-search,
.ad-screen .mg-loc-picker input {
  background: #fff;
  color: #1b2433;
  border: 1px solid #d7dee8;
}
.wt-perf-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}
.wt-layer-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.wt-layer-row input {
  flex: 1;
  min-width: 0;
}
.wt-layer-row button {
  flex: 0 0 auto;
  min-width: 36px;
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: #fde8e8;
  color: #b91c1c;
  font-size: 1.1rem;
  cursor: pointer;
}
#wt-layers { margin-bottom: 8px; }
#mg-spec-status { min-height: 1.2em; }
.sm-add-modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  background: var(--md-bg);
}
.sm-add-modal[hidden] { display: none !important; }
.sm-add-card {
  width: 100%;
  height: 100%;
  max-height: none;
  overflow: auto;
  background: var(--md-bg);
  border: 0;
  border-radius: 0;
  padding: calc(16px + var(--md-safe-t)) calc(16px + var(--md-safe-r)) calc(20px + var(--md-safe-b)) calc(16px + var(--md-safe-l));
}
.sm-add-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.sm-add-head h3 {
  margin: 0;
  font-size: 1.15rem;
}
.sm-add-row {
  display: flex;
  gap: 8px;
}
.sm-add-row input { flex: 1; min-width: 0; }
.sm-add-row .md-btn { width: auto; flex: 0 0 auto; }
#sm-locs {
  width: 100%;
}
.sm-add-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}
.sm-add-actions .md-btn-primary { flex: 1; }
.sm-add-actions .md-btn-ghost { width: auto; }
.wt-spec-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(7, 11, 20, 0.45);
}
.wt-spec-modal[hidden] { display: none !important; }
.wt-spec-modal-card {
  width: min(520px, 100%);
  max-height: min(90vh, 760px);
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  padding: 20px 20px 18px;
  color: #1b2433;
  color-scheme: light;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.28);
}
.wt-spec-modal .mg-file-name { color: #64748b; }
.wt-spec-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.wt-spec-modal-head h3 {
  margin: 0;
  font-size: 1.05rem;
  color: #1b2433;
}
.wt-spec-modal-head .md-icon-btn { color: #1b2433; }
.ad-screen .wt-spec-modal .mg-form-note { margin-bottom: 12px; }
.wt-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0 14px;
  color: #1b2433;
  font-size: 0.84rem;
  line-height: 1.45;
}
.wt-consent input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
}
.wt-consent span { min-width: 0; }
.wt-spec-modal .md-btn-primary,
.wt-spec-modal .md-btn-ghost { width: auto; }
@media (max-width: 620px) {
  .wt-perf-fields { grid-template-columns: 1fr; }
  .wt-layer-row { flex-wrap: wrap; }
}
.ad-screen .md-search input { color: #1b2433; }
.ad-screen .mg-cat-row,
.ad-screen .mg-group,
.ad-screen .mg-item,
.ad-screen .mg-user-detail,
.ad-screen .mg-users-table {
  background: #fff;
  border: 1px solid #e6ebf2;
  color: #1b2433;
}
.ad-screen .mg-item-num,
.ad-screen .mg-item-meta { color: #64748b; }
.ad-screen .mg-cat-actions button,
.ad-screen .mg-item-actions button {
  color: #1b4f72;
  background: #eef4f8;
}
.ad-screen .md-btn-ghost {
  background: #eef1f5;
  color: #1b2433;
}
.ad-screen .mg-add-dwg {
  background: #1b4f72;
  color: #fff;
}
.ad-screen .mg-add-dwg svg {
  stroke: #fff;
}
.ad-screen .md-error { color: #b91c1c; }
.ad-screen .md-error.is-ok { color: #0f766e; }
.ad-screen .mg-form {
  background: #fff;
  border-radius: 8px;
  padding: 22px;
}

@media (min-width: 860px) {
  .ad-sidebar { display: flex; }
  .ad-burger { display: none; }
}

@media (max-width: 859px) {
  .ad-sidebar {
    display: flex;
    flex: 0 0 64px;
    width: 64px;
    padding: calc(12px + var(--md-safe-t)) 6px 16px;
  }
  .ad-logo { width: 44px; height: 44px; margin: 0 auto 12px; }
  .ad-logo svg { width: 34px; height: 34px; }
  .ad-menu-label { display: none; }
  .ad-nav button {
    font-size: 0;
    letter-spacing: 0;
    padding: 11px 0;
    justify-content: center;
    gap: 0;
  }
  .ad-nav button svg { width: 22px; height: 22px; }
  .ad-burger { display: none; }
  .ad-welcome { font-size: 1.05rem; }
  .ad-company { display: none; }
  .ad-home { padding: 22px 16px; }
  .ad-stats { font-size: 0.95rem; }
  .ad-stats strong { font-size: 1.2rem; }
  .mg-users-table thead { display: none; }
  .mg-users-table,
  .mg-users-table tbody,
  .mg-users-table tr,
  .mg-users-table td {
    display: block;
    width: 100%;
  }
  .mg-users-table tr {
    padding: 12px 0 8px;
    border-bottom: 1px solid #e6ebf2;
  }
  .mg-users-table tbody tr:last-child { border-bottom: 0; }
  .mg-users-table td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 14px;
    border: 0;
  }
  .mg-users-table td::before {
    content: attr(data-label);
    flex: 0 0 92px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
  }
  .mg-users-table td[data-label=""]::before { content: none; }
  .mg-users-table td[data-label=""] { justify-content: flex-end; }
  .mg-user-access { min-width: 0; }
}

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