:root {
    --rt-page: #ffffff;
    --rt-wash: #f6f9fc;
    --rt-wash-2: #f0f4f8;
    --rt-ink: #1a1f36;
    --rt-body: #3c4257;
    --rt-muted: #697386;
    --rt-line: #e3e8ee;
    --rt-line-strong: #c1c9d2;
    --rt-purple: #635bff;
    --rt-purple-dark: #544ada;
    --rt-purple-soft: #f0efff;
    --rt-gold: #b56b00;
    --rt-green: #008a5e;
    --rt-red: #cd3d64;
    --rt-shadow: 0 2px 5px rgba(60,66,87,0.04), 0 1px 1px rgba(0,0,0,0.04);
}

body.rt-app-body {
    background: var(--rt-wash);
    color: var(--rt-body);
}

.rt-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid var(--rt-line);
    backdrop-filter: blur(12px);
}

.rt-topbar-inner {
    width: min(1180px, calc(100% - 40px));
    min-height: 58px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.rt-brand,
.rt-brand:hover {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--rt-ink);
    font-size: 0.92rem;
    font-weight: 740;
    text-decoration: none;
}

.rt-site-logo {
    display: block;
    height: 2rem;
    width: auto;
    max-width: min(11.5rem, 42vw);
}

.rt-top-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.82rem;
    font-weight: 650;
}

.rt-top-actions a {
    color: var(--rt-body);
    text-decoration: none;
}

.rt-top-actions a:hover {
    color: var(--rt-purple);
}

.rt-user-menu .dropdown-toggle::after {
    margin-left: 0.45rem;
}

.rt-user-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.35rem 0.55rem 0.35rem 0.35rem;
    border: 1px solid var(--rt-line);
    border-radius: 999px;
    background: #fff;
    color: var(--rt-ink);
    font-size: 0.82rem;
    font-weight: 650;
}

.rt-user-menu-toggle:hover,
.rt-user-menu-toggle:focus,
.rt-user-menu-toggle.show {
    color: var(--rt-purple);
    border-color: var(--rt-line-strong);
    background: var(--rt-wash);
}

.rt-user-avatar {
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--rt-purple-soft);
    color: var(--rt-purple);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.03em;
}

.rt-user-name {
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rt-user-dropdown {
    min-width: 12rem;
    border-color: var(--rt-line);
    box-shadow: var(--rt-shadow);
}

.rt-user-dropdown .dropdown-item {
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--rt-body);
}

.rt-user-dropdown .dropdown-item.active,
.rt-user-dropdown .dropdown-item:active {
    background: var(--rt-purple-soft);
    color: var(--rt-purple);
}

.rt-login-link,
.rt-login-link:hover {
    padding: 0.48rem 0.7rem;
    color: #fff !important;
    background: var(--rt-purple);
    border-radius: 4px;
}

.rt-subnav {
    background: #fff;
    border-bottom: 1px solid var(--rt-line);
}

.rt-subnav-inner {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0;
}

.rt-subnav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    flex-shrink: 0;
}

.rt-subnav-spacer {
    flex: 1 1 auto;
    min-width: 1rem;
}

.rt-subnav-cta {
    flex-shrink: 0;
    margin-left: auto;
    padding: 0.55rem 0.95rem !important;
    font-size: 0.84rem !important;
    white-space: nowrap;
}

.rt-subnav-cta.active {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.rt-subnav a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    color: var(--rt-muted);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
}

.rt-subnav a:hover,
.rt-subnav a.active {
    color: var(--rt-ink);
    background: var(--rt-wash-2);
}

.rt-subnav .rt-portal-link {
    margin-left: auto;
    color: var(--rt-purple);
}

.rt-app-main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 1.5rem 0 3rem;
}

.rt-app-main > h1,
.rt-app-main h1.text-2xl {
    color: var(--rt-ink);
    font-size: clamp(1.5rem, 2.5vw, 2rem) !important;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-weight: 700 !important;
}

