/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */
/* Shared Bootstrap tooltip trigger; help text remains available to screen readers. */
.field-help {
    display: inline;
}

.field-help__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75em;
    height: 1.75em;
    padding: 0;
    margin-inline-start: 0.25rem;
    border: 0;
    background: transparent;
    border-radius: 50%;
    color: inherit;
    font: inherit;
    cursor: help;
    vertical-align: middle;
}

.field-help__icon {
    width: 1em;
    height: 1em;
}

.field-help__trigger:focus-visible {
    outline: 3px solid var(--brand-red, #ef3340);
    outline-offset: 2px;
}

.app-form-field {
    min-width: 0;
}

.app-form-field-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.5rem;
    margin-bottom: 0.5rem;
}

.app-form-field-heading > .form-label {
    min-width: 0;
    margin-bottom: 0;
    overflow-wrap: anywhere;
}

.app-form-field-heading .form-required {
    font-size: 0.875em;
    font-weight: normal;
}

.app-form-field-heading > .field-help {
    min-width: 0;
    max-width: 100%;
}

.app-form-field .invalid-feedback {
    overflow-wrap: anywhere;
}

.app-form-group.is-invalid {
    border-inline-start: 0.2rem solid var(--bs-danger);
    padding-inline-start: 0.75rem;
}

.app-form-group > legend .form-required {
    font-size: 0.875em;
    font-weight: normal;
}

.device-image-card {
    width: 20rem;
    max-width: 100%;
}

.device-image-card__image {
    width: 100%;
    height: 12rem;
    object-fit: contain;
}

.table-action,
.compact-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    vertical-align: middle;
    flex-shrink: 0;
}

.table-action-cell {
    width: 1%;
    white-space: nowrap;
}

.user-action-slots {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.25rem;
}

.user-action-slots .table-action:disabled {
    pointer-events: none;
}

.table-action-cell .button_to {
    display: inline-block;
    margin: 0;
}

@media (pointer: coarse) {
    .table-action, .compact-action { width: 2.75rem; height: 2.75rem; }
}

.compact-action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.compact-action-row > .btn:not(.compact-action) {
    max-width: 100%;
    overflow-wrap: anywhere;
}

.organization-logo-group {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.organization-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0.25rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    text-decoration: none;
    font: inherit;
}

.organization-logo__image {
    width: 1.75rem;
    height: 1.75rem;
    object-fit: contain;
    background: white;
    border-radius: 0.125rem;
}

.organization-logo__initials, .organization-logo--more {
    font-size: 0.75rem;
    font-weight: 600;
}

