:root {
  color-scheme: light;
  --ink-950: #07111f;
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50: #f8fafc;
  --brand-700: #0369a1;
  --brand-600: #0284c7;
  --brand-500: #0ea5e9;
  --brand-100: #e0f2fe;
  --brand-50: #f0f9ff;
  --green: #16a34a;
  --yellow: #ca8a04;
  --orange: #ea580c;
  --red: #dc2626;
  --overdue: #7f1d1d;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 24px 70px rgba(2, 8, 23, 0.22);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--ink-100);
  color: var(--ink-900);
}

body {
  overflow: hidden;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(14, 165, 233, 0.35);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(14, 165, 233, 0.28), transparent 30%),
    radial-gradient(circle at 85% 85%, rgba(34, 197, 94, 0.18), transparent 30%),
    linear-gradient(145deg, #07111f 0%, #0f172a 55%, #172554 100%);
}

.login-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 36px 36px;
}

.login-card {
  position: relative;
  width: min(100%, 450px);
  padding: 38px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-lg);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
  box-shadow: 0 8px 20px rgba(2, 132, 199, 0.28);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.brand-mark-large {
  width: 58px;
  height: 58px;
  margin-bottom: 20px;
  border-radius: 18px;
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-700);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(30px, 7vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.login-copy {
  margin: 16px 0 26px;
  color: var(--ink-600);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label,
.filter-grid > label > span,
.filter-label {
  color: var(--ink-600);
  font-size: 12px;
  font-weight: 700;
}

.login-form input,
.search-box,
.filter-grid select,
.multi-filter > summary {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-900);
}

.login-form input {
  padding: 0 14px;
}

.login-form input:focus,
.filter-grid select:focus,
.multi-filter[open] > summary,
.search-box:focus-within {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
}

.privacy-note {
  margin: 18px 0 0;
  color: var(--ink-500);
  font-size: 12px;
  line-height: 1.5;
}

.app-shell {
  min-height: 100dvh;
}

.topbar {
  position: relative;
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-sm);
}

.brand-group,
.topbar-actions,
.user-chip {
  display: flex;
  align-items: center;
}

.brand-group {
  gap: 11px;
}

.brand-group strong,
.brand-group span {
  display: block;
}

.brand-group strong {
  font-size: 15px;
}

.brand-group span {
  margin-top: 2px;
  color: var(--ink-500);
  font-size: 11px;
}

.topbar-actions {
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 750;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

.button-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  box-shadow: 0 8px 18px rgba(2, 132, 199, 0.2);
}

.button-secondary {
  border-color: #bae6fd;
  color: var(--brand-700);
  background: var(--brand-50);
}

.button-light {
  border-color: var(--border);
  color: var(--ink-700);
  background: var(--surface);
}

.button-ghost {
  border-color: transparent;
  color: var(--ink-600);
  background: transparent;
}

.button-large {
  min-height: 50px;
  margin-top: 8px;
}

.button-compact {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

.user-chip {
  gap: 9px;
  min-height: 44px;
  padding: 4px 10px 4px 5px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  color: var(--ink-900);
  text-align: left;
}

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: var(--ink-900);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.user-copy strong,
.user-copy small {
  display: block;
}

.user-copy strong {
  max-width: 150px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy small {
  margin-top: 1px;
  color: var(--ink-500);
  font-size: 9px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  height: calc(100dvh - 70px);
}

.sidebar {
  position: relative;
  z-index: 3;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: var(--surface-muted);
}

.location-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid #bae6fd;
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, #f0f9ff, #fff);
  box-shadow: var(--shadow-sm);
}

.location-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  color: var(--brand-700);
  background: #dff3ff;
  font-size: 24px;
  font-weight: 700;
}

.location-copy {
  min-width: 0;
}

.location-copy span,
.location-copy strong,
.location-copy small {
  display: block;
}

.location-copy span {
  color: var(--ink-500);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.location-copy strong {
  margin-top: 3px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-copy small {
  margin-top: 3px;
  color: var(--ink-500);
  font-size: 10px;
  line-height: 1.4;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--brand-700);
  font-size: 22px;
}

.control-panel {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}

.search-box span {
  color: var(--ink-400);
  font-size: 22px;
}

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-900);
  font-size: 13px;
}

.search-box input::placeholder {
  color: var(--ink-400);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 11px;
}

.filter-grid > label,
.filter-field {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.filter-grid select {
  min-height: 39px;
  padding: 0 30px 0 10px;
  font-size: 12px;
}

.multi-filter {
  position: relative;
  min-width: 0;
}

.multi-filter > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 39px;
  padding: 0 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-900);
  font-size: 12px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.multi-filter > summary::-webkit-details-marker {
  display: none;
}

.multi-filter.is-filtered > summary {
  border-color: #7dd3fc;
  background: var(--brand-50);
  color: var(--brand-700);
}

.multi-filter.is-empty > summary {
  border-color: #fecaca;
  background: #fff7f7;
  color: var(--red);
}

