/*
 * Microsoft Places — Device Manager (Beta)
 */

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design tokens ──────────────────────────────────────────────────────────── */
:root {
  --ink:     #0A1D5F;
  --blue:    #0972CE;
  --teal:    #37C1CE;
  --vi:      #0972CE;
  --vi2:     #37C1CE;
  --snow:    #f7f8fb;
  --cloud:   #eef0f6;
  --mist:    #e2e4ef;
  --silver:  #abafc4;
  --surface: #ffffff;
  --text:    #1a1a2e;
  --muted:   #5a6278;
  --danger:  #d13438;
  --success: #107c10;
  --top-h:   56px;
  --filt-h:  52px;
  --rad:     8px;
}

/* ── Base ───────────────────────────────────────────────────────────────────── */
html, body { height: 100%; }

body {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--snow);
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; }

#main-app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

[hidden] { display: none !important; }

/* ── Beta badge / notice ───────────────────────────────────────────────────── */
.dm-beta-badge {
  display: inline-block;
  background: #d97706;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  line-height: 1.5;
  vertical-align: middle;
  flex-shrink: 0;
}
.signin-card h1 .dm-beta-badge { margin-left: 8px; font-size: 9px; vertical-align: 3px; }

.dm-beta-notice {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(217,119,6,.1); border: 1px solid rgba(217,119,6,.35);
  border-radius: 8px; padding: 10px 20px; margin: 12px 24px 0;
  font-size: 12.5px; color: #92400e; line-height: 1.55; flex-shrink: 0;
}
.dm-beta-notice svg { flex-shrink: 0; margin-top: 1px; color: #d97706; }
.dm-beta-notice code {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px; background: rgba(217,119,6,.15); padding: 1px 5px; border-radius: 3px;
}

/* ── Sign-in screen ─────────────────────────────────────────────────────────── */
#signin-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink);
  z-index: 100;
}

#signin-screen::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(55,193,206,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(55,193,206,.06) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.signin-logo {
  position: absolute; top: 24px; left: 28px;
  height: 28px; width: auto;
  filter: brightness(0) invert(1);
  opacity: .9;
}

.signin-card {
  position: relative;
  background: var(--surface);
  border-radius: 14px;
  padding: 40px 44px;
  text-align: center;
  width: 100%; max-width: 400px;
  box-shadow: 0 24px 64px rgba(0,0,0,.32);
}

.signin-eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--teal); margin-bottom: 12px;
}

.signin-card h1 { font-size: 22px; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.signin-card p  { font-size: 14px; color: var(--muted); line-height: 1.65; margin-bottom: 28px; }

.btn-ms {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--ink); color: #fff;
  border: none; border-radius: 8px;
  padding: 14px 24px; font-family: inherit;
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.btn-ms:hover { background: #0d2470; }

/* ── Loading screen ─────────────────────────────────────────────────────────── */
#loading-screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  background: var(--ink); z-index: 90;
}

.loading-logo { height: 32px; width: auto; filter: brightness(0) invert(1); opacity: .85; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(55,193,206,.25);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-msg { font-size: 14px; color: rgba(255,255,255,.7); }

/* ── Error / Consent / Maintenance screens ──────────────────────────────────── */
#error-screen,
#consent-screen,
#maintenance-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--snow); z-index: 80;
}

.error-card {
  background: var(--surface); border-radius: 12px;
  padding: 40px; text-align: center; width: 100%; max-width: 420px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
  border: 1px solid var(--mist);
}

.error-icon { margin-bottom: 16px; }
.error-card h2 { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.error-card p  { font-size: 14px; color: var(--muted); line-height: 1.65; margin-bottom: 20px; }
.error-card code {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 12px; background: var(--cloud); padding: 1px 5px; border-radius: 3px;
}

.btn-retry {
  display: inline-block; padding: 10px 24px;
  background: var(--ink); color: #fff; border: none; border-radius: 6px;
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.btn-retry:hover { background: #0d2470; }

#avispl-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink);
  z-index: 100;
  overflow: hidden;
}
#avispl-screen::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(55,193,206,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(55,193,206,.06) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}
#avispl-screen::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #0972CE 0%, #37C1CE 100%);
}
.avispl-prompt-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}
.btn-avispl-continue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  background: transparent;
  border: 1.5px solid rgba(255,255,255,.2);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn-avispl-continue:hover {
  border-color: rgba(255,255,255,.5);
  background: rgba(255,255,255,.06);
}

/* ── Topbar ─────────────────────────────────────────────────────────────────── */
#topbar {
  display: flex; align-items: center; gap: 10px;
  height: var(--top-h); padding: 0 20px;
  background: var(--ink); flex-shrink: 0;
}