.organization-logo:focus-visible {
    outline: 3px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Native top-layer popover is not clipped by the responsive table's overflow. */
.organization-overflow {
    width: max-content;
    max-width: min(24rem, calc(100vw - 2rem));
    max-height: min(24rem, 70vh);
    overflow: auto;
    padding: 0.25rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    white-space: normal;
    overflow-wrap: anywhere;
}

@media (pointer: coarse) {
    .organization-logo { width: 2.75rem; height: 2.75rem; }
}

.device-map {
    width: 100%;
    height: clamp(20rem, 48vw, 32rem);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    background: var(--brand-gray-100, #f1f1ef);
}

.device-map-marker {
    background: transparent;
    border: 0;
}

.device-map-marker__pin {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #6c757d;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
}

.device-map-marker__pin--gateway {
    position: relative;
    border-radius: 0.25rem;
    background: var(--brand-black, #1d1d1b);
}

.device-map-marker__pin--gateway.device-map-marker__pin--never_seen {
    background: #6c757d;
}

.device-map-marker__pin--online {
    background: #198754;
}

.device-map-marker__pin--delayed {
    background: #ffc107;
}

.device-map-marker__pin--offline {
    background: #dc3545;
}

.device-map-marker__pin--irregular {
    background: #0dcaf0;
}

.device-map-marker__pin--gateway::before,
.floor-plan-position__marker--category-gateway::before,
.device-category-legend__symbol--gateway::before {
    position: absolute;
    inset: 0;
    background-color: #fff;
    -webkit-mask: url("/assets/icons/gateway-radio-8d3af822.svg") center / contain no-repeat;
    mask: url("/assets/icons/gateway-radio-8d3af822.svg") center / contain no-repeat;
    mask-mode: alpha;
    content: "";
}

.device-map-marker__pin--gateway.device-map-marker__pin--delayed::before,
.floor-plan-position__marker--category-gateway.floor-plan-position__marker--delayed::before {
    background-color: #1d1d1b;
}

.device-map-popup {
    min-width: 10rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.device-map-popup__title {
    display: block;
    margin-bottom: 0.25rem;
}

.device-map-popup__category {
    font-weight: 600;
}

.device-category-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    color: var(--bs-secondary-color);
    font-size: 0.875rem;
}

.device-category-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.device-category-legend__symbol {
    position: relative;
    display: inline-block;
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    border: 0.12rem solid var(--brand-white, #fff);
    background: var(--bs-secondary);
    box-shadow: 0 0.05rem 0.2rem rgba(var(--brand-black-rgb), 0.4);
}

.device-category-legend__symbol--sensor {
    border-radius: 50%;
}

.device-category-legend__symbol--gateway {
    border-radius: 0.18rem;
    background: var(--brand-black);
}

.device-map-popup__status {
    margin-top: 0.35rem;
    font-weight: 600;
    color: #6c757d;
}

.device-map-popup__status--online {
    color: #197a3e;
}

.device-map-popup__status--delayed {
    color: #9a6700;
}

.device-map-popup__status--offline {
    color: #b42318;
}

.device-map-popup__measurements {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: start;
    text-align: left;
    min-width: 0;
    max-width: 100%;
    gap: 0.25rem 0.75rem;
    margin: 0.5rem 0;
}

.device-map-popup__measurements :is(dt, dd) {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.device-map-popup__transmission {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 0.5rem;
  margin: 0.65rem 0;
}

.device-map-popup__transmission dt,
.device-map-popup__transmission dd {
  margin: 0;
}

.device-map-popup__transmission dt {
  font-weight: 600;
}

.device-map-popup__link {
    display: inline-block;
    margin-top: 0.35rem;
    font-weight: 600;
}

.location-picker-map {
    height: clamp(18rem, 42vw, 28rem);
}

.project-area-map {
    height: clamp(15rem, 32vw, 20rem);
}

.project-position-marker .location-picker-marker__pin {
    cursor: inherit;
}

.location-picker-marker {
    background: transparent;
    border: 0;
}

.location-picker-marker__pin {
    display: block;
    width: 1.75rem;
    height: 1.75rem;
    cursor: grab;
    border: 3px solid #fff;
    border-radius: 50%;
    background: var(--brand-red, #ef3340);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.floor-plan-position__viewport {
    max-width: 100%;
    overflow: auto;
}

.floor-plan-position__canvas {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
}

.floor-plan-position__image {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    cursor: crosshair;
    user-select: none;
}

.floor-plan-position__image--readonly {
    cursor: default;
}

.floor-plan-position__marker {
    position: absolute;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 0.2rem solid var(--brand-white);
    background: var(--brand-red);
    border-radius: 50%;
    box-shadow: 0 0.125rem 0.5rem rgba(var(--brand-black-rgb), 0.45);
    cursor: grab;
    line-height: 1;
    touch-action: none;
    transform: translate(-50%, -50%);
}

.floor-plan-position__marker:active {
    cursor: grabbing;
}

.floor-plan-position__marker:focus-visible {
    outline: 0.2rem solid rgba(var(--brand-red-rgb), 0.45);
    outline-offset: 0.2rem;
}

.floor-plan-position__marker--readonly {
    cursor: default;
    pointer-events: none;
}

.floor-plan-position__marker--device-link,
.floor-plan-position__marker--device-link:active {
    cursor: pointer;
    touch-action: manipulation;
}

.floor-plan-position__marker--category-gateway {
    border-radius: 0.25rem;
    background: var(--brand-black);
}

.floor-plan-position__marker--online {
    background: var(--bs-success);
}

.floor-plan-position__marker--delayed {
    background: var(--bs-warning);
}

.floor-plan-position__marker--offline {
    background: var(--bs-danger);
}

.floor-plan-position__marker--never_seen {
    background: var(--bs-secondary);
}

.floor-plan-position__marker--irregular {
    background: var(--bs-info);
}

.floor-plan-position__marker--alarm-info {
    box-shadow: 0 0 0 0.3rem rgba(var(--bs-info-rgb), 0.55);
}

.floor-plan-position__marker--alarm-warning {
    box-shadow: 0 0 0 0.3rem rgba(var(--bs-warning-rgb), 0.65);
}

.floor-plan-position__marker--alarm-critical {
    box-shadow: 0 0 0 0.3rem rgba(var(--bs-danger-rgb), 0.55);
}

.floor-plan-position__marker--unacknowledged-alarm-info {
    box-shadow: 0 0 0 0.45rem rgba(var(--bs-info-rgb), 0.85);
}

.floor-plan-position__marker--unacknowledged-alarm-warning {
    box-shadow: 0 0 0 0.45rem rgba(var(--bs-warning-rgb), 0.9);
}

.floor-plan-position__marker--unacknowledged-alarm-critical {
    box-shadow: 0 0 0 0.45rem rgba(var(--bs-danger-rgb), 0.85);
}

.floor-plan-position__marker-label {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 50%;
    max-width: 12rem;
    padding: 0.2rem 0.4rem;
    overflow: hidden;
    border-radius: 0.25rem;
    background: rgba(var(--brand-black-rgb), 0.8);
    color: var(--brand-white);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    text-overflow: ellipsis;
    transform: translateX(-50%);
    white-space: nowrap;
}

.floor-plan-position__marker-name {
    display: block;
    overflow: hidden;
    margin-bottom: 0.25rem;
    text-overflow: ellipsis;
}

.floor-plan-position__marker-alarm {
    display: block;
    margin-top: 0.25rem;
}

.floor-plan-position__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.floor-plan-position__marker--legend {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    vertical-align: middle;
    cursor: default;
    touch-action: auto;
    transform: none;
}

.leaflet-dragging .location-picker-marker__pin {
    cursor: grabbing;
}

.measurement-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.measurement-card {
    border: 1px solid #d8d8d8;
    border-radius: 0.75rem;
    padding: 1rem;
    background: #fff;
}

.measurement-card__name {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.measurement-card__value {
    font-size: 2rem;
    font-weight: 600;
    line-height: 1.2;
}

.measurement-card__unit {
    font-size: 1rem;
    font-weight: 400;
}

.measurement-card__time {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--brand-gray-700);
}

.device-status {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
    margin: 1rem 0 2rem;
    padding: 0.75rem 1rem;
    border: 1px solid #d8d8d8;
    border-radius: 0.75rem;
    background: #f8f8f8;
}

.uplinks-table {
    width: 100%;
    border-collapse: collapse;
}

.uplinks-table th,
.uplinks-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

.uplinks-table th {
    font-size: 0.85rem;
    color: #666;
}

.uplinks-table td {
    font-size: 0.9rem;
}

.device-status__communication {
    font-weight: 600;
}

.device-status__communication--online {
    color: #197a3e;
}

.device-status__communication--delayed {
    color: #9a6700;
}

.device-status__communication--offline {
    color: #b42318;
}

.device-status__communication--never_seen {
    color: #666;
}

.device-status__communication--irregular {
    color: #055160;
}

.alarm-section {
    margin: 1.5rem 0;
}

.alarm-section--open {
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 0.75rem;
}

.alarm-card {
    margin-top: 0.75rem;
    padding: 1rem;
    border-left: 5px solid #777;
    background: #fafafa;
}

.alarm-card--info {
    border-left-color: #2563eb;
}

.alarm-card--warning {
    border-left-color: #d97706;
}

.alarm-card--critical {
    border-left-color: #b91c1c;
}

.alarm-card__header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.alarm-severity {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.alarm-card__time {
    font-size: 0.875rem;
    color: #666;
}

.alarm-history-table {
    width: 100%;
    border-collapse: collapse;
}

.alarm-history-table th,
.alarm-history-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

.alarm-history-table th {
    font-size: 0.85rem;
    color: #666;
}

.alarm-setting {
    margin: 1.5rem 0;
    padding: 1rem;
    border: 1px solid #d8d8d8;
    border-radius: 0.75rem;
    background: #fff;
}

.alarm-setting h2 {
    margin-top: 0;
}

.alarm-setting__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit,
            minmax(250px, 1fr));
    gap: 1.5rem;
}

.alarm-setting__group {
    padding: 1rem;
    border: 1px solid #e5e5e5;
    border-radius: 0.5rem;
}

.alarm-setting__group h3 {
    margin-top: 0;
}

.alarm-setting__group>div {
    margin-bottom: 0.75rem;
}

.alarm-setting__group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.alarm-setting__group input,
.alarm-setting__group select {
    width: 100%;
    max-width: 16rem;
}

.device-thresholds {
    margin: 2rem 0;
}

.device-thresholds__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.device-thresholds__header h2 {
    margin: 0;
}

.threshold-table {
    width: 100%;
    border-collapse: collapse;
}

.threshold-table th,
.threshold-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

.threshold-table th {
    font-size: 0.85rem;
    color: #666;
}

.measurement-card--normal {
    border-color: #cfd8d3;
}

.measurement-card--warning {
    border-color: #d97706;
    border-left-width: 5px;
}

.measurement-card--critical {
    border-color: #b91c1c;
    border-left-width: 5px;
}

.measurement-card--info {
    border-color: #2563eb;
    border-left-width: 5px;
}

.measurement-card__status {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #197a3e;
}

.measurement-card__alarm {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.measurement-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.measurement-card__header .measurement-card__name {
    margin-bottom: 0;
}

.measurement-status-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.measurement-status-badge--normal {
    background: #e7f5ec;
    color: #197a3e;
}

.measurement-status-badge--info {
    background: #e8f0fe;
    color: #2563eb;
}

.measurement-status-badge--warning {
    background: #fff3d6;
    color: #9a6700;
}

.measurement-status-badge--critical {
    background: #fdecec;
    color: #b42318;
}

.measurement-card--pending {
    border-color: #d4a72c;
    border-left-width: 5px;
}

.measurement-status-badge--pending {
    background: #fff7d6;
    color: #7a5c00;
}

.measurement-card__pending {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #7a5c00;
}

/* Application shell */
:root {
    --brand-red: #EF3340;
    --brand-red-rgb: 239, 51, 64;
    --brand-red-hover: #C92531;
    --action-primary: #0D6EFD;
    --action-primary-hover: #0B5ED7;
    --action-primary-rgb: 13, 110, 253;
    --brand-black: #1D1D1B;
    --brand-black-rgb: 29, 29, 27;
    --brand-charcoal: #292927;
    --brand-gray-700: #545452;
    --brand-gray-300: #D8D8D4;
    --brand-gray-100: #F1F1EF;
    --brand-background: #F6F6F4;
    --brand-white: #FFFFFF;
    /* The real height of the top bar: padding, user button with its border,
       red line. A smaller value makes every short page scroll. */
    --app-navbar-height: calc(1rem + 2.75rem + 2px + 0.2rem);
    --app-sidebar-width: 17rem;

    --bs-primary: var(--brand-red);
    --bs-primary-rgb: var(--brand-red-rgb);
    --bs-link-color: var(--brand-red);
    --bs-link-color-rgb: var(--brand-red-rgb);
    --bs-link-hover-color: var(--brand-red-hover);
    --bs-link-hover-color-rgb: 201, 37, 49;
    --bs-body-font-family: Arial, Helvetica, sans-serif;
    --bs-body-bg: var(--brand-background);
    --bs-body-color: var(--brand-black);
    --bs-border-color: var(--brand-gray-300);
    --bs-focus-ring-color: rgba(var(--brand-red-rgb), 0.22);
}

body {
    color: var(--brand-black);
    font-family: Arial, Helvetica, sans-serif;
    background: var(--brand-background);
}

.app-navbar {
    min-height: var(--app-navbar-height);
    background-color: var(--brand-black) !important;
    border-bottom: 0.2rem solid var(--brand-red);
}

.app-navbar .navbar-brand {
    /* The logo fills the bar; the bar's own padding is enough around it. */
    padding-top: 0;
    padding-bottom: 0;
    color: var(--brand-white);
    font-weight: 700;
    letter-spacing: 0.01em;
}

.app-navbar .navbar-brand:hover,
.app-navbar .navbar-brand:focus {
    color: var(--brand-white);
}

.app-brand {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 0.75rem;
}

.app-brand__logo-surface {
    display: inline-flex;
    flex: 0 1 auto;
    align-items: center;
    padding: 0.3rem 0.55rem;
    background: transparent;
    border-radius: 0.2rem;
}

/* In the navbar the logo fills the bar; the bar's own padding is enough. */
.app-navbar .app-brand__logo-surface {
    padding-top: 0;
    padding-bottom: 0;
}

.app-brand-logo {
    display: block;
    /* The logo is about 3.8 : 1. At 10.5rem it is 2.75rem high, which fills the
       navbar without making it taller. */
    width: clamp(6rem, 24vw, 10.5rem);
    height: auto;
}

/* Imprint: the only place that shows the company logos. */
.imprint-logo {
    display: block;
    width: min(22rem, 100%);
    height: auto;
}

/* Authentication */
.guest-page {
    min-height: 100vh;
    background:
        linear-gradient(145deg, rgba(var(--brand-red-rgb), 0.045), transparent 42%),
        var(--brand-background);
}

.guest-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: clamp(2rem, 7vh, 5rem) 1rem;
}

.guest-shell__content {
    width: 100%;
    max-width: 31rem;
    justify-self: center;
}

.guest-shell .guest-brand {
    width: 100%;
    margin-bottom: 1.5rem;
}

.auth-card {
    position: relative;
    overflow: hidden;
    border: 0.125rem solid var(--brand-black);
    border-radius: 0.9375rem;
    box-shadow: 0 0.75rem 2.25rem rgba(var(--brand-black-rgb), 0.1);
}

.auth-card::before {
    content: "";
    flex: 0 0 0.25rem;
    background: var(--brand-red);
}

.auth-card__body {
    padding: clamp(1.5rem, 5vw, 2.5rem);
}

.auth-locale-switcher {
    display: flex;
    justify-content: flex-end;
    margin: -0.25rem 0 1.25rem;
}

.auth-locale-switcher__list {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-locale-switcher__item + .auth-locale-switcher__item {
    border-left: 1px solid var(--brand-gray-300);
}

.auth-locale-switcher__link {
    display: inline-flex;
    min-width: 2.4rem;
    min-height: 2.25rem;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.55rem;
    color: #585854;
    border-radius: 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-decoration: none;
}

.auth-locale-switcher__link:hover {
    color: var(--brand-red-hover);
    background: var(--brand-gray-100);
}

.auth-locale-switcher__link:focus-visible {
    color: var(--brand-black);
    outline: 0.2rem solid rgba(var(--brand-red-rgb), 0.35);
    outline-offset: 0.1rem;
}

.auth-locale-switcher__link--active {
    color: var(--brand-black);
    background: rgba(var(--brand-red-rgb), 0.1);
    box-shadow: inset 0 -0.15rem 0 var(--brand-red);
}

.auth-card__header {
    margin-bottom: 1.75rem;
}

.auth-card__accent {
    display: block;
    width: 2.75rem;
    height: 0.2rem;
    margin-bottom: 0.85rem;
    background: var(--brand-red);
}

.auth-card__title {
    margin: 0;
    color: var(--brand-black);
    font-size: clamp(1.65rem, 5vw, 2rem);
    font-weight: 700;
    line-height: 1.2;
}

.auth-form {
    display: grid;
    gap: 1.25rem;
}

.auth-form .form-label {
    margin-bottom: 0.45rem;
    color: var(--brand-black);
    font-weight: 600;
}

.auth-form .form-control {
    min-height: 3rem;
    border-color: #B8B8B3;
}

.auth-form .form-control::placeholder {
    color: #686864;
    opacity: 1;
}

.auth-card__submit {
    width: 100%;
    min-height: 3rem;
    font-size: 1.1875rem;
    font-weight: 700;
}

.auth-card__footer {
    padding: 1rem clamp(1.5rem, 5vw, 2.5rem);
    text-align: center;
    background: var(--brand-gray-100);
    border-top: 1px solid var(--brand-gray-300);
}

.auth-card__footer a {
    color: var(--brand-red-hover);
    font-weight: 600;
    text-underline-offset: 0.18em;
}

.guest-shell .alert {
    margin-bottom: 1rem;
    border-width: 1px 1px 1px 0.3rem;
    border-radius: 0.5rem;
    box-shadow: 0 0.25rem 1rem rgba(var(--brand-black-rgb), 0.07);
}

@media (max-width: 575.98px) {
    .guest-shell {
        align-items: start;
        padding-block: 1.5rem;
    }

    .guest-shell .guest-brand {
        margin-bottom: 1.25rem;
    }
}

.app-navbar .btn-dark {
    --bs-btn-bg: var(--brand-black);
    --bs-btn-border-color: var(--brand-gray-700);
    --bs-btn-hover-bg: var(--brand-charcoal);
    --bs-btn-hover-border-color: var(--brand-red);
    --bs-btn-active-bg: var(--brand-charcoal);
    --bs-btn-active-border-color: var(--brand-red);
    --bs-btn-focus-shadow-rgb: var(--brand-red-rgb);
}

.app-navbar [data-testid="user-menu"] > .btn {
    display: inline-flex;
    max-width: 30vw;
    align-items: center;
    gap: 0.5rem;
}

.user-menu__initials,
.user-menu__avatar {
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    flex: 0 0 2rem;
    align-items: center;
    justify-content: center;
    color: var(--brand-white);
    background: var(--brand-gray-700);
    border-radius: 50%;
    font-size: 0.875rem;
    font-weight: 600;
}

.user-menu__avatar {
    object-fit: cover;
    object-position: center;
}

.app-navbar [data-testid="user-menu"] .dropdown-menu {
    min-width: 16rem;
    max-width: calc(100vw - 1.5rem);
}

.user-menu__identity {
    white-space: normal;
    overflow-wrap: anywhere;
}

.device-type-image-thumbnail {
    display: block;
    width: 3rem;
    height: 3rem;
    object-fit: contain;
}

.device-type-image-display {
    display: block;
    width: auto;
    max-width: min(100%, 30rem);
    max-height: 20rem;
    object-fit: contain;
}

.device-type-image-device {
    display: block;
    width: auto;
    max-width: min(100%, 20rem);
    max-height: 12rem;
    object-fit: contain;
}

.device-type-image-placeholder {
    display: grid;
    place-items: center;
    color: var(--bs-secondary-color);
    background: var(--brand-gray-100);
    border: 1px dashed var(--bs-border-color);
    border-radius: 0.375rem;
}

.user-menu__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-navbar .navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(var(--brand-red-rgb), 0.3);
}

.app-shell {
    display: flex;
    min-height: calc(100vh - var(--app-navbar-height));
    /* On phones the window is shorter than 100vh while the browser bar shows. */
    min-height: calc(100dvh - var(--app-navbar-height));
}

.app-sidebar {
    position: sticky;
    top: var(--app-navbar-height);
    flex: 0 0 var(--app-sidebar-width);
    width: var(--app-sidebar-width);
    height: calc(100vh - var(--app-navbar-height));
    padding: 1.25rem 1rem;
    overflow-y: auto;
    background: var(--brand-black);
    border-right: 1px solid var(--brand-charcoal);
}

.app-main {
    min-width: 0;
    flex: 1 1 auto;
}

/* The footer is revealed at the end of the page: it is fixed to the bottom
   of the window and painted only inside its own place in the page
   (.app-footer clips it), so it shows as the content scrolls away above it.
   An invisible copy gives that place the footer's height. */
html:has(.app-footer) {
    scroll-padding-top: var(--app-navbar-height);
}

.app-main {
    display: flex;
    flex-direction: column;
}

/* The space above the footer is the container's padding alone. */
.app-main > .container-fluid {
    padding-bottom: 1.5rem;
}

.app-main > .container-fluid > :last-child {
    margin-bottom: 0 !important;
}

.app-footer {
    position: relative;
    margin-top: auto;
    border-top: 1px solid var(--bs-border-color);
    clip-path: inset(0);
}

.app-footer__ghost {
    visibility: hidden;
}

.app-footer__fixed {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    background: var(--brand-background);
}

@media (min-width: 992px) {
    .app-footer__fixed {
        left: var(--app-sidebar-width);
    }
}

/* A footer link that has keyboard focus must be visible: the footer then
   shows in full, above the content it covers. */
.app-footer:has(:focus-visible) {
    clip-path: none;
}

.app-footer:has(:focus-visible) .app-footer__fixed {
    z-index: 1010;
    border-top: 1px solid var(--bs-border-color);
}

@media print {
    .app-footer {
        clip-path: none;
    }

    .app-footer__ghost {
        display: none;
    }

    .app-footer__fixed {
        position: static;
    }
}

.app-navigation__link {
    padding: 0.6rem 0.75rem;
    color: rgba(255, 255, 255, 0.82);
    border-radius: 0.375rem;
}

.app-navigation__link:hover,
.app-navigation__link:focus {
    color: var(--brand-white);
    background: rgba(255, 255, 255, 0.1);
}

.app-navigation .app-navigation__link.active {
    color: #fff;
    font-weight: 600;
    background: var(--brand-red);
}

.app-navigation__section {
    margin: 1.25rem 0 0.35rem;
    padding: 0 0.75rem;
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

#appNavigation {
    width: min(19rem, 85vw);
    color: var(--brand-white);
    background: var(--brand-black);
}

#appNavigation .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

#appNavigation .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

@media (max-width: 991.98px) {
    .app-main {
        width: 100%;
    }
}

@media (min-width: 992px) {
    .app-navbar .app-brand__logo-surface {
        width: calc(var(--app-sidebar-width) - 2rem);
        flex: 0 0 calc(var(--app-sidebar-width) - 2rem);
        justify-content: center;
    }
}

@media (max-width: 991.98px) {
    .app-brand {
        flex-direction: column;
        gap: 0.125rem;
    }

    .app-brand__logo-surface {
        padding: 0.25rem 0.4rem;
    }

    .app-navbar .app-brand-logo {
        width: clamp(7rem, 36vw, 9rem);
    }
}

/* On a phone the name would be cut to one letter; the initials stand for it
   and the button keeps its accessible name. */
@media (max-width: 575.98px) {
    .app-navbar .user-menu__name {
        display: none;
    }
}

/* Shared fachview presentation */
.page-header__accent {
    width: 3rem;
    height: 0.25rem;
    margin-bottom: 0.75rem;
    background: var(--brand-red);
}

.page-header h1 {
    color: var(--brand-black);
    font-weight: 700;
}

/* Shared content rhythm; card layouts and heading semantics stay intact. */
.app-main > .container-fluid > section {
    margin-block: 0 1.5rem;
}

.app-main > .container-fluid > section > .measurement-cards {
    margin-bottom: 0;
}

.app-main section > h2:not(.visually-hidden),
.app-main .device-thresholds__header > h2 {
    margin-block: 0 1rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--brand-gray-300);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.35;
}

.app-main :where(.card-header, .card-body) > h2:not(.visually-hidden) {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.35;
}

.app-main section h3:not(:where(.h1, .h2, .h3, .h4, .h5, .h6)) {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
}

.app-main :where(p, dd) {
    line-height: 1.55;
}

.app-main :where(small, .small, .form-text):not(:where(.badge, .badge *, .measurement-status-badge, .measurement-chart *, svg, svg *)) {
    font-size: 0.875rem;
}

.organization-logo-preview {
    display: block;
    width: auto;
    max-width: min(100%, 15rem);
    max-height: 7.5rem;
    object-fit: contain;
}

.organization-logo-display {
    display: flex;
    align-items: center;
    min-height: 6rem;
    padding: 1rem 1.25rem;
    background: var(--brand-white);
    border-left: 0.25rem solid var(--brand-red);
    border-radius: 0.5rem;
    box-shadow: 0 0.25rem 1rem rgba(var(--brand-black-rgb), 0.07);
}

.organization-logo-display__image {
    display: block;
    width: auto;
    max-width: min(100%, 20rem);
    max-height: 8rem;
    object-fit: contain;
}

.organization-index-logo {
    display: block;
    width: auto;
    max-width: 3rem;
    max-height: 3rem;
    object-fit: contain;
}

.organization-index-logo__placeholder {
    color: var(--brand-gray-700);
}

.btn-primary {
    --bs-btn-color: var(--brand-white);
    --bs-btn-hover-color: var(--brand-white);
    --bs-btn-active-color: var(--brand-white);
    --bs-btn-disabled-color: var(--brand-white);
    --bs-btn-bg: var(--action-primary);
    --bs-btn-border-color: var(--action-primary);
    --bs-btn-hover-bg: var(--action-primary-hover);
    --bs-btn-hover-border-color: var(--action-primary-hover);
    --bs-btn-focus-shadow-rgb: var(--action-primary-rgb);
    --bs-btn-active-bg: var(--action-primary-hover);
    --bs-btn-active-border-color: var(--action-primary-hover);
    --bs-btn-disabled-bg: var(--action-primary);
    --bs-btn-disabled-border-color: var(--action-primary);
}

.btn-outline-primary {
    --bs-btn-disabled-color: var(--action-primary);
    --bs-btn-disabled-border-color: var(--action-primary);
    --bs-btn-color: var(--action-primary);
    --bs-btn-border-color: var(--action-primary);
    --bs-btn-hover-color: var(--brand-white);
    --bs-btn-hover-bg: var(--action-primary);
    --bs-btn-hover-border-color: var(--action-primary);
    --bs-btn-focus-shadow-rgb: var(--action-primary-rgb);
    --bs-btn-active-color: var(--brand-white);
    --bs-btn-active-bg: var(--action-primary-hover);
    --bs-btn-active-border-color: var(--action-primary-hover);
}

.btn-outline-secondary {
    --bs-btn-focus-shadow-rgb: var(--brand-black-rgb);
    --bs-btn-active-color: var(--brand-white);
    --bs-btn-disabled-color: var(--brand-black);
    --bs-btn-disabled-border-color: var(--brand-gray-700);
    --bs-btn-color: var(--brand-black);
    --bs-btn-border-color: var(--brand-gray-700);
    --bs-btn-hover-color: var(--brand-white);
    --bs-btn-hover-bg: var(--brand-black);
    --bs-btn-hover-border-color: var(--brand-black);
    --bs-btn-active-bg: var(--brand-charcoal);
    --bs-btn-active-border-color: var(--brand-charcoal);
}

.profile-avatar {
    display: inline-flex;
    width: 7rem;
    height: 7rem;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    color: var(--brand-white);
    background: var(--brand-black);
    border-radius: 50%;
    font-size: 2rem;
    font-weight: 700;
}

.profile-details dt {
    color: var(--brand-gray-700);
}

#recent-uplinks {
    scroll-margin-top: calc(var(--app-navbar-height) + 1rem);
}

.dashboard-kpi {
    border: 0;
    border-top: 0.25rem solid var(--brand-red);
    box-shadow: 0 0.125rem 0.35rem rgba(var(--brand-black-rgb), 0.08);
}

.dashboard-kpi__label {
    color: var(--brand-gray-700);
    font-size: 0.875rem;
    font-weight: 600;
}

.dashboard-kpi__value {
    margin-top: 0.5rem;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.dashboard-kpi .card-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0.75rem 1rem;
}

.dashboard-priority > * {
    min-width: 0;
}

:is(.dashboard-map, .device-details) .device-map {
    container-type: inline-size;
    height: 15rem;
}

:is(.dashboard-map, .device-details) .leaflet-popup-content {
    max-width: calc(100cqw - 4rem);
    max-height: 10rem;
    overflow: auto;
}

:is(.dashboard-map, .device-details) .device-map-popup {
    min-width: 0;
}

:is(.dashboard-map, .device-details__location) > .card {
    margin-bottom: 0 !important;
}

.device-details > * {
    min-width: 0;
}

.device-details section > p {
    margin-bottom: 0.5rem;
    overflow-wrap: anywhere;
}

.device-details__location > section:first-child {
    margin-bottom: 1.5rem;
}

.app-main > .container-fluid > .device-current-measurements {
    margin-bottom: 1rem;
}

@media (min-width: 1400px) {
    .dashboard-action-card,
    .dashboard-priority > .dashboard-map > .card {
        height: 100%;
    }
}

/* Keep all six action fields readable within this dashboard card. */
.dashboard-action-table .table {
    table-layout: auto;
    width: 100%;
}

/* Wrap at word boundaries only; a name that does not fit scrolls the table
   instead of breaking in the middle of a word. */
.dashboard-action-table :is(td, .badge, .dashboard-action-value) {
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
}

.dashboard-action-table #action-column-1 {
    width: 1%;
}

.dashboard-action-table .table th {
    word-break: normal;
    overflow-wrap: normal;
    white-space: normal;
}

.dashboard-action-value {
    display: block;
}

@media (max-width: 767.98px) {
    .dashboard-action-table :is(table, tbody, tr, td) {
        display: block;
        width: 100%;
    }

    /* Retain real column headers for assistive technology. */
    .dashboard-action-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }

    .dashboard-action-table tbody tr + tr {
        border-top: 2px solid var(--brand-gray-300);
    }

    .dashboard-action-table td {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
        gap: 0.75rem;
    }

    .dashboard-action-table td::before {
        content: attr(data-label);
        font-weight: 600;
    }
}

.dashboard-status-summary {
    display: flex;
    min-height: 3.25rem;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--brand-gray-100);
    border-radius: 0.375rem;
}