.multi-filter-summary {
  min-width: 0;
  overflow: hidden;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-filter-chevron {
  flex: 0 0 auto;
  color: var(--ink-400);
  font-size: 15px;
  transition: transform 0.16s ease;
}

.multi-filter[open] .multi-filter-chevron {
  transform: rotate(180deg);
}

.multi-filter-panel {
  position: absolute;
  z-index: 90;
  top: calc(100% + 6px);
  left: 0;
  width: max(100%, 286px);
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.multi-filter.align-right .multi-filter-panel {
  right: 0;
  left: auto;
}

.multi-filter-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 0 7px;
  border-bottom: 1px solid var(--ink-100);
}

.multi-filter-actions button {
  min-height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: var(--ink-100);
  color: var(--ink-700);
  font-size: 10px;
  font-weight: 750;
}

.multi-filter-actions button:last-child {
  margin-left: auto;
  background: var(--brand-100);
  color: var(--brand-700);
}

.multi-filter-options {
  display: grid;
  gap: 3px;
  padding-top: 7px;
}

.multi-filter-options-scroll {
  max-height: min(340px, 48dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.multi-filter-option {
  display: flex !important;
  align-items: center;
  gap: 9px !important;
  min-height: 38px;
  padding: 7px 8px;
  border-radius: 9px;
  color: var(--ink-700);
  font-size: 11px;
  line-height: 1.25;
  cursor: pointer;
}

.multi-filter-option:hover {
  background: var(--ink-50);
}

.multi-filter-option:has(input:checked) {
  background: var(--brand-50);
  color: var(--ink-900);
}

.multi-filter-option input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--brand-600);
}

.multi-filter-option span {
  min-width: 0;
  flex: 1;
  font-weight: 650;
}

.multi-filter-option small {
  float: right;
  margin-left: 8px;
  color: var(--ink-400);
  font-size: 9px;
  font-weight: 700;
}

.filter-sla-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.filter-action {
  grid-column: 1 / -1;
  align-self: end;
  min-height: 39px;
  font-size: 12px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.kpi-card {
  min-width: 0;
  padding: 11px 9px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.kpi-card span,
.kpi-card strong,
.kpi-card small {
  display: block;
}

.kpi-card span {
  min-height: 25px;
  color: var(--ink-500);
  font-size: 9px;
  font-weight: 750;
  line-height: 1.25;
}

.kpi-card strong {
  margin-top: 2px;
  font-size: 21px;
  line-height: 1;
}

.kpi-card small {
  margin-top: 4px;
  overflow: hidden;
  color: var(--ink-400);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-urgent {
  border-color: #fecaca;
  background: #fff7f7;
}

.kpi-urgent strong {
  color: var(--red);
}

.kpi-warning {
  border-color: #fed7aa;
  background: #fffaf3;
}

.kpi-warning strong {
  color: var(--orange);
}

.list-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 2px 10px;
}

.list-heading h2,
.list-heading p,
.modal-header h2,
.modal-header p,
.upload-card h3,
.upload-card p,
.automation-card h3,
.automation-card p,
.history-heading h3 {
  margin: 0;
}

.list-heading h2 {
  font-size: 15px;
}

.list-heading p {
  margin-top: 3px;
  color: var(--ink-500);
  font-size: 10px;
}

.text-button,
.sample-link {
  border: 0;
  background: transparent;
  color: var(--brand-700);
  font-size: 11px;
  font-weight: 750;
  text-decoration: none;
}

.text-button:hover,
.sample-link:hover {
  text-decoration: underline;
}

.ticket-list {
  display: grid;
  gap: 9px;
  padding-bottom: 22px;
}

.ticket-card {
  position: relative;
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.ticket-card:hover {
  transform: translateY(-1px);
  border-color: var(--ink-300);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.ticket-card:focus-within {
  border-color: var(--brand-500);
}

.ticket-accent {
  background: var(--green);
}

.ticket-card[data-sla="yellow"] .ticket-accent { background: var(--yellow); }
.ticket-card[data-sla="orange"] .ticket-accent { background: var(--orange); }
.ticket-card[data-sla="red"] .ticket-accent { background: var(--red); }
.ticket-card[data-sla="overdue"] .ticket-accent { background: var(--overdue); }

.ticket-card-button {
  display: block;
  width: 100%;
  padding: 12px 12px 10px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.ticket-row,
.ticket-meta,
.ticket-footer {
  display: flex;
  align-items: center;
}

.ticket-row {
  justify-content: space-between;
  gap: 8px;
}

.ticket-subrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 3px;
}

.ticket-id {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sla-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  color: #166534;
  background: #dcfce7;
  font-size: 9px;
  font-weight: 850;
  white-space: nowrap;
}

.sla-badge.sla-yellow {
  color: #854d0e;
  background: #fef9c3;
}

.sla-badge.sla-orange {
  color: #9a3412;
  background: #ffedd5;
}

.sla-badge.sla-red {
  color: #991b1b;
  background: #fee2e2;
}

.sla-badge.sla-overdue {
  color: #fff;
  background: var(--overdue);
}

.ticket-station {
  min-width: 0;
  flex: 1;
  margin: 0;
  overflow: hidden;
  color: var(--ink-800);
  font-size: 13px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  width: fit-content;
  padding: 4px 7px;
  border-radius: 999px;
  color: #1d4ed8;
  background: #dbeafe;
  font-size: 8px;
  font-weight: 850;
  line-height: 1.1;
  text-transform: none;
  white-space: nowrap;
}

.status-badge.status-pending-spare-parts {
  color: #92400e;
  background: #fef3c7;
}

.status-badge.status-appointment {
  color: #6d28d9;
  background: #ede9fe;
}

.status-badge.status-other {
  color: var(--ink-600);
  background: var(--ink-100);
}

.ticket-issue {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--ink-600);
  font-size: 11px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ticket-meta {
  flex-wrap: wrap;
  gap: 5px 9px;
  margin-top: 8px;
  color: var(--ink-500);
  font-size: 9px;
}

.ticket-meta span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.ticket-footer {
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--ink-100);
}

.ticket-address {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-500);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-button {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  color: var(--brand-700);
  background: var(--brand-50);
  font-size: 9px;
  font-weight: 800;
}

.empty-state {
  padding: 26px 18px;
  border: 1px dashed var(--ink-300);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink-500);
  text-align: center;
}

.empty-state strong {
  display: block;
  color: var(--ink-800);
}

.empty-state p {
  margin: 7px 0 0;
  font-size: 12px;
  line-height: 1.5;
}

.map-panel {
  position: relative;
  min-width: 0;
  background: #dce5e9;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.leaflet-control-zoom a {
  color: var(--ink-800) !important;
}

.leaflet-popup-content-wrapper {
  overflow: hidden;
  padding: 0;
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
}

.leaflet-popup-content {
  width: min(290px, 75vw) !important;
  margin: 0 !important;
}

.leaflet-popup-tip {
  box-shadow: 5px 5px 10px rgba(15, 23, 42, 0.08);
}

.popup-card {
  overflow: hidden;
}

.popup-head {
  padding: 13px 14px;
  color: #fff;
  background: var(--green);
}

.popup-head.sla-yellow { background: var(--yellow); }
.popup-head.sla-orange { background: var(--orange); }
.popup-head.sla-red { background: var(--red); }
.popup-head.sla-overdue { background: var(--overdue); }

.popup-head span,
.popup-head strong,
.popup-head small {
  display: block;
}

.popup-head span {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.88;
}

.popup-head strong {
  margin-top: 3px;
  font-size: 15px;
}

.popup-head small {
  margin-top: 3px;
  font-size: 10px;
  opacity: 0.9;
}

.popup-body {
  display: grid;
  gap: 8px;
  padding: 13px 14px 14px;
}

.popup-field span,
.popup-field strong {
  display: block;
}

.popup-field strong.status-badge {
  display: inline-flex;
  margin-top: 4px;
  color: #1d4ed8;
  font-size: 9px;
}

.popup-field strong.status-badge.status-pending-spare-parts {
  color: #92400e;
}

.popup-field strong.status-badge.status-appointment {
  color: #6d28d9;
}

.popup-field span {
  color: var(--ink-500);
  font-size: 9px;
  font-weight: 750;
  text-transform: uppercase;
}

.popup-field strong {
  margin-top: 2px;
  color: var(--ink-800);
  font-size: 11px;
  line-height: 1.35;
}

.popup-copy-value {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
}

.popup-copy-value strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.popup-copy-mini {
  display: inline-grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid #bae6fd;
  border-radius: 7px;
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.popup-copy-mini:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 1px;
}

.popup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.popup-claim-area {
  margin-top: 2px;
}

.popup-claim-button {
  display: grid;
  width: 100%;
  min-height: 44px;
  place-items: center;
  gap: 2px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  text-align: center;
  touch-action: manipulation;
  cursor: pointer;
}

.popup-claim-button strong,
.popup-claim-button small {
  display: block;
}

.popup-claim-button strong {
  font-size: 11px;
  font-weight: 900;
}

.popup-claim-button small {
  font-size: 8px;
  font-weight: 750;
  line-height: 1.25;
}

.popup-claim-button.claim-available {
  border-color: #15803d;
  background: #16a34a;
  color: #fff;
}

.popup-claim-button.claim-received {
  border-color: #eab308;
  background: #facc15;
  color: #713f12;
}

.popup-claim-button.claim-received.is-releasable:not(:disabled):hover,
.popup-claim-button.claim-received.is-releasable:not(:disabled):focus-visible {
  border-color: #a16207;
  outline: 2px solid rgba(250, 204, 21, 0.35);
  outline-offset: 1px;
}

.popup-claim-button:disabled {
  opacity: 1;
  cursor: default;
}

.popup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 2px;
}

.popup-actions a,
.popup-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--ink-700);
  background: var(--surface);
  font-size: 10px;
  font-weight: 800;
  text-decoration: none;
}

