:root {
    --navy: #0b1d3a;
    --navy-soft: #12315d;
    --blue: #0b3475;
    --blue-hover: #082b62;
    --brand-gold: #dda919;
    --green: #16a34a;
    --green-hover: #15803d;
    --amber: #f59e0b;
    --red: #dc2626;
    --red-hover: #b91c1c;
    --ink: #172033;
    --muted: #64748b;
    --line: #dbe3ef;
    --canvas: #f8fafc;
    --panel: #ffffff;
    --blue-soft: #eff6ff;
    --green-soft: #ecfdf3;
    --amber-soft: #fffbeb;
    --red-soft: #fef2f2;
    --sidebar-width: 192px;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

html {
    min-width: 320px;
    background: var(--canvas);
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-size: 14px;
}

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

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

a {
    color: inherit;
    text-decoration: none;
}

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

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    width: var(--sidebar-width);
    min-height: 100vh;
    flex-direction: column;
    overflow-y: auto;
    color: #dbe7ff;
    background: var(--navy);
}

.app-brand {
    display: flex;
    min-height: 78px;
    align-items: center;
    gap: 10px;
    padding: 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-logo {
    display: block;
    width: 100%;
    height: auto;
}

.brand-logo-full {
    width: 158px;
    max-height: 48px;
    object-fit: contain;
    object-position: left center;
}

.brand-logo-mark {
    display: none;
    width: 34px;
    height: 34px;
}

.brand-mark {
    display: grid;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    place-items: center;
    border-radius: 7px;
    color: #fff;
    background: var(--blue);
    font-size: 18px;
    font-weight: 800;
}

.brand-copy {
    display: grid;
    min-width: 0;
}

.brand-copy strong {
    color: #fff;
    font-size: 16px;
    letter-spacing: 2px;
}

.brand-copy small {
    margin-top: 2px;
    overflow: hidden;
    color: #94a3b8;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-nav {
    display: grid;
    gap: 3px;
    padding: 14px 10px;
}

.app-nav a {
    display: flex;
    min-height: 38px;
    align-items: center;
    gap: 11px;
    padding: 8px 10px;
    border-radius: 5px;
    color: #cbd5e1;
    transition: background 150ms ease, color 150ms ease;
}

.app-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.app-nav a.active {
    color: #fff;
    background: var(--blue);
    font-weight: 650;
    box-shadow: inset 3px 0 var(--brand-gold);
}

.app-nav svg,
.logout-link svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

.sidebar-account {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) 28px;
    gap: 8px;
    align-items: center;
    margin-top: auto;
    padding: 14px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.account-avatar {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 50%;
    color: #1e3a8a;
    background: #dbeafe;
    font-size: 12px;
    font-weight: 800;
}

.account-copy {
    display: grid;
    min-width: 0;
}

.account-copy strong,
.account-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-copy strong {
    color: #fff;
    font-size: 11px;
}

.account-copy small {
    margin-top: 2px;
    color: #94a3b8;
    font-size: 9px;
}

.logout-link {
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 4px;
    color: #94a3b8;
}

.logout-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.app-main {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    padding: 24px 28px 40px;
}

.page-header {
    display: flex;
    min-height: 58px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.page-header h1 {
    margin: 2px 0 0;
    color: #111827;
    font-size: 24px;
    line-height: 1.2;
}

.page-header p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.eyebrow {
    color: var(--blue);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.header-actions,
.toolbar,
.filter-row,
.button-row,
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.header-actions {
    justify-content: flex-end;
}

.export-dropdown {
    position: relative;
}

.export-dropdown > summary {
    list-style: none;
    cursor: pointer;
}

.export-dropdown > summary::-webkit-details-marker {
    display: none;
}

.export-dropdown > summary svg:last-child {
    width: 15px;
    transition: transform 0.15s ease;
}

.export-dropdown[open] > summary svg:last-child {
    transform: rotate(180deg);
}

.export-dropdown-menu {
    position: absolute;
    z-index: 50;
    top: calc(100% + 7px);
    right: 0;
    display: grid;
    min-width: 220px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 6px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
}

.export-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 4px;
    color: var(--ink);
    padding: 9px 10px;
    text-decoration: none;
}

.export-dropdown-menu a:hover,
.export-dropdown-menu a:focus-visible {
    background: #f1f5fb;
    outline: none;
}

.export-dropdown-menu svg {
    width: 18px;
    color: var(--blue);
}

.export-dropdown-menu span {
    display: grid;
    gap: 1px;
}

.export-dropdown-menu small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.btn {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 13px;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: #263247;
    background: #fff;
    font-weight: 650;
    line-height: 1;
    cursor: pointer;
}

.btn:hover {
    border-color: #aebbd0;
    background: #f8fafc;
}

.btn svg {
    width: 15px;
    height: 15px;
}

.btn-primary {
    border-color: var(--blue);
    color: #fff;
    background: var(--blue);
}

.btn-primary:hover {
    border-color: var(--blue-hover);
    background: var(--blue-hover);
}

.btn-success {
    border-color: var(--green);
    color: #fff;
    background: var(--green);
}

.btn-success:hover,
.btn-success:focus-visible {
    border-color: var(--green-hover);
    color: #fff;
    background: var(--green-hover);
}

.btn-danger {
    border-color: var(--red);
    color: #fff;
    background: var(--red);
}

.btn-danger:hover,
.btn-danger:focus-visible {
    border-color: var(--red-hover);
    color: #fff;
    background: var(--red-hover);
}

.btn-sm {
    min-height: 29px;
    padding: 5px 9px;
    font-size: 12px;
}

.btn-icon {
    width: 32px;
    padding: 0;
}

.panel {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 15px 17px;
    border-bottom: 1px solid var(--line);
}

.panel-header h2,
.panel-header h3 {
    margin: 0;
    font-size: 16px;
}

.panel-body {
    padding: 16px 17px;
}

.stack {
    display: grid;
    gap: 14px;
}

.grid-2,
.grid-3,
.grid-4 {
    display: grid;
    gap: 12px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card {
    min-height: 92px;
    padding: 15px 16px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.kpi-card span {
    color: var(--muted);
    font-size: 12px;
}

.kpi-card strong {
    display: block;
    margin-top: 9px;
    color: #111827;
    font-size: 25px;
    line-height: 1;
}

.kpi-card small {
    display: block;
    margin-top: 7px;
    color: var(--green);
    font-size: 10px;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.field,
.field-inline {
    display: grid;
    gap: 5px;
}

.field label,
.field-inline label {
    color: #475569;
    font-size: 11px;
    font-weight: 700;
}

.field-inline {
    min-width: 150px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 34px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 4px;
    outline: none;
    background: #fff;
}

textarea {
    min-height: 82px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    min-height: 16px;
    accent-color: var(--blue);
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.data-table th,
.data-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: #64748b;
    background: #fbfdff;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    font-size: 12px;
}

.data-table tbody tr:hover {
    background: #f8fbff;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.cell-main {
    display: flex;
    min-width: 150px;
    align-items: center;
    gap: 9px;
}

.cell-main strong,
.cell-main small {
    display: block;
}

.cell-main small {
    margin-top: 2px;
    color: var(--muted);
}

.mini-avatar {
    display: grid;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    place-items: center;
    border-radius: 50%;
    color: #1d4ed8;
    background: #dbeafe;
    font-size: 10px;
    font-weight: 800;
}

.badge {
    display: inline-flex;
    min-height: 22px;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    color: #334155;
    background: #eef2f7;
    font-size: 10px;
    font-weight: 750;
    white-space: nowrap;
}

.badge-success {
    color: #166534;
    background: var(--green-soft);
}

.badge-info {
    color: #1d4ed8;
    background: var(--blue-soft);
}

.badge-warning {
    color: #92400e;
    background: var(--amber-soft);
}

.badge-danger {
    color: #991b1b;
    background: var(--red-soft);
}

.notice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid #bfdbfe;
    border-radius: 5px;
    color: #1e40af;
    background: var(--blue-soft);
    font-size: 12px;
}

.notice svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

.notice-error {
    border-color: #fecaca;
    color: #991b1b;
    background: var(--red-soft);
}

.notice-warning {
    border-color: #fde68a;
    color: #92400e;
    background: var(--amber-soft);
}

.tabs {
    border-bottom: 1px solid var(--line);
}

.tabs a,
.tabs button {
    padding: 9px 3px;
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.tabs a.active,
.tabs button.active {
    border-bottom-color: var(--blue);
    color: var(--blue);
    font-weight: 700;
}

.chart-panel {
    min-height: 220px;
}

.bar-chart {
    display: grid;
    grid-template-columns: repeat(var(--bar-count, 1), minmax(28px, 1fr));
    height: 168px;
    gap: clamp(4px, 1.2vw, 18px);
    overflow-x: auto;
    padding: 0 clamp(4px, 1vw, 10px);
}

.bar-chart-item {
    display: grid;
    min-width: 0;
    grid-template-rows: 120px 48px;
}

.bar-plot {
    display: flex;
    min-width: 0;
    align-items: flex-end;
    justify-content: center;
    border-bottom: 1px solid var(--line);
}

.bar-fill {
    display: block;
    width: min(55px, 62%);
    min-height: 4px;
    border-radius: 4px 4px 0 0;
    background: var(--blue);
}

.bar-fill.is-zero {
    height: 4px !important;
    opacity: 0.9;
}

.bar-chart-item:nth-child(2) .bar-fill {
    background: var(--green);
}

.bar-chart-item:nth-child(3) .bar-fill {
    background: #94a3b8;
}

.bar-label {
    display: grid;
    min-width: 0;
    align-content: start;
    justify-items: center;
    gap: 1px;
    padding-top: 6px;
    color: var(--muted);
    text-align: center;
}

.bar-label strong {
    display: -webkit-box;
    max-width: 100%;
    overflow: hidden;
    font-size: 10px;
    font-weight: 500;
    line-height: 12px;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.bar-label small {
    color: var(--muted);
    font-size: 10px;
    line-height: 12px;
}

.trend-chart {
    position: relative;
    height: 160px;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
    background: #fbfdff;
}

.trend-line {
    position: absolute;
    left: 8%;
    right: 8%;
    height: 2px;
    transform-origin: left center;
    background: var(--blue);
}

.trend-line.green {
    background: var(--green);
}

.empty-state {
    display: grid;
    min-height: 210px;
    place-items: center;
    padding: 24px;
    color: var(--muted);
    text-align: center;
}

.empty-state svg {
    width: 36px;
    height: 36px;
    margin-bottom: 8px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 14px;
}

.span-2 {
    grid-column: 1 / -1;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.profile-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.profile-header .mini-avatar {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
    font-size: 14px;
}

.profile-header .profile-copy {
    min-width: 200px;
    flex: 1;
}

.profile-copy h2 {
    margin: 0;
    font-size: 17px;
}

.profile-copy p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.timeline {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.timeline li {
    position: relative;
    padding: 0 0 16px 21px;
}

.timeline li::before {
    position: absolute;
    top: 4px;
    left: 2px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--blue);
    content: "";
}

.timeline li::after {
    position: absolute;
    top: 13px;
    bottom: 0;
    left: 5px;
    width: 1px;
    background: var(--line);
    content: "";
}

.timeline li:last-child::after {
    display: none;
}

.timeline strong,
.timeline small {
    display: block;
}

.timeline small {
    margin-top: 3px;
    color: var(--muted);
}

.calendar-grid {
    display: grid;
    min-width: 820px;
    grid-template-columns: 66px repeat(5, minmax(135px, 1fr));
    border: 1px solid var(--line);
    background: #fff;
}

.route-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
    min-width: 0;
}

.route-calendar-day {
    grid-template-columns: minmax(0, 720px);
    min-width: 0;
}

.route-calendar-month {
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.route-calendar-wrap {
    overflow-x: auto;
}

.calendar-day {
    min-width: 0;
    min-height: 150px;
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
}

.calendar-day.today {
    border-color: var(--blue);
}

.calendar-day.selected {
    outline: 2px solid var(--blue);
    outline-offset: -2px;
}

.calendar-day > header {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    color: var(--muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}

.calendar-day > header a {
    color: inherit;
    text-decoration: none;
}

.calendar-events {
    display: grid;
    gap: 6px;
    padding: 8px;
}

.calendar-events .route-block {
    display: grid;
    min-height: 0;
    min-width: 0;
    overflow-wrap: anywhere;
}

.calendar-events .route-block small {
    color: inherit;
}

.calendar-empty {
    padding: 10px 2px;
    color: var(--muted);
    font-size: 12px;
}

.calendar-grid > div {
    min-height: 74px;
    padding: 8px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.calendar-grid .calendar-head,
.calendar-grid .calendar-time {
    min-height: 34px;
    color: var(--muted);
    background: #f8fafc;
    font-size: 10px;
    font-weight: 750;
}

.route-block {
    display: block;
    padding: 7px;
    border-left: 3px solid var(--blue);
    border-radius: 3px;
    color: #1e40af;
    background: var(--blue-soft);
    font-size: 10px;
}

.route-block.green {
    border-left-color: var(--green);
    color: #166534;
    background: var(--green-soft);
}

.route-block.amber {
    border-left-color: var(--amber);
    color: #92400e;
    background: var(--amber-soft);
}

.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 18px;
}

.step {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.step::before {
    display: grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: #fff;
    content: attr(data-step);
}

.step.complete::before {
    border-color: var(--green);
    color: #fff;
    background: var(--green);
    content: "✓";
}

.step.active {
    color: var(--blue);
}

.step.active::before {
    border-color: var(--blue);
    color: #fff;
    background: var(--blue);
}

.step-line {
    width: 55px;
    height: 1px;
    margin: 0 8px;
    background: var(--line);
}

.question-builder {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr) 220px;
    gap: 12px;
}

.builder-tools,
.question-card,
.properties-panel {
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fff;
}

.builder-tools {
    display: grid;
    align-content: start;
    gap: 7px;
}

.builder-tools button {
    padding: 8px;
    border: 0;
    color: var(--blue);
    background: var(--blue-soft);
    text-align: left;
    cursor: pointer;
}

.question-list {
    display: grid;
    gap: 10px;
}

.question-card.active {
    border-color: var(--blue);
    box-shadow: 0 0 0 1px var(--blue);
}

.gallery {
    display: grid;
    grid-template-columns: repeat(4, minmax(170px, 1fr));
    gap: 12px;
}

.evidence-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fff;
}

.evidence-preview {
    position: relative;
    display: grid;
    aspect-ratio: 16 / 10;
    place-items: center;
    overflow: hidden;
    color: #64748b;
    background: #dbe3ed;
}

.evidence-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.evidence-preview-action {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 4px;
    color: #fff;
    background: rgba(15, 23, 42, .82);
    font-size: 10px;
    font-weight: 750;
}

.evidence-preview .evidence-preview-action svg {
    width: 14px;
    height: 14px;
}

.image-viewer-dialog {
    width: min(1100px, calc(100vw - 32px));
    max-height: calc(100vh - 28px);
    overflow: hidden;
    background: #fff;
}

.image-viewer-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.image-viewer-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.image-viewer-stage {
    position: relative;
    display: grid;
    min-height: 420px;
    max-height: calc(100vh - 120px);
    place-items: center;
    overflow: auto;
    padding: 18px;
    color: #cbd5e1;
    background: #111827;
}

.image-viewer-stage img {
    display: none;
    max-width: 100%;
    max-height: calc(100vh - 158px);
    object-fit: contain;
}

.image-viewer-stage.loaded img {
    display: block;
}

.image-viewer-loading {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.image-viewer-stage.loaded .image-viewer-loading,
.image-viewer-stage.failed .image-viewer-loading {
    display: none;
}

.image-viewer-error {
    display: none;
}

.image-viewer-stage.failed .image-viewer-error {
    display: block;
}

@media (max-width: 700px) {
    .image-viewer-dialog {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
    }

    .image-viewer-stage {
        min-height: 300px;
        padding: 8px;
    }
}

.evidence-preview svg {
    width: 34px;
    height: 34px;
}

.evidence-card figcaption {
    padding: 10px;
    font-size: 11px;
}

.evidence-card figcaption strong,
.evidence-card figcaption small {
    display: block;
}

.evidence-card figcaption small {
    margin-top: 4px;
    color: var(--muted);
}

.tracking-toolbar {
    margin-bottom: 12px;
}

.tracking-toolbar .filter-bar {
    grid-template-columns: minmax(220px, 1fr) 190px auto 36px auto auto;
}

.tracking-auto {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.tracking-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.tracking-layout {
    display: grid;
    grid-template-columns: minmax(520px, 1fr) minmax(285px, 340px);
    gap: 12px;
}

.tracking-map-panel,
.tracking-users-panel {
    min-width: 0;
}

.tracking-date-field {
    width: 165px;
}

#tracking-map {
    width: 100%;
    height: min(580px, calc(100vh - 330px));
    min-height: 440px;
    border-block: 1px solid var(--line);
    background: #e8eef4;
}

.tracking-map-detail {
    display: grid;
    min-height: 76px;
    grid-template-columns: auto minmax(150px, 1fr) repeat(4, minmax(90px, auto));
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
}

.tracking-map-detail > span:not(.tracking-avatar) {
    display: grid;
    min-width: 0;
}

.tracking-map-detail small {
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tracking-detail-empty {
    grid-column: 1 / -1;
    color: var(--muted);
    text-align: center;
}

.tracking-user-list {
    height: min(656px, calc(100vh - 254px));
    min-height: 516px;
    overflow-y: auto;
}

.tracking-user {
    display: grid;
    width: 100%;
    min-height: 68px;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.tracking-user:hover,
.tracking-user.active {
    background: var(--blue-soft);
}

.tracking-user.active {
    box-shadow: inset 3px 0 var(--blue);
}

.tracking-avatar {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: #334155;
    font-size: 12px;
    font-weight: 800;
}

.tracking-user-copy {
    display: grid;
    min-width: 0;
}

.tracking-user-copy strong,
.tracking-user-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tracking-user-copy small {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
}

.tracking-signal {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    font-size: 10px;
    white-space: nowrap;
}

.tracking-signal::before {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    content: "";
}

.tracking-signal.is-online::before,
.tracking-marker.is-online {
    background: var(--green);
}

.tracking-signal.is-recent::before,
.tracking-marker.is-recent {
    background: var(--amber);
}

.tracking-signal.is-stale::before,
.tracking-signal.is-no-location::before,
.tracking-signal.is-not-installed::before,
.tracking-signal.is-disabled::before,
.tracking-marker.is-stale,
.tracking-marker.is-no-location,
.tracking-marker.is-not-installed,
.tracking-marker.is-disabled {
    background: #64748b;
}

.tracking-disabled-notice { margin-bottom: 12px; }

.tracking-marker-shell {
    border: 0;
    background: transparent;
}

.tracking-marker {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border: 3px solid #fff;
    border-radius: 50%;
    color: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.26);
    font-size: 11px;
    font-weight: 800;
}

#tracking-refresh.is-loading svg {
    animation: tracking-spin 0.8s linear infinite;
}

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

.report-cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.report-card {
    display: grid;
    grid-template-columns: 36px 1fr auto;
    gap: 12px;
    align-items: center;
    min-height: 84px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.report-icon {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 6px;
    color: var(--blue);
    background: var(--blue-soft);
}

.report-icon svg {
    width: 18px;
    height: 18px;
}

.report-card h3 {
    margin: 0;
    font-size: 13px;
}

.report-card p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 10px;
}

dialog {
    width: min(720px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    padding: 0;
    overflow: auto;
    border: 0;
    border-radius: 7px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

dialog::backdrop {
    background: rgba(15, 23, 42, 0.48);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 17px;
    border-bottom: 1px solid var(--line);
}

.modal-header h2 {
    margin: 0;
    font-size: 16px;
}

.modal-body {
    padding: 17px;
}

.visits-table {
    min-width: 1180px;
}

.visit-location-button {
    white-space: nowrap;
}

.visit-location-dialog {
    width: min(920px, calc(100vw - 32px));
}

.visit-location-context {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.visit-location-body {
    display: grid;
    gap: 14px;
}

.visit-location-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 6px;
}

.visit-location-summary > div {
    position: relative;
    min-width: 0;
    padding: 13px 14px 13px 34px;
    border-right: 1px solid var(--line);
}

.visit-location-summary > div:last-child {
    border-right: 0;
}

.visit-location-summary span:not(.visit-location-dot),
.visit-location-summary strong,
.visit-location-summary small {
    display: block;
}

.visit-location-summary span:not(.visit-location-dot) {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.visit-location-summary strong {
    margin-top: 5px;
    font-size: 12px;
}

.visit-location-summary small {
    margin-top: 3px;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 10px;
}

.visit-location-dot {
    position: absolute;
    top: 15px;
    left: 14px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #64748b;
}

.visit-location-dot.check-in { background: var(--blue); }
.visit-location-dot.check-out { background: var(--green); }

#visit-location-map {
    width: 100%;
    height: min(430px, 52vh);
    min-height: 320px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #eef3f8;
}

.visit-location-note {
    margin: 0;
    color: var(--muted);
    font-size: 10px;
}

@media (max-width: 700px) {
    .visit-location-summary {
        grid-template-columns: 1fr;
    }

    .visit-location-summary > div {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .visit-location-summary > div:last-child {
        border-bottom: 0;
    }

    #visit-location-map {
        min-height: 280px;
    }
}

.loading-layer {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: none;
    place-items: center;
    align-content: center;
    gap: 12px;
    color: var(--navy);
    background: rgba(248, 250, 252, 0.84);
    backdrop-filter: blur(2px);
}

.loading-layer.visible {
    display: grid;
}

.loading-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid #bfdbfe;
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 750ms linear infinite;
}

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

.text-muted {
    color: var(--muted);
}

.text-danger {
    color: var(--red);
}

.text-success {
    color: var(--green);
}

.nowrap {
    white-space: nowrap;
}

.right {
    text-align: right;
}

.auth-body {
    min-height: 100vh;
    background: #eef3f9;
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: minmax(300px, 38%) minmax(420px, 1fr);
}

.auth-brand {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(34px, 5vw, 72px);
    color: #cbd5e1;
    background: var(--navy);
}

.auth-brand h1 {
    max-width: 520px;
    margin: 12px 0;
    color: #fff;
    font-size: 36px;
    line-height: 1.14;
}

.auth-brand p {
    max-width: 520px;
    color: #94a3b8;
    font-size: 16px;
    line-height: 1.6;
}

.auth-content {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 28px;
}

.auth-card {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
}

.auth-card-brand {
    min-height: auto;
    margin-bottom: 24px;
    padding: 0;
    border: 0;
}

.auth-logo-wrap {
    min-height: auto;
    padding: 0;
    border: 0;
}

.auth-logo {
    display: block;
    width: min(260px, 100%);
    height: auto;
}

.auth-logo-inverse {
    width: min(340px, 100%);
}

.auth-card-brand .brand-copy strong {
    color: var(--navy);
}

.auth-card h2 {
    margin: 0;
    font-size: 23px;
}

.auth-card > p {
    margin: 6px 0 20px;
    color: var(--muted);
}

.auth-card .field {
    margin-top: 12px;
}

.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 14px 0;
    color: var(--muted);
    font-size: 12px;
}

.auth-options label {
    display: flex;
    align-items: center;
    gap: 6px;
}

.auth-options a {
    color: var(--blue);
}

.auth-submit {
    width: 100%;
    margin: 4px 0 10px;
}

@media (max-width: 1100px) {
    :root {
        --sidebar-width: 72px;
    }

    .brand-copy,
    .app-nav span,
    .account-copy {
        display: none;
    }

    .brand-logo-full {
        display: none;
    }

    .brand-logo-mark {
        display: block;
    }

    .app-brand {
        justify-content: center;
        padding-inline: 10px;
    }

    .app-nav a {
        justify-content: center;
    }

    .sidebar-account {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .question-builder {
        grid-template-columns: 150px minmax(0, 1fr);
    }

    .properties-panel {
        grid-column: 1 / -1;
    }

    .gallery {
        grid-template-columns: repeat(3, minmax(150px, 1fr));
    }

    .tracking-toolbar .filter-bar {
        grid-template-columns: minmax(200px, 1fr) 180px auto 36px;
    }

    .tracking-auto,
    #tracking-updated {
        grid-column: span 2;
    }

    .tracking-summary {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .tracking-layout {
        grid-template-columns: 1fr;
    }

    .tracking-user-list {
        height: auto;
        min-height: 0;
        max-height: 420px;
    }
}

@media (max-width: 760px) {
    .app-main {
        padding: 18px 14px 32px;
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

    .header-actions {
        justify-content: flex-start;
    }

    .grid-2,
    .grid-3,
    .grid-4,
    .form-grid,
    .report-cards {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: auto;
    }

    .question-builder {
        grid-template-columns: 1fr;
    }

    .properties-panel {
        grid-column: auto;
    }

    .gallery {
        grid-template-columns: repeat(2, minmax(130px, 1fr));
    }

    .auth-shell {
        grid-template-columns: 1fr;
    }

    .auth-brand {
        display: none;
    }

    .tracking-toolbar .filter-bar,
    .tracking-summary {
        grid-template-columns: 1fr;
    }

    .tracking-auto,
    #tracking-updated {
        grid-column: auto;
    }

    .tracking-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    #tracking-map {
        height: 440px;
        min-height: 360px;
    }

    .tracking-map-detail {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .tracking-map-detail > span:nth-child(n+3) {
        padding-top: 8px;
        border-top: 1px solid var(--line);
    }
}

.manual-viewer-panel {
    overflow: hidden;
}

.manual-viewer-header {
    align-items: center;
}

.manual-viewer-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.manual-viewer-header > small {
    color: var(--muted);
    white-space: nowrap;
}

.manual-viewer {
    display: block;
    width: 100%;
    height: calc(100vh - 220px);
    min-height: 620px;
    border: 0;
    background: #eef2f7;
}

.manual-viewer-fallback {
    min-height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
    padding: 28px;
    color: var(--muted);
    text-align: center;
}

.manual-viewer-fallback > svg {
    width: 42px;
    height: 42px;
}

@media (max-width: 760px) {
    .manual-viewer-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .manual-viewer {
        height: 70vh;
        min-height: 520px;
    }
}