.dashboard-status-summary__count {
    font-size: 1.35rem;
}

.favorite-help-dialog {
    width: min(34rem, calc(100vw - 2rem));
    max-width: 100%;
    color: var(--bs-body-color);
    background: var(--bs-body-bg);
}

.favorite-help-dialog::backdrop {
    background: rgba(var(--brand-black-rgb), 0.55);
}

.favorite-help-dialog__content {
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.favorite-help-dialog__instruction {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--brand-gray-100);
    border-radius: 0.5rem;
}

.favorite-help-dialog__instruction[hidden] {
    display: none;
}

.favorite-help-dialog__instruction kbd,
.favorite-help-dialog__instruction > [aria-hidden="true"] {
    min-width: 3.75rem;
    color: var(--brand-white);
    background: var(--brand-black);
    border-radius: 0.35rem;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
}

.pwa-install-dialog {
    width: min(30rem, calc(100vw - 2rem));
    max-width: 100%;
    color: var(--bs-body-color);
    background: var(--bs-body-bg);
}

.pwa-install-dialog::backdrop {
    background: rgba(var(--brand-black-rgb), 0.55);
}

.pwa-install-dialog__content {
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.session-ended-dialog {
    width: min(30rem, calc(100vw - 2rem));
    max-width: 100%;
    color: var(--bs-body-color);
    background: var(--bs-body-bg);
}

.session-ended-dialog::backdrop {
    background: rgba(var(--brand-black-rgb), 0.55);
}

.session-ended-dialog__content {
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 0.25rem rgba(var(--brand-red-rgb), 0.18);
}

.form-check-input:checked {
    background-color: var(--brand-red);
    border-color: var(--brand-red);
}

a:focus-visible,
button:focus-visible {
    outline: 0.2rem solid rgba(var(--brand-red-rgb), 0.45);
    outline-offset: 0.15rem;
}

.btn:focus-visible {
    outline-color: rgba(var(--bs-btn-focus-shadow-rgb), 0.8);
}

.card {
    --bs-card-bg: var(--brand-white);
    --bs-card-border-color: var(--brand-gray-300);
}

.table-responsive {
    position: relative;
    border-radius: 0.5rem;
    border: 1px solid var(--brand-gray-300);
}

.table-responsive > .table {
    margin-bottom: 0;
    background: var(--brand-white);
}

.app-main .table {
    font-size: 1rem;
    line-height: 1.45;
}

.app-main .table > :not(caption) > * > * {
    padding-block: 0.625rem;
}

.app-main .table.table-sm > :not(caption) > * > * {
    padding-block: 0.5rem;
}

:where(.app-main .table) :where(th, td) {
    font-size: inherit;
}

/* A table that scrolls sideways keeps its actions in view: the action column
   stays at the right edge. Bootstrap paints a cell's hover and stripe colour
   as an inset shadow, so that shadow is kept and the divider line added to it. */
.table-responsive > .table > :is(thead, tbody) > tr > .table-action-cell {
    position: sticky;
    right: 0;
    z-index: 1;
    box-shadow:
        inset 0 0 0 9999px var(--bs-table-bg-state, var(--bs-table-bg-type, var(--bs-table-accent-bg))),
        -1px 0 0 var(--brand-gray-300);
}

/* On a phone the first column, which names the row, stays in view as well. */
@media (max-width: 767.98px) {
    .table-responsive:not(.dashboard-action-table) > .table > :is(thead, tbody) > tr > :first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        max-width: 42vw;
        box-shadow:
            inset 0 0 0 9999px var(--bs-table-bg-state, var(--bs-table-bg-type, var(--bs-table-accent-bg))),
            1px 0 0 var(--brand-gray-300);
    }
}