.rt-app-main h2,
.rt-app-main h3 {
    color: var(--rt-ink);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background-color: var(--rt-purple);
    border: 1px solid var(--rt-purple);
    color: #fff !important;
    padding: 0.5rem 0.875rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.btn-primary:hover {
    background-color: var(--rt-purple-dark);
    border-color: var(--rt-purple-dark);
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background-color: #fff;
    border: 1px solid var(--rt-line-strong);
    color: var(--rt-body) !important;
    padding: 0.5rem 0.875rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.btn-secondary:hover {
    background-color: var(--rt-wash-2);
    border-color: var(--rt-muted);
    color: var(--rt-ink) !important;
}

.card {
    background: #fff;
    border: 1px solid var(--rt-line);
    border-radius: 8px;
    box-shadow: var(--rt-shadow);
    padding: 1.25rem;
}

.rt-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.4;
    white-space: nowrap;
}

.rt-badge-active {
    background: rgba(47, 143, 107, 0.12);
    color: var(--rt-green);
}

.rt-badge-awaiting {
    background: rgba(200, 144, 0, 0.12);
    color: var(--rt-gold);
}

.rt-badge-muted {
    background: var(--rt-wash);
    color: var(--rt-muted);
}

.rt-badge-retired {
    background: rgba(180, 35, 24, 0.1);
    color: var(--rt-red);
}

.rt-breadcrumbs {
    background: #fff;
    border-bottom: 1px solid var(--rt-line);
}

.rt-breadcrumbs-list {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    list-style: none;
    padding: 0.65rem 0;
    margin-bottom: 0;
}

.rt-breadcrumbs-item {
    display: inline-flex;
    align-items: center;
    font-size: 0.78rem;
    color: var(--rt-muted);
}

.rt-breadcrumbs-item:not(:last-child)::after {
    content: '/';
    margin-left: 0.35rem;
    color: var(--rt-line-strong);
}

.rt-breadcrumbs-item a {
    color: var(--rt-muted);
    text-decoration: none;
}

.rt-breadcrumbs-item a:hover {
    color: var(--rt-purple);
}

.rt-breadcrumbs-item span[aria-current="page"] {
    color: var(--rt-ink);
    font-weight: 650;
}

.rt-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.rt-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--rt-ink);
    margin: 0;
}

.rt-dl {
    display: grid;
    grid-template-columns: minmax(8rem, 36%) 1fr;
    row-gap: 0.5rem;
    column-gap: 1rem;
    font-size: 0.875rem;
    align-items: start;
}

.rt-dl dt {
    color: var(--rt-muted);
    font-size: 0.75rem;
    font-weight: 600;
    margin: 0;
    padding-top: 0.15rem;
    line-height: 1.4;
}

.rt-dl dd {
    color: var(--rt-ink);
    margin: 0;
    line-height: 1.4;
    font-weight: 500;
}

.rt-metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.rt-metric-card {
    background: #fff;
    border: 1px solid var(--rt-line);
    border-radius: 8px;
    padding: 1.1rem 1.2rem;
    box-shadow: 0 1px 2px rgba(43, 24, 73, 0.04);
}

.rt-metric-label {
    display: block;
    font-size: 0.74rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--rt-muted);
    margin-bottom: 0.35rem;
}

.rt-metric-value {
    font-size: 1.65rem;
    font-weight: 720;
    color: var(--rt-ink);
    line-height: 1.1;
}

.rt-chart-wrap {
    position: relative;
    height: 240px;
}

.rt-table-wrap {
    overflow-x: auto;
}

/* Zero-padding card that holds a full-bleed table — defeats .card's 1.35rem padding */
.rt-table-card {
    padding: 0 !important;
    overflow: hidden;
}

.rt-table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
    align-items: center;
}

.rt-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.rt-page-header h1 {
    margin-bottom: 0 !important;
}

.rt-two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
    gap: 1rem;
    align-items: start;
}