.popup-actions a {
  border-color: #bae6fd;
  color: var(--brand-700);
  background: var(--brand-50);
}

.ticket-marker-wrap {
  background: transparent;
  border: 0;
}

.ticket-marker {
  position: relative;
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 8px;
  transform: rotate(-45deg);
  background: var(--green);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.35);
}

.ticket-marker::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
}

.ticket-marker.sla-yellow { background: var(--yellow); }
.ticket-marker.sla-orange { background: var(--orange); }
.ticket-marker.sla-red { background: var(--red); }
.ticket-marker.sla-overdue { background: var(--overdue); }

.ticket-marker.sla-overdue::before {
  content: "";
  position: absolute;
  inset: -8px;
  border: 2px solid rgba(127, 29, 29, 0.5);
  border-radius: 50%;
  animation: pulse-marker 1.8s ease-out infinite;
}

@keyframes pulse-marker {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}

.user-location-marker {
  position: relative;
  width: 20px;
  height: 20px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 0 2px #2563eb, 0 5px 18px rgba(37, 99, 235, 0.4);
}

.map-top-actions {
  position: absolute;
  z-index: 500;
  top: 14px;
  right: 14px;
}

.map-action-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink-800);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(12px);
}

.map-legend {
  position: absolute;
  z-index: 500;
  right: 14px;
  bottom: 58px;
  display: grid;
  gap: 7px;
  min-width: 134px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}

.map-legend strong {
  margin-bottom: 2px;
  font-size: 10px;
}

.map-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-600);
  font-size: 9px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.legend-dot.sla-yellow { background: var(--yellow); }
.legend-dot.sla-orange { background: var(--orange); }
.legend-dot.sla-red { background: var(--red); }
.legend-dot.sla-overdue { background: var(--overdue); }

.data-banner {
  position: absolute;
  z-index: 500;
  left: 50%;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 28px);
  padding: 9px 12px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink-600);
  box-shadow: var(--shadow-md);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  backdrop-filter: blur(12px);
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(202, 138, 4, 0.15);
}