/* Tables outside scroll wrappers get the same edge treatment without clipping. */
.app-main :not(.table-responsive) > .table {
    border: 1px solid var(--brand-gray-300);
    border-radius: 0.5rem;
    border-collapse: separate;
    border-spacing: 0;
}

.app-main :not(.table-responsive) > .table > :first-child > tr:first-child > :first-child {
    border-start-start-radius: 0.5rem;
}

.app-main :not(.table-responsive) > .table > :first-child > tr:first-child > :last-child {
    border-start-end-radius: 0.5rem;
}

.app-main :not(.table-responsive) > .table > :last-child > tr:last-child > :first-child {
    border-end-start-radius: 0.5rem;
}

.app-main :not(.table-responsive) > .table > :last-child > tr:last-child > :last-child {
    border-end-end-radius: 0.5rem;
}

/* Underlines retain the link cue; actions and semantic status links keep their styling. */
.app-main :where(.table, p, dd, .compact-action-row) a:where(:not(.btn, .badge, .organization-logo, .measurement-status-badge, [class*="text-"], [class*="link-"], [class*="marker"])) {
    color: var(--brand-gray-700);
    text-decoration-color: var(--brand-gray-300);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
}

.app-main :where(.table, p, dd, .compact-action-row) a:where(:not(.btn, .badge, .organization-logo, .measurement-status-badge, [class*="text-"], [class*="link-"], [class*="marker"])):is(:hover, :focus-visible) {
    color: var(--brand-black);
    text-decoration-line: underline;
    text-decoration-color: currentColor;
}