.tb-logo { height: 22px; width: auto; filter: brightness(0) invert(1); opacity: .9; }
.tb-divider { width: 1px; height: 20px; background: rgba(255,255,255,.18); margin: 0 4px; }

.tb-breadcrumb { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.tb-breadcrumb-parent {
  font-size: 13px; font-weight: 500; color: rgba(255,255,255,.6);
  text-decoration: none; transition: color .15s;
}
.tb-breadcrumb-parent:hover { color: rgba(255,255,255,.9); }
.tb-breadcrumb-sep { font-size: 13px; color: rgba(255,255,255,.35); }
.tb-title { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; }

.btn-back, .btn-signout, .btn-help {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 6px;
  font-family: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
  border: 1px solid rgba(255,255,255,.2); color: rgba(255,255,255,.8);
  background: transparent; text-decoration: none; flex-shrink: 0;
  transition: background .15s, color .15s;
}
.btn-back:hover, .btn-signout:hover, .btn-help:hover {
  background: rgba(255,255,255,.1); color: #fff;
}

/* ── Expiry badge + modal ─────────────────────────────────────────────────────── */
.user-expiry-badge {
  position: absolute; top: -2px; right: -2px; width: 14px; height: 14px;
  background: #d97706; color: #fff; border-radius: 50%;
  font-size: 9px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--ink); pointer-events: none; z-index: 1;
}