.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.status-dot.offline {
  background: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

.modal {
  width: min(920px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.modal::backdrop {
  background: rgba(2, 8, 23, 0.64);
  backdrop-filter: blur(5px);
}

.modal-shell {
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 24px;
  letter-spacing: -0.03em;
}

.modal-header p:not(.eyebrow) {
  max-width: 650px;
  margin-top: 7px;
  color: var(--ink-600);
  font-size: 12px;
  line-height: 1.5;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-muted);
  color: var(--ink-600);
  font-size: 24px;
}

.import-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

.upload-card {
  position: relative;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.upload-card-primary {
  border-color: #bae6fd;
  background: var(--brand-50);
}

.upload-step {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: #fff;
  background: var(--ink-800);
  font-size: 12px;
  font-weight: 850;
}

.upload-card-primary .upload-step {
  background: var(--brand-700);
}

.upload-card h3,
.automation-card h3,
.history-heading h3 {
  font-size: 15px;
}

.upload-card p,
.automation-card p {
  color: var(--ink-600);
  font-size: 11px;
  line-height: 1.55;
}

.upload-card small {
  color: var(--ink-500);
  font-size: 10px;
  line-height: 1.45;
}

.sample-link {
  width: fit-content;
}

.automation-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
  padding: 16px 18px;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
  background: #fffbeb;
}

.automation-card code {
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(120, 53, 15, 0.08);
  color: #92400e;
  font-size: 10px;
}

.history-section {
  margin-top: 18px;
}

.history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-muted);
}