.table th {
    white-space: nowrap;
}

/* Normal table empty messages match the dashboard's quiet, left-aligned hint. */
.app-main .card .table-empty-state {
    color: var(--bs-secondary-color);
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.55;
    text-align: start;
    margin: 0;
}

/* Overview headers wrap at word boundaries without shrinking their type. */
.overview-table th {
    white-space: normal;
    word-break: normal;
    overflow-wrap: normal;
}

.table > thead > tr > th {
    color: var(--brand-black);
    background: var(--brand-gray-100);
    border-bottom-color: var(--brand-gray-300);
}

.avatar-placeholder {
    display: inline-flex;
    width: 2.5rem;
    height: 2.5rem;
    align-items: center;
    justify-content: center;
    color: #495057;
    font-size: 0.8rem;
    font-weight: 700;
    background: #e9ecef;
    border-radius: 50%;
}

.form-control,
.form-select {
    max-width: 100%;
}

@media (max-width: 767.98px) {
    .table-responsive .btn {
        margin-block: 0.125rem;
    }
}

/* Device measurement chart */
.measurement-chart {
    overflow: hidden;
    border-top: 0.25rem solid var(--brand-red);
    box-shadow: 0 0.125rem 0.35rem rgba(var(--brand-black-rgb), 0.08);
}

