/* Shared visual layer for the map workspace, server-rendered sections and login.
   Section styles own layout behavior; this file owns the INSAN brand treatment. */
:root {
  --brand: #1f386d;
  --brand-hover: #284780;
  --brand-soft: #eef2f9;
  --bg: #f7f7f7;
  --surface: #fff;
  --surface-strong: #fff;
  --ink: #202124;
  --muted: #71757b;
  --line: #e5e6e8;
  --line-strong: #d6d8dc;
  --accent: var(--brand);
  --accent-strong: var(--brand-hover);
  --soft-active: var(--brand-soft);
  --glass: #fff;
  --glass-strong: #fff;
  --green: #3d7a5b;
  --green-soft: #edf5f0;
  --danger: #a63431;
  --shadow: 0 8px 28px #20212412;
  --radius: 6px;
  --navigation-width: 76px;
  color-scheme: light;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body::before, body::after { display: none; }
button, input, select, textarea { font-family: inherit; letter-spacing: 0; }
button:disabled { cursor: not-allowed; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
:is(button, a, summary, select, input):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}
:is(h1, h2, h3, p) { letter-spacing: 0; }
:is(h1, h2, h3) { overflow-wrap: anywhere; }

/* The same header and navigation treatment on both rendering paths. */
.portal-header__bar {
  grid-template-columns: var(--navigation-width) minmax(0, 1fr) auto;
  gap: 24px;
  padding: 0 24px 0 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
  backdrop-filter: none;
  font-family: Arial, sans-serif;
}
.portal-header__brand { justify-content: center; height: 58px; padding: 8px 12px; }
.portal-header__brand img { width: 150px; height: auto; max-height: 44px; object-fit: contain; filter: none; }
.portal-header__title { justify-self: start; font-size: 13px; font-weight: 400; color: var(--muted); }
.portal-header__user { color: var(--ink); font-weight: 400; }
.portal-header__user svg { color: var(--brand); }
.portal-header__logout { background: #fff; border-color: var(--line); color: var(--muted); }
.portal-header__logout:hover { background: #f5f5f5; color: var(--brand); }
.primary-nav, .admin-nav {
  background: var(--brand);
  border-right: 0;
  backdrop-filter: none;
  padding-top: 24px;
}
.primary-nav .nav-button, .admin-nav > a, .admin-nav .nav-parent {
  border-radius: 5px;
  background: transparent;
  color: #d1dbef;
  border-color: transparent;
  box-shadow: none;
  font-size: 14px;
  font-weight: 400;
  text-decoration: none;
}
.primary-nav .nav-button svg, .admin-nav > a svg, .admin-nav .nav-parent svg { width: 20px; height: 20px; }
.primary-nav .nav-button:is(:hover, .is-active, [aria-expanded=true]),
.admin-nav > a:is(:hover, .is-active), .admin-nav .nav-parent:is(:hover, .is-active, [aria-expanded=true]) {
  color: #fff;
  background: #ffffff18;
  border-color: transparent;
  box-shadow: none;
  text-decoration: none;
}
.primary-nav .nav-button.is-active::before, .admin-nav > a.is-active::before,
.admin-nav .nav-parent.is-active::before { background: #fff; height: 22px; border-radius: 0; }
.primary-nav :focus-visible, .admin-nav :focus-visible { outline-color: #b8c9ed; }
.nav-group-divider { background: #ffffff24; margin-block: 14px; }
.portal-nav-submenu, .nav-submenu {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 36px #18233526;
  backdrop-filter: none;
}
.portal-nav-submenu :is(a, button), .admin-nav .nav-submenu a {
  display: grid;
  padding: 10px;
  border-radius: 4px;
  color: #53575d;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
}
.portal-nav-submenu :is(a, button):is(:hover, :focus-visible, .is-active),
.admin-nav .nav-submenu a:is(:hover, :focus-visible, .is-active) {
  color: var(--brand);
  background: var(--brand-soft);
  box-shadow: none;
  text-decoration: none;
}
.nav-tooltip, .admin-nav > a > span, .admin-nav .nav-parent > span {
  background: #fff;
  border-color: var(--line);
  border-radius: 5px;
  color: var(--ink);
  line-height: 1.4;
  font-weight: 400;
}

/* White working surfaces, quiet separators, no glass or floating sections. */
.context-panel, .context-heading, .filter-stack, .route-builder-add, .workspace-toolbar,
.route-builder-footer, .request-summary {
  background: #fff;
  border-color: var(--line);
  backdrop-filter: none;
}
.context-heading { min-height: 82px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; }
.context-heading h1 { font-size: 22px; font-weight: 600; line-height: 1.25; }
.eyebrow { font-size: 10px; font-weight: 400; color: var(--muted); margin-bottom: 7px; }
.context-panel .panel-list { background: #fafafa; }
.entity-card, .account-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: none;
  backdrop-filter: none;
}
.entity-card:hover { background: #fff; border-color: #bbc7dd; box-shadow: none; transform: none; }
.entity-card.fleet-list-card.is-selected { border-color: var(--brand); background: #f6f8fc; box-shadow: inset 3px 0 var(--brand); }
.entity-card strong { font-size: 16px; font-weight: 600; line-height: 1.3; }
.entity-card span { font-weight: 400; }
.card-meta span { background: #f3f4f5; border-radius: 4px; }
.fuel-data-status { background: var(--brand-soft); color: var(--brand); border: 0; border-radius: 4px; }
.input-shell, .select-shell, .segmented {
  border-color: var(--line-strong);
  border-radius: 5px;
  background: #fff;
  box-shadow: none;
  backdrop-filter: none;
}
.input-shell:focus-within, .select-shell:focus-within { border-color: var(--brand); box-shadow: 0 0 0 2px #1f386d14; }
.input-shell input:focus-visible { outline: 0; }
.input-shell svg, .select-shell svg { color: #858a92; }
.segmented { background: #f5f5f5; border-color: var(--line); gap: 3px; }
.segment { border-radius: 3px; font-weight: 400; }
.segment.is-active { background: #fff; color: var(--brand); box-shadow: 0 1px 3px #2021241a; font-weight: 600; }
.segmented.route-type-segmented { grid-template-columns: repeat(3, minmax(0, 1fr)); }
input, select { font-weight: 400; }
input::placeholder { color: #858a92; }
.admin-main input:not([type=checkbox]):not([type=hidden]), .login-panel input:not([type=hidden]),
.permission-mode select, .route-field-label select, .route-number-label input {
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  box-shadow: none;
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
}
.admin-main input:focus, .login-panel input:focus { border-color: var(--brand); box-shadow: 0 0 0 2px #1f386d14; }
.field span, .route-field-label, .route-number-label { font-size: 12px; font-weight: 400; text-transform: none; }
.copy-button, .route-build-command, .login-panel button {
  border: 1px solid var(--brand);
  border-radius: 5px;
  background: var(--brand);
  box-shadow: none;
  color: #fff;
  font-weight: 500;
}
.copy-button:hover:not(:disabled), .route-build-command:hover:not(:disabled), .login-panel button:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}
.ghost-button, .icon-command, .text-command, .round-action, .route-toll-select-all, .route-toll-clear {
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  box-shadow: none;
  backdrop-filter: none;
  font-weight: 400;
}
.ghost-button:hover, .icon-command:hover, .text-command:hover { background: #f4f5f6; }
.icon-command.is-active, .route-map-sizes .icon-command.is-active { background: var(--brand-soft); color: var(--brand); border-color: #becbe2; }
.route-inline-command { color: var(--brand); }
input[type=checkbox], .check-row input, .route-compact-check input { accent-color: var(--brand); }
.switch-track { background: #e3e5e8; border-color: #d4d7dc; box-shadow: none; }
.switch-input:checked + .switch-track { background: var(--brand); border-color: var(--brand); }
.switch-input:focus-visible + .switch-track { outline-color: var(--brand); }
.route-option { background: #fff; border-color: var(--line); border-radius: 5px; }
.route-option input:checked + .route-option-box { background: var(--brand); border-color: var(--brand); }
.route-option input:focus-visible + .route-option-box { outline-color: var(--brand); }
.route-option-box { border-color: var(--line-strong); box-shadow: none; }

/* Registries and integrations follow the same full-width workspace rhythm. */
.admin-main { background: var(--bg); padding: 32px; }
.content-grid { gap: 24px; }
.hero { padding: 0 0 8px; background: none; border: 0; border-radius: 0; box-shadow: none; backdrop-filter: none; }
.admin-main h1 { font-size: 28px; font-weight: 500; line-height: 1.25; }
.admin-main h2 { font-weight: 600; line-height: 1.4; }
.admin-main p { color: var(--muted); font-size: 13px; font-weight: 400; line-height: 1.6; }
.hero-badges { padding-top: 4px; }
.badge, .account-badge, .notice { border: 1px solid var(--line); border-radius: 4px; background: #fff; font-weight: 400; color: var(--muted); }
.panel { border: 1px solid var(--line); border-radius: 6px; background: #fff; box-shadow: none; backdrop-filter: none; }
.panel-head, .sync-head, .fleet-toolbar { border-color: var(--line); }
.panel-head { min-height: 64px; }
.panel-head span, .fleet-toolbar > span { font-weight: 400; }
.stats-grid, .event-meta { gap: 1px; background: var(--line); }
.stats-grid div, .event-meta div { background: #fff; padding-block: 20px; }
.stats-grid span, .event-meta span { font-size: 12px; font-weight: 400; text-transform: none; }
.stats-grid strong { font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 12px; overflow-wrap: anywhere; }
.panel > .stats-grid + p { margin: 0; max-width: none; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 12px; }
.event-meta strong { font-weight: 500; }
.admin-main pre { background: #fafafa; border-color: var(--line); }
.admin-main table { background: #fff; }
.admin-main :is(th, td) { padding: 16px 18px; border-color: #ededee; }
.admin-main th, .admin-main .fleet-table.fleet-registry-table th, .route-history-table th {
  background: #fafafa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
}
.admin-main tbody tr:hover, .route-history-table tbody tr:hover { background: #f8f9fc; }
.admin-main td a { color: var(--brand); font-weight: 500; }
.admin-main .wialon-table { min-width: 680px; }
.integration-tabs a { border-radius: 5px; border-color: var(--line); background: #fff; box-shadow: none; font-weight: 400; }
.integration-tabs a.is-active { background: var(--brand); border-color: var(--brand); box-shadow: none; }
.rights-picker summary, .rights-list { background: #fff; border-color: var(--line-strong); border-radius: 5px; font-weight: 400; }
.rights-picker summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rights-picker summary::after { content: '+'; font-size: 18px; color: var(--brand); }
.rights-picker[open] summary::after { content: '-'; }
.rights-list .check-row { font-weight: 400; line-height: 1.45; }
.account-head span { font-weight: 400; text-transform: none; font-size: 12px; }
.account-head strong { font-weight: 500; overflow-wrap: anywhere; }
.state-icon { border-radius: 6px; color: var(--brand); background: var(--brand-soft); }

/* Route parameters remain above the resizable map. */
.planner-page { background: #fff; }
.planner-page .route-builder-panel { padding: 32px; }
.planner-page .context-heading h1, .route-history-page h1 { font-size: 28px; font-weight: 500; }
.planner-page .route-vehicle-form, .route-builder-footer { border-color: var(--line); }
.route-stop { background: #fff; border-color: var(--line); border-radius: 5px; box-shadow: none; }
.route-stop-index { background: var(--brand-soft); color: var(--brand); border-radius: 4px; }
.route-stop-address { font-weight: 400; }
.route-stop-address:focus { background: #f7f9fc; }
.route-stop.is-drag-target { border-color: var(--brand); }
.route-stops-empty { background: #fafafa; border-color: var(--line-strong); border-radius: 5px; font-weight: 400; }
.route-stops-head { font-weight: 500; }
.route-stops-head b { background: #f2f3f5; }
.route-preview-metric, .route-status { background: #f6f7f9; border-color: var(--line); border-radius: 4px; box-shadow: none; backdrop-filter: none; }
.route-preview-metric span { font-weight: 400; }
.route-history-page { padding: 32px; background: var(--bg); }
.route-history-table { border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.route-history-table td, .route-history-table th { border-color: var(--line); }
.route-request-field { max-width: 420px; margin: 0 0 20px; }
.route-request-field input { min-height: 40px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 8px 12px; background: #fff; }
.route-history-groups { display: grid; gap: 12px; margin: 24px 0; }
.route-history-group { min-width: 0; border-bottom: 1px solid var(--line); }
.route-history-group > summary { display: flex; align-items: center; gap: 18px; padding: 18px 0; cursor: pointer; list-style: none; }
.route-history-group > summary::-webkit-details-marker { display: none; }
.route-history-group > summary strong { margin-right: auto; overflow-wrap: anywhere; min-width: 0; }
.route-history-group > summary :is(span, time) { color: var(--muted); font-size: 12px; }
.route-history-group > summary svg { width: 18px; height: 18px; flex: 0 0 18px; }
.route-history-group[open] > summary svg { transform: rotate(180deg); }
.route-history-group-content { min-width: 0; padding-bottom: 18px; }
.route-history-page footer .icon-command { flex: 0 0 42px; width: 42px; height: 42px; }
.route-history-page footer .icon-command:disabled { opacity: .4; cursor: default; }
.route-driver-links { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); min-width: 0; }
.route-driver-links header { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; justify-content: space-between; }
.route-driver-links h3 { font-size: 15px; margin: 0; }
.route-driver-links p, .route-driver-status, #driverCopyStatus { font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.route-driver-status { color: #b44937; }
.route-driver-part { margin: 14px 0; min-width: 0; }
.route-driver-part label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.route-driver-url { display: grid; grid-template-columns: minmax(0, 1fr) 42px 42px; gap: 8px; }
.route-driver-url input { width: 100%; min-width: 0; border: 1px solid var(--line-strong); border-radius: 5px; padding: 10px; font-size: 13px; background: #fff; }
.route-driver-url .icon-command { width: 42px; height: 42px; }
.insan-map-marker-loading { background: #347452; }
.insan-map-marker-unloading { background: #b44937; color: #fff; }
.insan-map-marker-via { background: #1f386d; }
@media (max-width: 620px) {
  .route-history-group > summary { flex-wrap: wrap; gap: 10px; }
  .route-history-group > summary strong { flex-basis: 100%; }
  .route-history-group > summary time { margin-right: auto; }
}
#map, .map-fallback { background: #f1f2f3; }

/* Monitoring remains a focused, keyboard-accessible dialog. */
.monitoring-dialog { background: #fff; font-family: Arial, sans-serif; border-color: var(--line); }
.monitoring-header { background: #fff; border-top: 3px solid var(--brand); }
.monitoring-dialog h2 { font-weight: 600; }
.monitoring-dialog .monitoring-icon-button { color: var(--brand); }
.monitoring-location, .monitoring-sensors > div { background: #f6f6f7; }
.monitoring-metrics svg { color: var(--brand); }
.monitoring-metrics > div { border-color: var(--line); }
button.monitoring-row-button { background: #fff; border-color: #cbd3e3; color: var(--brand); font-family: Arial, sans-serif; font-size: 12px; }
button.monitoring-row-button:hover { background: var(--brand-soft); }
.monitoring-dialog button:focus-visible, .monitoring-row-button:focus-visible { outline-color: var(--brand); }

/* The status.min.group split login, using INSAN branding. No login script needed. */
@font-face {
  font-family: "INSAN Login";
  src: url('/assets/fonts/Montserrat-Variable.ttf') format('truetype');
  font-weight: 100 900;
  font-display: swap;
}
body.insan-login { margin: 0; min-width: 320px; background: #fff; font-family: "INSAN Login", Arial, sans-serif; line-height: 1.5; }
.login-layout, .login-layout * { box-sizing: border-box; }
.login-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.login-layout :is(h1, h2, p) { margin: 0; }
.login-story { display: flex; flex-direction: column; min-width: 0; padding: 48px 56px; background: var(--brand); color: #fff; }
.login-brand { display: block; width: 252px; max-width: 100%; height: auto; filter: brightness(0) invert(1); }
.login-story-center { margin: auto 0; padding: 80px 0; }
.login-layout .login-eyebrow { margin-bottom: 22px; font-size: 12px; font-weight: 600; color: var(--brand); text-transform: uppercase; }
.login-story .login-eyebrow { color: #bac9e8; font-size: 11px; }
.login-story h1 { font-size: 72px; font-weight: 500; line-height: 1.08; overflow-wrap: normal; }
.login-story h1 span { color: #a5c0f4; }
.login-story .login-story-caption { max-width: 400px; color: #c5d2eb; font-size: 17px; margin-top: 30px; line-height: 1.7; }
.login-story-line { border-top: 1px solid #ffffff30; margin-top: 50px; padding-top: 22px; font-size: 11px; color: #c5d2eb; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.login-story-footer, .login-bottom, .login-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: 11px; }
.login-story-footer { color: #b9c9e7; }
.login-form-wrap { display: flex; flex-direction: column; min-width: 0; padding: 48px 64px; background: #fff; }
.login-top, .login-bottom { color: var(--muted); }
.login-live-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: var(--brand); }
.login-panel { width: 100%; max-width: 370px; margin: auto; padding: 65px 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
.login-panel h2 { font-size: 35px; line-height: 1.25; font-weight: 600; }
.login-panel .login-intro { color: var(--muted); font-size: 14px; margin: 15px 0 35px; }
.login-panel label { display: block; margin-bottom: 22px; font-size: 13px; font-weight: 500; }
.login-panel label span { display: block; }
.login-panel input:not([type=hidden]) { display: block; width: 100%; min-height: 55px; margin-top: 9px; padding: 15px; border-radius: 8px; font-family: inherit; font-size: 15px; font-weight: 500; }
.login-panel input::placeholder { color: #989ca5; font-weight: 400; }
.login-panel input:focus { border-color: #8399c5; box-shadow: none; }
.login-panel input:focus-visible { outline: 3px solid #9fb2d6; outline-offset: 3px; }
.login-panel input[aria-invalid=true] { border-color: var(--danger); }
.login-panel button { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 52px; margin-top: 8px; padding: 12px 19px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.login-panel button svg { width: 18px; height: 18px; flex-shrink: 0; }
.login-panel .login-hint { margin-top: 32px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.login-error { padding: 12px 14px; margin-bottom: 20px; border: 1px solid #edd1d0; background: #fff3f2; color: var(--danger); border-radius: 6px; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
@media (max-width: 1150px) {
  .login-story { padding: 40px 35px; }
  .login-form-wrap { padding: 35px; }
  .login-story h1 { font-size: 52px; }
}
@media (max-width: 760px) {
  .login-layout { grid-template-columns: minmax(0, 1fr); }
  .login-story { padding: 25px 28px; min-height: 240px; }
  .login-brand { width: 180px; }
  .login-story-center { margin: 0; padding: 32px 0 4px; }
  .login-story .login-eyebrow { margin-bottom: 12px; font-size: 10px; }
  .login-story h1 { font-size: 38px; }
  .login-story h1 br { display: none; }
  .login-story-caption, .login-story-line, .login-story-footer { display: none; }
  .login-form-wrap { padding: 28px; }
  .login-panel { padding: 40px 0; max-width: 450px; }
  .login-panel h2 { font-size: 30px; }
  .login-bottom { margin-top: 20px; }
}
@media (max-width: 370px) {
  .login-story, .login-form-wrap { padding-inline: 22px; }
  .login-story h1 { font-size: 32px; }
  .login-panel h2 { font-size: 27px; }
}

@media (min-width: 1101px) {
  :root { --navigation-width: 236px; }
  .portal-header__brand { background: var(--brand); border-bottom: 1px solid #ffffff24; }
  .portal-header__brand img { filter: brightness(0) invert(1); width: 152px; }
  .portal-shell { grid-template-columns: var(--navigation-width) 340px minmax(0, 1fr); }
  .admin-shell, .portal-shell.planner-shell { grid-template-columns: var(--navigation-width) minmax(0, 1fr); }
  .primary-nav, .admin-nav { padding: 28px 12px; align-items: stretch; }
  .primary-nav .portal-nav-tree, .admin-nav .nav-tree { width: 100%; }
  .primary-nav .nav-button, .admin-nav > a, .admin-nav .nav-parent {
    grid-template-columns: 20px minmax(0, 1fr);
    place-items: center start;
    gap: 12px;
    width: 100%;
    height: 48px;
    padding: 0 12px;
    text-align: left;
  }
  .primary-nav .nav-button > .nav-tooltip, .admin-nav > a > span, .admin-nav .nav-tree .nav-parent > span {
    position: static;
    display: block;
    opacity: 1;
    transform: none;
    width: auto;
    max-width: 100%;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    color: inherit;
    font-size: 14px;
    white-space: normal;
    line-height: 1.4;
  }
  .portal-nav-submenu, .nav-submenu { left: calc(100% + 10px); width: 280px; }
  .nav-group-divider { width: 100%; }
}
@media (min-width: 621px) and (max-width: 1100px) {
  .portal-header__bar { grid-template-columns: 182px minmax(0, 1fr) auto; }
}
@media (max-width: 800px) {
  .admin-main, .planner-page .route-builder-panel, .route-history-page { padding: 20px; }
  .admin-main h1, .planner-page .context-heading h1, .route-history-page h1 { font-size: 24px; }
}
@media (max-width: 620px) {
  :root { --navigation-width: 54px; }
  .portal-header__bar { grid-template-columns: minmax(0, 1fr) auto; padding: 0 12px; gap: 12px; }
  .portal-header__brand { justify-content: start; padding: 8px 0; }
  .portal-header__brand img { width: 125px; }
  .admin-main, .planner-page .route-builder-panel, .route-history-page { padding: 16px 12px; }
  .hero { gap: 12px; }
  .admin-main h1, .planner-page .context-heading h1, .route-history-page h1 { font-size: 22px; }
  .admin-main .panel-head, .admin-main .sync-head, .admin-main .create-form, .admin-main .secret-form { padding: 16px 12px; }
  .stats-grid div, .event-meta div { padding: 16px 12px; }
  .stats-grid strong { font-size: 22px; }
}