.history-status {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.history-status.error {
  background: var(--red);
}

.history-item strong,
.history-item small {
  display: block;
}

.history-item strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item small {
  margin-top: 2px;
  color: var(--ink-500);
  font-size: 9px;
}

.history-item time {
  color: var(--ink-500);
  font-size: 9px;
  white-space: nowrap;
}

.import-result {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  background: #f0fdf4;
  color: #166534;
  font-size: 11px;
  line-height: 1.55;
}

.import-result.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.toast {
  position: fixed;
  z-index: 3000;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  max-width: min(460px, calc(100% - 28px));
  padding: 11px 15px;
  transform: translate(-50%, 20px);
  border-radius: 12px;
  background: var(--ink-900);
  color: #fff;
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .button-label,
  .user-copy small {
    display: none;
  }

  .button-compact {
    width: 38px;
    padding: 0;
  }

  .user-chip {
    padding-right: 5px;
  }

  .user-copy strong {
    max-width: 100px;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .topbar {
    position: sticky;
    top: 0;
    height: 62px;
    padding: 0 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 11px;
    font-size: 11px;
  }

  .brand-group strong {
    font-size: 13px;
  }

  .brand-group span {
    display: none;
  }

  .user-copy {
    display: none;
  }

  .user-chip {
    padding: 4px;
    border: 0;
    background: transparent;
  }

  .workspace {
    display: flex;
    height: auto;
    min-height: calc(100dvh - 62px);
    flex-direction: column;
  }

  .map-panel {
    order: 1;
    height: 51dvh;
    min-height: 360px;
  }

  .sidebar {
    order: 2;
    overflow: visible;
    padding: 12px;
    border: 0;
  }

  .map-legend {
    right: 9px;
    bottom: 52px;
    gap: 5px;
    min-width: 118px;
    padding: 9px;
  }

  .map-legend span {
    font-size: 8px;
  }

  .map-top-actions {
    top: 9px;
    right: 9px;
  }

  .map-action-button:not(.team-role-toggle) > span {
    display: none;
  }

  .data-banner {
    bottom: 9px;
    max-width: calc(100% - 18px);
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, minmax(78px, 1fr));
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .kpi-card {
    min-width: 78px;
  }

  .modal-shell {
    padding: 18px;
  }

  .import-grid {
    grid-template-columns: 1fr;
  }

  .automation-card {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 430px) {
  .login-card {
    padding: 28px 22px;
  }

  .topbar-actions {
    gap: 3px;
  }

  .location-card {
    gap: 9px;
    padding: 12px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .multi-filter-panel,
  .multi-filter.align-right .multi-filter-panel {
    right: auto;
    left: 0;
    width: 100%;
    min-width: 0;
  }

  .filter-action {
    grid-column: auto;
    width: 100%;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 84px);
  }

  .map-panel {
    min-height: 330px;
  }

  .map-legend {
    display: none;
  }

  .history-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .history-item time {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.replacement-warning {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(180, 83, 9, 0.34);
  border-radius: 14px;
  background: rgba(255, 247, 237, 0.96);
  color: #7c2d12;
  line-height: 1.45;
}

.replacement-warning strong {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .replacement-warning {
    display: block;
  }
  .replacement-warning strong {
    display: block;
    margin-bottom: 4px;
  }
}

.admin-key-section {
  display: grid;
  grid-template-columns: minmax(150px, 210px) minmax(220px, 1fr);
  gap: 7px 14px;
  align-items: center;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 14px;
  background: rgba(239, 246, 255, 0.92);
}

.admin-key-section input {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(100, 116, 139, 0.45);
  border-radius: 10px;
  font: inherit;
}

.admin-key-section small {
  grid-column: 2;
  color: #475569;
}

@media (max-width: 640px) {
  .admin-key-section {
    grid-template-columns: 1fr;
  }
  .admin-key-section small {
    grid-column: 1;
  }
}

/* v0.5 authentication, cat branding and live-team refinements */
.brand-mark {
  display: block;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.85);
  object-fit: cover;
  background: var(--ink-100);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
}

.brand-mark-large {
  width: 64px;
  height: 64px;
  border-radius: 20px;
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field input {
  width: 100%;
  padding-right: 70px;
}

.password-toggle {
  position: absolute;
  right: 7px;
  min-width: 54px;
  height: 34px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  color: var(--brand-700);
  background: var(--brand-50);
  font-size: 11px;
  font-weight: 800;
}

.login-error {
  margin: 2px 0 0;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  color: #991b1b;
  background: #fef2f2;
  font-size: 12px;
  line-height: 1.45;
}

.login-form code,
.key-help code {
  overflow-wrap: anywhere;
}

.modal-key {
  width: min(94vw, 470px);
}

.modal-shell-key {
  display: grid;
  gap: 16px;
  width: 100%;
  padding: 24px;
}

.import-key-field {
  display: grid;
  gap: 7px;
  color: var(--ink-700);
  font-size: 12px;
  font-weight: 800;
}

.import-key-field input {
  min-height: 48px;
  padding: 0 72px 0 13px;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: 0;
}

.import-key-field input:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.1);
}

.key-help {
  color: var(--ink-500);
  font-size: 11px;
  line-height: 1.55;
}

.import-key-unlocked {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.import-key-unlocked > div {
  min-width: 0;
}

.load-more-card {
  display: grid;
  place-items: center;
  gap: 7px;
  padding: 14px;
  border: 1px dashed var(--ink-300);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-500);
  font-size: 11px;
  text-align: center;
}

/* Cards outside the scroll viewport are skipped by compatible browsers. */
.ticket-card {
  content-visibility: auto;
  contain: layout paint style;
  contain-intrinsic-size: 142px;
}

.ticket-list {
  contain: layout style;
}

#map,
.leaflet-map-pane,
.leaflet-canvas-pane canvas {
  transform: translateZ(0);
}

.leaflet-canvas-pane canvas {
  image-rendering: auto;
}

@media (max-width: 760px) {
  .topbar {
    backdrop-filter: none;
    background: #fff;
  }

  .button:hover,
  .ticket-card:hover {
    transform: none;
  }

  .modal-shell-key {
    padding: 20px;
  }

  .import-key-unlocked {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* v0.5: minimal login, ticket classifications and live team locations */
.login-overlay {
  background: linear-gradient(145deg, #eef7ff 0%, #f8fafc 52%, #eef2ff 100%);
}

.login-overlay::before {
  display: none;
}

.login-card {
  width: min(100%, 380px);
  padding: 32px;
  border-color: rgba(148, 163, 184, 0.24);
  border-radius: 22px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14);
}

.login-card .brand-mark-large {
  margin: 0 auto 16px;
}

.login-card h1 {
  font-size: clamp(28px, 7vw, 36px);
}

.login-form {
  margin-top: 24px;
  text-align: left;
}

.location-share-text {
  color: #0369a1 !important;
  font-weight: 700;
}

.ticket-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 5px 0 7px;
}

.type-badge,
.province-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 8px;
  font-weight: 850;
  line-height: 1.1;
  white-space: nowrap;
}

.type-badge.type-ev {
  color: #075985;
  background: #e0f2fe;
}

.type-badge.type-bss {
  color: #166534;
  background: #dcfce7;
}

.type-badge.type-other {
  color: var(--ink-600);
  background: var(--ink-100);
}

.province-badge {
  max-width: 190px;
  overflow: hidden;
  color: #5b21b6;
  background: #ede9fe;
  text-overflow: ellipsis;
}

.ticket-claim-badge {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  overflow: hidden;
  padding: 4px 7px;
  border-radius: 999px;
  background: #fef3c7;
  color: #854d0e;
  font-size: 8px;
  font-weight: 850;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popup-field strong.type-badge {
  display: inline-flex;
  font-size: 9px;
}

.ticket-owner {
  display: -webkit-box;
  overflow: hidden;
  margin: 7px 0 0;
  color: var(--ink-500);
  font-size: 9px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.ticket-owner b {
  color: var(--ink-700);
}

.map-top-actions {
  display: flex;
  gap: 8px;
}

.map-action-button.is-active {
  border-color: #93c5fd;
  color: #1d4ed8;
  background: rgba(239, 246, 255, 0.98);
}

.team-role-toggle {
  min-height: 38px;
  padding-inline: 10px;
}

.team-role-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.13);
}

.team-role-dot.role-cse {
  background: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.13);
}

.team-role-toggle.role-se.is-active {
  border-color: #7dd3fc;
  color: #0369a1;
  background: rgba(240, 249, 255, 0.98);
}

.team-role-toggle.role-cse.is-active {
  border-color: #c4b5fd;
  color: #6d28d9;
  background: rgba(245, 243, 255, 0.98);
}

.team-role-toggle:not(.is-active) {
  color: var(--ink-400);
  background: rgba(255, 255, 255, 0.88);
  opacity: 0.82;
}

.team-location-marker {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 3px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: #0284c7;
  box-shadow: 0 5px 18px rgba(15, 23, 42, 0.3);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.team-location-marker.team-role-cse {
  background: #7c3aed;
}

.team-location-marker > span {
  transform: translateY(-1px);
}

.team-location-marker > small {
  position: absolute;
  right: -5px;
  bottom: -5px;
  min-width: 22px;
  padding: 2px 4px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #075985;
  color: #fff;
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.22);
  font-size: 7px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.team-location-marker.team-role-cse > small {
  background: #5b21b6;
}

.team-location-marker.team-status-online {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.28), 0 5px 18px rgba(15, 23, 42, 0.3);
}

.team-location-marker.team-status-stale {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.34), 0 5px 18px rgba(15, 23, 42, 0.25);
  filter: saturate(0.72);
}

.team-location-marker.team-status-offline {
  background: #64748b;
  opacity: 0.76;
  filter: grayscale(0.55);
}

.team-location-marker.team-status-offline > small {
  background: #475569;
}

.team-location-marker-small {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-width: 2px;
}

.team-popup header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.team-popup header strong,
.team-popup header small {
  display: block;
}

.team-popup header strong {
  font-size: 14px;
}

.team-popup header small {
  margin-top: 2px;
  color: var(--ink-500);
  font-size: 10px;
}

.legend-divider {
  height: 1px;
  margin: 2px 0;
  background: var(--border);
}

.legend-dot.team-role-se { background: #0284c7; }
.legend-dot.team-role-cse { background: #7c3aed; }
.legend-dot.team-stale { background: #d97706; }
.legend-dot.team-offline { background: #64748b; }

.multi-filter-panel-owner,
.multi-filter.align-right .multi-filter-panel-owner {
  position: fixed;
  z-index: 1601;
  top: calc(env(safe-area-inset-top, 0px) + 72px);
  right: auto;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  left: 50%;
  display: flex;
  width: min(680px, calc(100vw - 24px));
  min-width: 0;
  max-height: none;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  transform: translateX(-50%);
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.18), 0 24px 70px rgba(2, 8, 23, 0.28);
}

body.owner-filter-open {
  overflow: hidden;
}

body.owner-filter-open .sidebar {
  overflow: visible;
}

#ownerFilter[open] {
  z-index: 1600;
}

.multi-filter-panel-owner .multi-filter-actions {
  flex: 0 0 auto;
  padding: 10px;
  background: var(--surface);
}

.multi-filter-panel-owner .multi-filter-options-scroll {
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
  padding: 8px;
  overflow-y: auto;
  background: var(--surface);
}

.owner-group-option {
  align-items: flex-start;
  min-height: 46px;
  border: 1px solid transparent;
}

.owner-group-option:has(input:checked) {
  border-color: #bae6fd;
}

.owner-group-label {
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: break-word;
  line-height: 1.42;
}

.owner-group-count {
  flex: 0 0 auto;
  float: none !important;
  margin: 2px 0 0 8px !important;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--ink-100);
  color: var(--ink-500) !important;
  font-variant-numeric: tabular-nums;
}

.map-top-actions {
  max-width: calc(100% - 28px);
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (min-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(390px, 460px) minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .map-top-actions {
    gap: 5px;
  }

  .team-location-marker {
    width: 36px;
    height: 36px;
  }

  .team-role-toggle {
    min-height: 36px;
    padding-inline: 8px;
    font-size: 10px;
  }
}

/* v0.5.4: Excel-like search inside the Ticket Owner group picker. */
.owner-filter-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding: 10px;
  border-bottom: 1px solid var(--ink-100);
  background: var(--surface);
}

.owner-filter-search-box {
  display: flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--ink-50);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.owner-filter-search-box:focus-within {
  border-color: #38bdf8;
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.14);
}

.owner-filter-search-icon {
  flex: 0 0 auto;
  color: var(--ink-400);
  font-size: 19px;
  line-height: 1;
  transform: rotate(-18deg);
}

.owner-filter-search-box input {
  min-width: 0;
  flex: 1 1 auto;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-900);
  font: inherit;
  font-size: 12px;
}