.measurement-chart__canvas {
    min-height: 10rem;
    overflow-x: auto;
    color: var(--brand-gray-700);
}

.measurement-chart__canvas > svg {
    display: block;
    width: 100%;
    min-width: 42rem;
    height: auto;
    color: var(--brand-black);
}

.measurement-chart__series-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    gap: 0.35rem 1rem;
}

.measurement-chart__device-group {
    min-width: 0;
    padding: 0.75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
}

.measurement-chart__device-group legend {
    float: none;
    width: auto;
}

.measurement-chart__device-group,
.measurement-chart__metric-toggles {
    overflow-wrap: anywhere;
}

.measurement-chart__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.measurement-chart__legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.measurement-chart__legend-swatch {
    width: 0.8rem;
    height: 0.8rem;
    flex: 0 0 0.8rem;
    border-radius: 50%;
}

.measurement-chart__legend-threshold-swatch {
    width: 1.25rem;
    height: 0;
    flex: 0 0 1.25rem;
    border-top: 0.15rem dashed;
}

.measurement-chart__axis {
    color: var(--brand-gray-700);
    font-size: 0.75rem;
}

.measurement-chart__axis-label {
    fill: var(--brand-black);
    font-size: 0.8rem;
    font-weight: 600;
}

.measurement-chart__line {
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: round;
    stroke-width: 2.5;
}