.rt-asset-view-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
    gap: 1rem;
    align-items: start;
}

.rt-activity-tacho {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.rt-activity-tacho-bar {
    flex: 1;
    height: 6px;
    background: var(--rt-wash-2);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.rt-activity-tacho-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--rt-purple);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.rt-activity-tacho-fill.low {
    background: var(--rt-red);
}

.rt-activity-tacho-fill.medium {
    background: var(--rt-gold);
}

.rt-activity-tacho-fill.high {
    background: var(--rt-green);
}

.rt-asset-last-map img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid var(--rt-line);
}

.rt-asset-last-meta {
    margin-top: 0.75rem;
    font-size: 0.875rem;
}

.rt-asset-last-meta dt {
    color: var(--rt-muted);
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.rt-asset-last-meta dt:first-child {
    margin-top: 0;
}

.rt-asset-last-meta dd {
    margin: 0.15rem 0 0;
}

.rt-asset-history #asset-history-map {
    min-height: 360px;
    border-radius: 6px;
    border: 1px solid var(--rt-line);
}

.rt-map-placeholder {
    min-height: 240px;
    display: grid;
    place-items: center;
    text-align: center;
    color: var(--rt-muted);
    font-size: 0.875rem;
    background: var(--rt-wash-2);
    border: 1px dashed var(--rt-line-strong);
    border-radius: 6px;
    padding: 1.5rem;
}

#asset-map {
    min-height: 280px;
    width: 100%;
    border-radius: 6px;
    border: 1px solid var(--rt-line);
}

#geofence-map {
    min-height: 300px;
    height: 300px;
    width: 100%;
    border-radius: 6px;
    border: 1px solid var(--rt-line);
}

.rt-global-geofence-map {
    min-height: 480px;
    height: 480px;
    width: 100%;
    border-radius: 6px;
    border: 1px solid var(--rt-line);
}

.rt-geofence-admin-layout {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 900px) {
    .rt-geofence-admin-layout {
        grid-template-columns: 1fr;
    }
}

.rt-geofence-sidebar {
    padding: 0;
    overflow: hidden;
}

.rt-geofence-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--rt-line);
}

.rt-geofence-area-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 420px;
    overflow-y: auto;
}

.rt-geofence-area-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    padding: 0.65rem 1rem;
    border: none;
    border-bottom: 1px solid var(--rt-line);
    background: transparent;
    cursor: pointer;
    font-size: 0.875rem;
}

.rt-geofence-area-item:hover,
.rt-geofence-area-item.is-selected {
    background: var(--rt-wash-2);
}

.rt-geofence-area-item-text {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.rt-geofence-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-top: 0.2rem;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.rt-geofence-pill {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    background: var(--rt-wash-2);
    color: var(--rt-muted);
    width: fit-content;
}

.rt-geofence-pill-visible {
    background: #d1fae5;
    color: #065f46;
}

.rt-geofence-map-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.rt-geofence-form {
    margin-top: 1rem;
}

.rt-geofence-section {
    border-top: 1px solid var(--rt-line);
    padding-top: 1.25rem;
}

.rt-geofence-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.rt-geofence-bar input[type="range"] {
    flex: 1;
    min-width: 160px;
}

.rt-geofence-radius-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--rt-purple);
    min-width: 4.5rem;
}

.badge-in-zone {
    background: #d1fae5;
    color: #065f46;
    border-radius: 4px;
}

.badge-out-zone {
    background: #fef3c7;
    color: #92400e;
    border-radius: 4px;
}

.rt-app-main .grid > .card {
    min-height: 100%;
}

#map {
    min-height: 460px;
    width: 100%;
    border-radius: 4px;
    border: 1px solid var(--rt-line);
}

.rt-app-main table {
    border-collapse: separate;
    border-spacing: 0;
}

.rt-app-main table.card {
    display: table;
    padding: 0;
    overflow: hidden;
}

.rt-app-main th {
    color: var(--rt-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--rt-wash-2);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--rt-line);
}