.owner-filter-search-box input::placeholder {
  color: var(--ink-400);
}

.owner-filter-search-box input::-webkit-search-cancel-button {
  display: none;
}

.owner-filter-search-clear {
  display: inline-grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: var(--ink-100);
  color: var(--ink-600);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.owner-filter-search-clear[hidden] {
  display: none !important;
}

.owner-filter-search-clear:hover,
.owner-filter-search-clear:focus-visible {
  background: var(--ink-200);
  color: var(--ink-900);
}

.owner-filter-search-meta {
  color: var(--ink-500);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.owner-filter-results {
  min-height: 0;
  flex: 1 1 auto;
  padding: 8px;
  overflow-y: auto;
  background: var(--surface);
}

.owner-filter-results .multi-filter-options {
  padding-top: 0;
}

.owner-group-option.is-search-hidden {
  display: none !important;
}

.owner-filter-empty {
  margin: 18px 8px;
  padding: 18px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--ink-50);
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
}

.owner-filter-empty[hidden] {
  display: none !important;
}

@media (max-width: 430px) {
  .owner-filter-search {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .owner-filter-search-meta {
    justify-self: start;
    padding-left: 2px;
  }
}


/* v0.6.1: location permission gate and 24-hour admin activity panel. */
.location-gate {
  display: grid;
  min-height: calc(100dvh - 70px);
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(14, 165, 233, 0.16), transparent 34%),
    radial-gradient(circle at 80% 75%, rgba(34, 197, 94, 0.11), transparent 32%),
    linear-gradient(145deg, #f8fafc, #e0f2fe);
}

.location-gate-card {
  width: min(100%, 520px);
  padding: 34px;
  border: 1px solid rgba(14, 165, 233, 0.22);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.16);
  text-align: center;
}

.location-gate-icon {
  display: grid;
  width: 70px;
  height: 70px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 22px;
  color: #fff;
  background: linear-gradient(145deg, var(--brand-500), var(--brand-700));
  box-shadow: 0 12px 30px rgba(2, 132, 199, 0.28);
  font-size: 34px;
  font-weight: 900;
}

.location-gate-card h2 {
  margin: 0;
  color: var(--ink-950);
  font-size: clamp(24px, 5vw, 34px);
  letter-spacing: -0.035em;
}

.location-gate-card > p:not(.eyebrow):not(.location-gate-status) {
  margin: 14px auto 0;
  color: var(--ink-600);
  line-height: 1.65;
}

.location-gate-card .button {
  width: 100%;
  margin-top: 18px;
}

.location-gate-card > small {
  display: block;
  margin-top: 14px;
  color: var(--ink-500);
  font-size: 11px;
  line-height: 1.55;
}

.location-gate-status {
  margin: 18px 0 0;
  padding: 11px 13px;
  border: 1px solid #bae6fd;
  border-radius: 12px;
  color: #075985;
  background: #f0f9ff;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.45;
}

.location-gate-status[data-mode="loading"] {
  border-color: #fde68a;
  color: #92400e;
  background: #fffbeb;
}

.location-gate-status[data-mode="success"] {
  border-color: #bbf7d0;
  color: #166534;
  background: #f0fdf4;
}

.location-gate-status[data-mode="error"] {
  border-color: #fecaca;
  color: #991b1b;
  background: #fef2f2;
}

.activity-log-button.is-active {
  border-color: #c4b5fd;
  color: #6d28d9;
  background: rgba(245, 243, 255, 0.98);
}

.admin-activity-panel {
  position: absolute;
  z-index: 650;
  top: 68px;
  right: 14px;
  bottom: 58px;
  display: flex;
  width: min(350px, calc(100% - 28px));
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 20px 55px rgba(15, 23, 42, 0.24);
  backdrop-filter: blur(16px);
}

.admin-activity-header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(145deg, #fff, #f5f3ff);
}

.admin-activity-header h2 {
  margin: 0;
  color: var(--ink-900);
  font-size: 15px;
  letter-spacing: -0.01em;
}

.admin-activity-header .eyebrow {
  margin-bottom: 4px;
  color: #6d28d9;
  font-size: 9px;
}

.admin-activity-header small {
  display: block;
  margin-top: 5px;
  color: var(--ink-500);
  font-size: 9px;
  line-height: 1.4;
}

.admin-activity-close {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--ink-600);
  font-size: 20px;
  line-height: 1;
}