.measurement-chart__threshold-line {
    stroke-width: 2;
    stroke-dasharray: 7 5;
    opacity: 0.9;
}

.measurement-chart__threshold-line--above,
.measurement-chart__threshold-line--below {
    stroke-width: 3;
}

.measurement-chart__threshold-outside-label {
    font-size: 0.72rem;
    font-weight: 700;
}

.measurement-chart__focus line {
    stroke: var(--brand-gray-700);
    stroke-dasharray: 4 4;
    stroke-opacity: 0.5;
}

.measurement-chart__tooltip {
    position: absolute;
    z-index: 2;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    color: var(--brand-white);
    background: var(--brand-black);
    border-radius: 0.4rem;
    box-shadow: 0 0.25rem 0.75rem rgba(var(--brand-black-rgb), 0.2);
    pointer-events: none;
    font-size: 0.85rem;
    overflow-wrap: anywhere;
}

/* Compact downlink payload and the existing disclosure/editor patterns. */
.downlink-payload { width: 24ch; max-width: 100%; }
.downlink-guidance { overflow-wrap: anywhere; }
#downlinks .field-help { min-width: 0; }
#downlinks .field-help .form-text { font-size: inherit; }
trix-editor[data-downlink-guidance-target] { min-height: 8rem; }
trix-toolbar [data-trix-active] { background-color: var(--bs-secondary-bg); }
[data-downlink-guidance-target][hidden] { display: none !important; }