.rt-app-main td {
    color: var(--rt-body);
    padding: 0.875rem 1rem;
    vertical-align: middle;
    font-size: 0.875rem;
}

.rt-app-main tr.border-b,
.rt-app-main .border-b {
    border-color: var(--rt-line) !important;
}

.rt-app-main a.text-blue-600,
.rt-app-main .text-blue-600,
.rt-app-main button.text-blue-600 {
    color: var(--rt-purple) !important;
    font-weight: 650;
    text-decoration: none;
}

.rt-app-main a.text-blue-600:hover,
.rt-app-main button.text-blue-600:hover {
    color: var(--rt-purple-dark) !important;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.rt-app-main input,
.rt-app-main select,
.rt-app-main textarea {
    border-color: var(--rt-line-strong) !important;
    border-radius: 4px !important;
    color: var(--rt-ink);
    background: #fff;
}

.rt-app-main input:focus,
.rt-app-main select:focus,
.rt-app-main textarea:focus {
    outline: none;
    border-color: var(--rt-purple) !important;
    box-shadow: 0 0 0 3px rgba(95, 36, 159, 0.13);
}

.rt-app-main label {
    color: var(--rt-ink);
    font-weight: 650;
}

.rt-app-main .bg-gray-50 {
    background-color: var(--rt-wash-2) !important;
}

.rt-app-main .bg-gray-200 {
    background-color: var(--rt-purple-soft) !important;
    color: var(--rt-purple-dark);
}

.rt-app-main .text-gray-500,
.rt-app-main .text-gray-600 {
    color: var(--rt-muted) !important;
}

.rt-app-main .text-amber-700,
.rt-app-main .text-amber-800 {
    color: var(--rt-gold) !important;
}

.rt-app-main .text-green-600,
.rt-app-main .text-green-700 {
    color: var(--rt-green) !important;
}

.rt-app-main .text-red-600 {
    color: var(--rt-red) !important;
}

.rt-app-main dl dt {
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-top: 0.75rem;
}

.rt-app-main dl dd {
    color: var(--rt-ink);
    margin-bottom: 0.55rem;
}

.rt-flash,
.rt-app-main .bg-red-100,
.rt-app-main .bg-green-100,
.rt-app-main .bg-blue-100 {
    border-radius: 6px !important;
    border-width: 1px !important;
}

.rt-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: min(22rem, calc(100vw - 2rem));
}

.rt-toast {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 1px solid;
    font-size: 0.875rem;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    opacity: 0;
    transform: translateY(-0.5rem);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.rt-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.rt-toast-success {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.rt-toast-error {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.rt-toast-info {
    background: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}

.rt-footer {
    background: #2b2238;
    color: #fff;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.rt-footer-inner {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 1.75rem 0;
    text-align: center;
    font-size: 0.84rem;
}

.rt-footer-muted {
    color: rgba(255,255,255,0.62);
    margin-top: 0.25rem;
}

@media (max-width: 760px) {
    .rt-topbar-inner,
    .rt-subnav-inner,
    .rt-breadcrumbs-list,
    .rt-app-main,
    .rt-footer-inner {
        width: min(100% - 28px, 1180px);
    }

    .rt-site-logo {
        height: 1.65rem;
        max-width: min(9.5rem, 52vw);
    }

    .rt-top-actions {
        gap: 0.65rem;
    }

    .rt-subnav-inner {
        flex-wrap: nowrap;
        padding-bottom: 0.7rem;
    }

    .rt-subnav-links {
        flex-wrap: nowrap;
    }

    .rt-subnav-spacer {
        flex: 1 1 auto;
        min-width: 0.5rem;
    }

    .rt-user-name {
        display: none;
    }

    .rt-subnav a {
        white-space: nowrap;
    }

    .rt-app-main {
        padding-top: 1.5rem;
    }

    .rt-two-col,
    .rt-asset-view-top {
        grid-template-columns: 1fr;
    }

    .rt-page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