.admin-activity-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
}

.admin-activity-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--ink-100);
}

.admin-activity-row:last-child {
  border-bottom: 0;
}

.admin-activity-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: #0284c7;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.admin-activity-avatar.role-cse {
  background: #7c3aed;
}

.admin-activity-avatar.role-admin {
  background: #0f172a;
}

.admin-activity-copy {
  min-width: 0;
}

.admin-activity-name {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.admin-activity-name strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-800);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-activity-name span {
  flex: 0 0 auto;
  padding: 2px 5px;
  border-radius: 999px;
  color: #475569;
  background: var(--ink-100);
  font-size: 7px;
  font-weight: 900;
}

.admin-activity-copy small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--ink-500);
  font-size: 8px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-presence {
  max-width: 78px;
  padding: 4px 6px;
  border-radius: 999px;
  color: #475569;
  background: var(--ink-100);
  font-size: 7px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
}

.admin-presence.is-online {
  color: #166534;
  background: #dcfce7;
}

.admin-presence.is-stale {
  color: #92400e;
  background: #fef3c7;
}

.admin-presence.is-offline {
  color: #475569;
  background: #e2e8f0;
}

.admin-presence.is-no-location {
  color: #9a3412;
  background: #ffedd5;
}

.admin-activity-empty {
  margin: 10px;
  padding: 20px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--ink-500);
  background: var(--ink-50);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

@media (max-width: 760px) {
  .location-gate {
    min-height: calc(100dvh - 64px);
    padding: 14px;
  }

  .location-gate-card {
    padding: 26px 20px;
    border-radius: 22px;
  }

  .admin-activity-panel {
    top: 58px;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
  }

  .activity-log-button span {
    display: none;
  }
}

@media (min-width: 1100px) {
  .map-panel.admin-activity-open .map-legend {
    right: 378px;
  }
}

/* v0.8.5: reliable claim-state transitions plus rechecked mobile interactions. */
.filter-sheet-handle {
  display: none;
}

.popup-issue-button {
  display: grid;
  width: 100%;
  gap: 5px;
  margin-top: 3px;
  padding: 9px 10px;
  border: 1px solid #bae6fd;
  border-radius: 10px;
  background: #f0f9ff;
  color: var(--ink-800);
  text-align: left;
  cursor: pointer;
}

.popup-issue-button span {
  color: var(--ink-800);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.4;
  text-transform: none;
}

.popup-issue-button small {
  color: var(--brand-700);
  font-size: 9px;
  font-weight: 850;
}

.popup-issue-button:hover,
.popup-issue-button:focus-visible {
  border-color: var(--brand-500);
  outline: none;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.14);
}

.popup-field .type-badge,
.ticket-tags .type-badge {
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
}

.upload-card-guide {
  border-color: #c4b5fd;
  background: #f5f3ff;
}

.upload-card-guide .upload-step {
  background: #6d28d9;
}