/* Device details: keep the existing content order and full-width data sections. */
.device-show > .card,
.device-show .device-details .card {
    border: 0;
    border-radius: var(--bs-border-radius-lg);
    box-shadow: var(--bs-box-shadow-sm);
}

.device-show > section {
    margin-block: 0 1.5rem;
}

.device-show .device-section,
.device-show .card-body {
    padding: 1.5rem;
}

.device-show .card-header {
    padding-inline: 1.5rem;
}

.device-show :where(p, dd, h1, h2, h3, .device-facts, .device-overview) {
    overflow-wrap: anywhere;
}

.device-show .device-section > :last-child,
.device-show .device-overview__identity > :last-child,
.device-show .measurement-cards {
    margin-bottom: 0;
}

.device-show .device-overview {
    display: grid;
    gap: 1rem 1.5rem;
}

.device-overview > *,
.device-facts > * {
    min-width: 0;
}

.device-show .device-status {
    grid-template-columns: minmax(0, 1fr);
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    align-content: start;
}

.device-show .device-status__communication {
    color: inherit;
    font-weight: inherit;
}

.device-facts {
    display: grid;
    gap: 0.75rem 1.5rem;
}

.device-facts > p {
    margin: 0;
}

.device-show .device-details__location {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.device-facts strong {
    display: block;
}

.device-show .device-metadata-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem 1rem;
    margin-inline: 0;
}

.device-show .device-metadata-list > * {
    width: auto;
    min-width: 0;
    padding: 0;
    margin: 0;
}

.device-show .device-metadata-list > dd {
    margin-bottom: 0.75rem;
}

@media (min-width: 576px) {
    .device-show .device-metadata-list {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
    }
}

@media (min-width: 1200px) {
    .device-show .device-overview {
        grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    }

    .device-overview__identity:only-child {
        grid-column: 1 / -1;
    }

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

    .device-show .device-metadata-list {
        grid-template-columns: repeat(2, minmax(0, 1fr) minmax(0, 1.5fr));
        column-gap: 1.5rem;
    }
}

.gps-route-endpoint {
    display: grid;
    place-items: center;
    border: 2px solid var(--bs-body-color);
    border-radius: 50%;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-weight: 600;
}

.gps-route .leaflet-interactive:focus-visible {
    outline: 3px solid var(--bs-body-color);
    outline-offset: 3px;
}

.gps-route .device-map {
    container-type: inline-size;
}

.gps-route .leaflet-popup-content {
    max-width: calc(100cqw - 4rem);
    overflow-wrap: anywhere;
}

.app-navbar__organization-logo {
    box-sizing: border-box;
    padding: 5px;
    display: block;
    height: 2.875rem;
    width: 2.875rem;
    object-fit: contain;
    flex-shrink: 0;
}

/* Short device facts adapt to their section width, including beside a map. */
.device-facts-container {
    container-type: inline-size;
}

.device-facts--hardware,
.device-facts--location {
    margin-bottom: 1rem;
    overflow-wrap: anywhere;
}

@container (min-width: 28rem) {
    .device-facts--hardware,
    .device-facts--location {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Turbo owns submit disabling and aria-busy; keep the previous results visible. */
.software-check-form .software-check-running { display: none; }
.software-check-form[aria-busy="true"] .software-check-idle { display: none; }
.software-check-form[aria-busy="true"] .software-check-running { display: inline; }

/* Decorative history stays within the existing current-value card. */
.measurement-card__sparkline {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 2rem;
    margin-block: 0.4rem;
    color: var(--brand-gray-700, #545452);
    opacity: 0.65;
}
.measurement-card__sparkline polyline {
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linejoin: round;
    stroke-linecap: round;
}

/* Share intrinsic track heights across each row, including wrapped metric names. */
.device-current-measurements .measurement-card {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: span 5;
    row-gap: 0;
    min-width: 0;
}
.device-current-measurements .measurement-card__header { align-items: start; }
.measurement-card__history { min-width: 0; }
.measurement-sparkline { position: relative; margin-block: 0.4rem; }
.measurement-sparkline .measurement-card__sparkline { margin: 0; }
.measurement-sparkline__point {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand-gray-700);
    transform: translate(-50%, -50%);
    pointer-events: none;
}
.measurement-sparkline__tooltip {
    max-width: 100%;
    width: max-content;
    font-size: 0.75rem;
    line-height: 1.3;
    padding: 0.35rem 0.5rem;
}

/* Forecast on the trend view: dotted line, a light band of 80 % of the
   expected values, and a thin line at the present. */
.measurement-chart__forecast-line {
    fill: none;
    stroke-width: 2.5;
    stroke-dasharray: 2 5;
    stroke-linecap: round;
}

.measurement-chart__forecast-band {
    opacity: 0.15;
    stroke: none;
}

.measurement-chart__now-line {
    stroke: var(--bs-secondary-color, #6c757d);
    stroke-width: 1;
    stroke-dasharray: 3 3;
}

.measurement-chart__legend-forecast-swatch {
    width: 1.25rem;
    height: 0;
    flex: 0 0 1.25rem;
    border-top: 0.2rem dotted;
}

/* Project names in the admin user list stay readable; the table scrolls. */
.user-projects-cell {
    min-width: 11rem;
}

/* Two-factor set-up: QR code on white (readable in dark mode too) and codes in two columns. */
.two-factor-qr {
    display: inline-block;
    padding: 12px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.two-factor-qr img {
    display: block;
    width: 200px;
    height: 200px;
}

.two-factor-codes {
    columns: 2;
    max-width: 22rem;
    font-size: 1.05rem;
    line-height: 2;
}

/* Column headers that sort the table in the browser (table_sort_controller.js):
   a button that looks like the header text it replaces. */
.table-sort__button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-align: inherit;
    cursor: pointer;
}

.table-sort__button:hover {
    text-decoration: underline;
}