.expiry-modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,29,95,.45); z-index: 500;
  display: flex; align-items: center; justify-content: center;
}
.expiry-modal {
  background: #fff; border-radius: 12px; box-shadow: 0 8px 40px rgba(10,29,95,.18);
  padding: 28px; max-width: 400px; width: calc(100% - 48px);
  display: flex; flex-direction: column; gap: 12px;
}
.expiry-modal-icon {
  width: 40px; height: 40px; background: #fffbeb; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.expiry-modal h2 { font-size: 17px; font-weight: 700; color: #0A1D5F; margin: 0; }
.expiry-modal p  { font-size: 14px; color: #5a6278; line-height: 1.55; margin: 0; }
.expiry-modal a  { color: #0972CE; font-weight: 600; }
.expiry-modal .btn-expiry-ok {
  align-self: flex-end; background: #0972CE; color: #fff; border: none; border-radius: 6px;
  cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 20px; transition: background .15s; margin-top: 4px;
}
.expiry-modal .btn-expiry-ok:hover { background: #0762b0; }

/* ── User info chip + popover ────────────────────────────────────────────────── */
.user-info-wrap { position: relative; flex-shrink: 0; }

.btn-user-info {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  border-radius: 6px; color: rgba(255,255,255,.85); cursor: pointer;
  font-family: inherit; font-size: 12px; font-weight: 500;
  padding: 4px 10px 4px 8px; transition: background .15s; white-space: nowrap;
}
.btn-user-info:hover { background: rgba(255,255,255,.18); }
.btn-user-info .user-chevron { opacity: .55; transition: transform .2s; }
.btn-user-info[aria-expanded="true"] .user-chevron { transform: rotate(180deg); }

.user-info-popover {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: #fff; border: 1px solid #e2e4ef; border-radius: 8px;
  box-shadow: 0 4px 20px rgba(10,29,95,.12), 0 1px 4px rgba(0,0,0,.06);
  min-width: 260px; z-index: 200;
}
.uip-row { display: flex; flex-direction: column; gap: 2px; padding: 8px 14px; border-bottom: 1px solid #f0f0f6; }
.uip-row:last-child { border-bottom: none; }
.uip-label { font-size: 10px; font-weight: 700; color: #5a6278; text-transform: uppercase; letter-spacing: .07em; }
.uip-value { font-size: 13px; color: #1a1a2e; word-break: break-all; }
.uip-mono  { font-family: monospace; font-size: 11px; }
.uip-expiry-ok   { color: #107c10; }
.uip-expiry-warn { color: #d97706; }
.uip-expiry-none { color: #5a6278; }

/* ── Maintenance banner ─────────────────────────────────────────────────────── */
.maintenance-banner {
  background: #fffbeb; border-bottom: 2px solid #fbbf24; color: #92400e;
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  font-size: 13px; font-weight: 500; flex-shrink: 0;
}
.maintenance-banner svg { flex-shrink: 0; }
.maintenance-banner-msg { flex: 1; }
.maintenance-banner-dismiss {
  background: transparent; border: 1px solid #f59e0b; border-radius: 4px; color: #92400e;
  font-family: inherit; font-size: 12px; font-weight: 600; padding: 3px 10px; cursor: pointer; flex-shrink: 0;
}
.maintenance-banner-dismiss:hover { background: #fef3c7; }

/* ── Filter bar — matches Control Center's #filterbar ────────────────────────── */
#filterbar {
  height: var(--filt-h);
  background: var(--surface);
  border-bottom: 1px solid var(--mist);
  display: flex; align-items: center; padding: 0 24px; gap: 8px;
  flex-shrink: 0; overflow-x: auto; scrollbar-width: none;
}
#filterbar::-webkit-scrollbar { display: none; }

.filter-srch {
  display: flex; align-items: center; gap: 6px;
  background: var(--snow); border: 1px solid var(--mist); border-radius: 6px;
  padding: 0 10px; min-width: 220px; flex-shrink: 0; transition: border-color .15s;
}
.filter-srch:focus-within { border-color: var(--vi, var(--blue)); }
.filter-srch svg { color: var(--silver); flex-shrink: 0; }
.filter-srch input {
  border: none; background: transparent; font-family: inherit; font-size: 13px;
  color: var(--text); outline: none; padding: 8px 0; width: 100%;
}
.filter-srch input::placeholder { color: var(--silver); }

.filter-sel {
  background: var(--snow); border: 1px solid var(--mist); border-radius: 6px;
  padding: 7px 30px 7px 10px; font-family: inherit; font-size: 13px; color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23abafc4' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  cursor: pointer; min-width: 130px; flex-shrink: 0; transition: border-color .15s;
}
.filter-sel:focus { outline: 2px solid var(--vi, var(--blue)); outline-offset: -1px; border-color: transparent; }
.filter-sel:hover { border-color: var(--vi, var(--blue)); }

.btn-clear {
  background: transparent; border: 1px solid var(--mist); border-radius: 6px;
  padding: 7px 14px; font-family: inherit; font-size: 13px; color: var(--muted);
  cursor: pointer; flex-shrink: 0; transition: background .15s, color .15s; white-space: nowrap;
}
.btn-clear:hover { background: var(--cloud); color: var(--text); }

.filter-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.btn-tree-ctrl {
  background: transparent; border: none; padding: 6px 10px;
  font-family: inherit; font-size: 12px; font-weight: 500; color: var(--vi, var(--blue));
  cursor: pointer; border-radius: 5px; white-space: nowrap; transition: background .15s;
}
.btn-tree-ctrl:hover { background: var(--cloud); }

.btn-tm-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--mist); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-tm-secondary:hover { background: var(--cloud); border-color: var(--silver); }

.btn-action {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 16px; border: none; border-radius: 7px;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn-action.primary { background: var(--ink); color: #fff; }
.btn-action.primary:hover:not(:disabled) { background: #0d2470; }
.btn-action.danger { background: var(--danger); color: #fff; }
.btn-action.danger:hover:not(:disabled) { background: #b02a2e; }
.btn-action:disabled { opacity: .5; cursor: not-allowed; }

/* ── Device list — square cards ──────────────────────────────────────────────── */
#app-body { flex: 1; overflow-y: auto; padding: 16px 24px; }

.tm-empty { text-align: center; color: var(--muted); padding: 32px 14px; grid-column: 1 / -1; }
.tm-empty-inline { color: var(--silver); font-size: 11px; }
.tm-mono { font-family: 'JetBrains Mono', monospace; font-size: 11px; }

.dm-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  max-width: 1400px;
}

.dm-device-card {
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 1px solid var(--mist);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.dm-device-card:hover { border-color: var(--vi); box-shadow: 0 2px 10px rgba(9,114,206,.1); }

.dm-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; flex-shrink: 0; }
.dm-device-id {
  font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--muted);
  background: var(--cloud); padding: 2px 6px; border-radius: 4px; word-break: break-all;
}
.dm-card-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity .15s; }
.dm-device-card:hover .dm-card-actions, .dm-device-card:focus-within .dm-card-actions { opacity: 1; }

/* Large sensor-type icon — the card's visual anchor */
.dm-card-icon {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; margin: 2px auto 0;
  border-radius: 50%;
  background: var(--cloud); color: var(--muted);
}
.dm-card-icon-wifi              { background: rgba(9,114,206,.12);   color: var(--vi); }
.dm-card-icon-occupancy         { background: rgba(16,124,16,.12);   color: var(--success); }
.dm-card-icon-peopleCount       { background: rgba(135,100,184,.15); color: #8764b8; }
.dm-card-icon-inferredOccupancy { background: rgba(55,193,206,.15);  color: #0e7d80; }
.dm-card-icon-heartbeat         { background: rgba(209,52,56,.1);    color: var(--danger); }
.dm-card-icon-badge             { background: rgba(217,119,6,.12);   color: #d97706; }

.dm-card-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 4px; overflow: hidden; text-align: center; }
.dm-card-name {
  font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.dm-card-place { font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-card-meta { display: flex; flex-direction: column; gap: 1px; font-size: 10.5px; color: var(--muted); overflow: hidden; }
.dm-card-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-card-sensors, .dm-card-tags {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 3px;
  overflow: hidden; max-height: 24px;
}

.btn-edit-sm, .btn-delete-sm {
  border: 1px solid var(--mist); background: var(--surface); border-radius: 5px;
  font-family: inherit; font-size: 10px; font-weight: 600; padding: 3px 7px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-edit-sm:hover { background: var(--cloud); border-color: var(--blue); color: var(--blue); }
.btn-delete-sm:hover { background: #fde8e8; border-color: var(--danger); color: var(--danger); }

/* ── Tag / sensor chips ─────────────────────────────────────────────────────── */
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--cloud); color: var(--text); font-size: 10px; font-weight: 500;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.tag-chip-sensor { background: rgba(9,114,206,.1); color: var(--vi); }
.tag-chip svg { flex-shrink: 0; }

/* ── Add/Edit device panel ─────────────────────────────────────────────────── */
.dm-panel-backdrop { position: fixed; inset: 0; background: rgba(10,29,95,.35); z-index: 250; }
.dm-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 95vw;
  background: var(--surface); z-index: 260; display: flex; flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,.18); animation: slideIn .25s cubic-bezier(.4,0,.2,1);
}
.dm-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 3px solid var(--teal); background: var(--ink);
  color: #fff; font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.dm-panel-header .help-close { color: rgba(255,255,255,.7); }
.dm-panel-header .help-close:hover { background: rgba(255,255,255,.12); color: #fff; }
.dm-panel-body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.dm-panel-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--mist); flex-shrink: 0;
}
.dm-panel-error {
  margin: 0 20px 16px; padding: 10px 14px; background: #fde8e8; color: var(--danger);
  border-left: 3px solid var(--danger); border-radius: 6px; font-size: 13px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.field-input {
  border: 1px solid var(--mist); border-radius: 6px; padding: 9px 12px;
  font-family: inherit; font-size: 14px; color: var(--text); outline: none; transition: border-color .15s;
}
.field-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(9,114,206,.1); }
.field-input:disabled { background: var(--cloud); color: var(--muted); }
.form-hint { font-size: 11px; color: var(--silver); }

.dm-sensor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dm-sensor-check {
  display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; transition: background .15s;
}
.dm-sensor-check:hover { background: var(--snow); }
.dm-sensor-check input { accent-color: var(--blue); width: 15px; height: 15px; cursor: pointer; }

/* ── Bulk import modal ─────────────────────────────────────────────────────── */
.bulk-backdrop { position: fixed; inset: 0; background: rgba(10,29,95,.4); z-index: 300; }
.bulk-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 640px; max-width: 92vw; max-height: 86vh;
  background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  z-index: 310; display: flex; flex-direction: column; overflow: hidden;
}
.bulk-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: var(--ink); color: #fff; font-size: 15px; font-weight: 700; flex-shrink: 0;
}
.bulk-modal-header .help-close { color: rgba(255,255,255,.7); }
.bulk-modal-header .help-close:hover { background: rgba(255,255,255,.12); color: #fff; }
.bulk-modal-body { padding: 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.bulk-modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--mist); flex-shrink: 0;
}

.bulk-progress-track { height: 8px; background: var(--cloud); border-radius: 999px; overflow: hidden; }
.bulk-progress-bar { height: 100%; background: var(--teal); width: 0%; transition: width .2s; }
.bulk-progress-text { font-size: 12px; color: var(--muted); text-align: right; }
.bulk-progress-summary { font-size: 13px; font-weight: 600; color: var(--ink); }
.tagbulk-row-status.ok { color: var(--success); font-weight: 600; }
.tagbulk-row-status.fail { color: var(--danger); font-weight: 600; }

.tm-report-lead { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.tm-report-lead code {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  background: var(--cloud); padding: 1px 5px; border-radius: 3px;
}

/* ── File upload zone (bulk import) ────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--mist); border-radius: 8px; padding: 24px 20px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s; position: relative;
}
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--blue); background: var(--cloud); }
.upload-icon { color: var(--silver); margin-bottom: 8px; }
.upload-main { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.upload-sub { font-size: 12px; color: var(--muted); }

/* ── Help drawer ────────────────────────────────────────────────────────────── */
.help-backdrop {
  position: fixed; inset: 0; background: rgba(10,29,95,.35);
  backdrop-filter: blur(2px); z-index: 200; animation: fadeIn .2s ease;
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.help-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 460px; max-width: 95vw;
  background: var(--surface); z-index: 210; display: flex; flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,.18); animation: slideIn .25s cubic-bezier(.4,0,.2,1);
}
.help-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 3px solid var(--teal); background: var(--ink); flex-shrink: 0;
}
.help-title { font-size: 15px; font-weight: 700; color: #fff; }
.help-close {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; background: transparent; border: none;
  border-radius: 6px; cursor: pointer; color: rgba(255,255,255,.6); transition: background .15s, color .15s;
}
.help-close:hover { background: rgba(255,255,255,.1); color: #fff; }
.help-body { flex: 1; overflow-y: auto; padding: 24px 20px; display: flex; flex-direction: column; gap: 24px; }
.help-section { display: flex; flex-direction: column; gap: 10px; }
.help-section-title { font-size: 13px; font-weight: 700; color: var(--ink); text-transform: uppercase; letter-spacing: .06em; }
.help-section p { font-size: 13px; color: var(--muted); line-height: 1.75; }
.help-section p + p { margin-top: 6px; }
.help-list { padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.help-list li { font-size: 13px; color: var(--muted); line-height: 1.65; }
.help-list strong { color: var(--text); }
.help-section code {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px; background: var(--cloud); padding: 1px 5px; border-radius: 3px;
}

@media (max-width: 900px) {
  #dm-toolbar { flex-direction: column; align-items: stretch; }
}