.troubleshooting-modal {
  width: min(860px, calc(100% - 24px));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.troubleshooting-shell {
  display: block;
  min-height: 100%;
  max-height: none;
  overflow: visible;
}

.troubleshooting-header {
  position: sticky;
  z-index: 4;
  top: -24px;
  padding-bottom: 15px;
  background: var(--surface);
}

.troubleshooting-content {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: auto;
  padding: 16px 3px 16px 0;
  overflow: visible;
}

.troubleshooting-loading,
.troubleshooting-empty {
  padding: 26px 18px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: var(--ink-50);
  color: var(--ink-600);
  text-align: center;
}

.troubleshooting-empty strong {
  display: block;
  color: var(--ink-900);
  font-size: 15px;
}

.troubleshooting-empty p {
  margin: 7px 0 0;
  font-size: 12px;
  line-height: 1.55;
}

.troubleshooting-empty.is-error {
  border-color: #fecaca;
  background: #fef2f2;
}

.troubleshooting-missing {
  border-color: #fde68a;
  background: #fffbeb;
}

.troubleshooting-guide-card {
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.troubleshooting-guide-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  border-radius: 15px 15px 0 0;
  background: linear-gradient(145deg, #f0f9ff, #fff);
}

.troubleshooting-code {
  color: var(--brand-700);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.troubleshooting-guide-card h3 {
  margin-top: 4px;
  font-size: 16px;
  line-height: 1.35;
}

.troubleshooting-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.troubleshooting-badges span,
.troubleshooting-parts span {
  padding: 4px 7px;
  border-radius: 999px;
  background: var(--ink-100);
  color: var(--ink-700);
  font-size: 9px;
  font-weight: 750;
}

.troubleshooting-badges .troubleshooting-mode {
  color: #075985;
  background: #e0f2fe;
}

.troubleshooting-section {
  padding: 14px 16px;
}

.troubleshooting-section h4 {
  margin-bottom: 8px;
  color: var(--ink-700);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.troubleshooting-primary {
  border-bottom: 0;
}

.troubleshooting-pre {
  max-height: none;
  overflow: visible;
  color: var(--ink-800);
  font-size: 12px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
}

.troubleshooting-details {
  border-top: 1px solid var(--border);
}

.troubleshooting-details summary {
  padding: 13px 16px;
  color: var(--brand-700);
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.troubleshooting-details[open] summary {
  border-bottom: 1px solid var(--border);
  background: var(--ink-50);
}

.troubleshooting-meta {
  display: grid;
  gap: 8px;
  padding: 13px 16px;
}

.troubleshooting-meta div {
  display: grid;
  grid-template-columns: minmax(110px, 0.32fr) 1fr;
  gap: 10px;
}

.troubleshooting-meta dt {
  color: var(--ink-500);
  font-size: 10px;
  font-weight: 800;
}

.troubleshooting-meta dd {
  margin: 0;
  color: var(--ink-800);
  font-size: 11px;
  white-space: pre-wrap;
}

.troubleshooting-parts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 14px;
}

.troubleshooting-notice {
  margin: 14px 16px;
  padding: 12px;
  border-radius: 10px;
  background: #fffbeb;
  color: #92400e;
  font-size: 11px;
}

.troubleshooting-safety {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid #fde68a;
  border-radius: 12px;
  background: #fffbeb;
  color: #78350f;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.45;
}

@media (min-width: 761px) {
  .import-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    overflow: hidden;
  }

  .workspace {
    position: relative;
    display: block;
    height: calc(100dvh - 62px);
    min-height: 0;
    overflow: hidden;
  }

  .map-panel {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: auto;
    min-height: 0;
  }

  .sidebar {
    position: absolute;
    inset: 10px 0 0;
    z-index: 20;
    height: calc(100% - 10px);
    padding: 0 12px calc(18px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 22px 22px 0 0;
    background: rgba(248, 250, 252, 0.985);
    box-shadow: 0 -18px 48px rgba(15, 23, 42, 0.2);
    will-change: transform;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .sidebar.sheet-collapsed {
    transform: translate3d(0, calc(100% - 74px), 0);
  }

  .sidebar.sheet-mid {
    transform: translate3d(0, 48%, 0);
  }

  .sidebar.sheet-expanded {
    transform: translate3d(0, 0, 0);
  }

  .sidebar.is-dragging {
    user-select: none;
  }

  .filter-sheet-handle {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: 15px auto;
    align-items: center;
    width: calc(100% + 24px);
    min-height: 64px;
    margin: 0 -12px 10px;
    padding: 5px 18px 10px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.98);
    color: var(--ink-900);
    text-align: left;
    touch-action: none;
    cursor: ns-resize;
  }

  .filter-sheet-grip {
    grid-column: 1 / -1;
    justify-self: center;
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: var(--ink-300);
  }

  .filter-sheet-title {
    font-size: 12px;
    font-weight: 850;
  }

  .filter-sheet-state {
    color: var(--brand-700);
    font-size: 9px;
    font-weight: 750;
  }

  .search-box input,
  .owner-filter-search-box input {
    font-size: 16px;
  }

  .search-box,
  #statusFilter > summary,
  #provinceFilter > summary,
  #ownerFilter > summary {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar .location-card {
    margin-top: 0;
  }

  .data-banner {
    bottom: 82px;
  }

  .map-legend {
    bottom: 122px;
  }

  .leaflet-bottom {
    bottom: 76px;
  }

  .troubleshooting-modal {
    width: calc(100% - 14px);
    height: calc(100vh - 14px);
    height: calc(100dvh - 14px);
    max-height: calc(100dvh - 14px);
    border-radius: 18px;
  }

  .troubleshooting-shell {
    height: auto;
    min-height: 100%;
    max-height: none;
    padding: 16px;
  }

  .troubleshooting-header {
    top: -16px;
    padding-top: 2px;
  }

  .troubleshooting-content {
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }

  .multi-filter-panel-owner,
  .multi-filter.align-right .multi-filter-panel-owner {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    bottom: auto;
    height: calc(var(--mobile-visual-viewport-height, 100dvh) - env(safe-area-inset-top, 0px) - 16px);
    max-height: calc(var(--mobile-visual-viewport-height, 100dvh) - env(safe-area-inset-top, 0px) - 16px);
  }

  .troubleshooting-guide-card > header {
    flex-direction: column;
  }

  .troubleshooting-badges {
    justify-content: flex-start;
  }
}
