.drag-cell {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

.drag-handle {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    color: #475467;
    cursor: grab;
    font-size: 17px;
    line-height: 1;
    user-select: none;
    padding: 0;
}

.drag-handle:active {
    cursor: grabbing;
}

[data-route-row].is-dragging td {
    background: #eaf2ff !important;
    opacity: .72;
}

.route-position {
    width: 58px;
    min-width: 58px;
    height: 28px;
    padding: 2px 6px;
    border-radius: 6px;
    color: var(--ink);
    text-align: center;
}

.route-controls {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.schedule-scroll {
    position: relative;
    max-height: calc(100vh - 130px);
    min-height: 420px;
    overflow: auto;
}

.schedule-editor {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.schedule-editor :is(th, td):nth-child(-n+7) {
    position: sticky;
    background: #fff;
    z-index: 3;
}

.schedule-editor th:nth-child(-n+7) {
    background: #f2f4f7;
    z-index: 6;
}

.schedule-editor thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #f2f4f7;
}

.schedule-editor thead th:nth-child(-n+7) {
    z-index: 7;
}

.schedule-editor :is(th, td):nth-child(1) { left: 0; width: 175px; min-width: 175px; max-width: 175px; }
.schedule-editor :is(th, td):nth-child(2) { left: 175px; width: 230px; min-width: 230px; max-width: 230px; }
.schedule-editor :is(th, td):nth-child(3) { left: 405px; width: 150px; min-width: 150px; max-width: 150px; }
.schedule-editor :is(th, td):nth-child(4) { left: 555px; width: 92px; min-width: 92px; max-width: 92px; }
.schedule-editor :is(th, td):nth-child(5) { left: 647px; width: 52px; min-width: 52px; max-width: 52px; }
.schedule-editor :is(th, td):nth-child(6) { left: 699px; width: 76px; min-width: 76px; max-width: 76px; }
.schedule-editor :is(th, td):nth-child(7) {
    left: 775px;
    width: 90px;
    min-width: 90px;
    max-width: 90px;
    box-shadow: 6px 0 8px -7px rgba(16, 24, 40, .55);
}

.schedule-editor :is(th, td):nth-child(n+8):not(:last-child) {
    border-left: 1px solid #98a2b3;
}

.schedule-editor :is(th, td):nth-last-child(2) {
    border-right: 1px solid #98a2b3;
}

.schedule-editor tr:hover td:nth-child(-n+7) {
    background: #f8fafc;
}

.travel-time-control {
    display: flex;
    align-items: center;
    justify-content: center;
}

.travel-time-control input[type="text"] {
    width: 68px;
    min-width: 68px;
    padding: 7px 5px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.travel-time-control > span {
    display: none;
}

.time-anchor > span {
    margin: 0;
    color: var(--muted);
    font-size: 10px;
    font-weight: 650;
}

.travel-time-first {
    color: var(--muted);
    font-size: 12px;
}

.schedule-editor .time-cell {
    display: grid;
    min-width: 178px;
    gap: 5px;
}

.time-anchor {
    display: grid;
    grid-template-columns: auto minmax(108px, 1fr);
    align-items: center;
    gap: 6px;
}

.time-anchor input[type="time"] {
    min-width: 108px;
    padding: 7px 8px;
}

.calculated-time {
    min-height: 15px;
    color: var(--blue) !important;
    font-size: 10px;
    font-weight: 700;
}

.trip-options {
    position: relative;
    width: 100%;
}

.trip-options[open] {
    z-index: 20;
}

.trip-options > summary {
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    color: #344054;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    list-style: none;
}

.trip-options > summary::-webkit-details-marker {
    display: none;
}

.trip-options > summary::after {
    content: "▾";
    margin-left: 2px;
    color: var(--muted);
}

.trip-options[open] > summary::after {
    transform: rotate(180deg);
}

.trip-options-menu {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    min-width: 180px;
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 24px rgba(16, 24, 40, .16);
    text-align: left;
}

.trip-options-menu .mini-check {
    justify-content: flex-start;
}

.skip-stop span {
    color: #b42318;
}

[data-trip-stop-cell].is-skipped {
    opacity: 1;
}

[data-trip-stop-cell].is-skipped > :not(.trip-options) {
    opacity: .68;
}

[data-trip-stop-cell].is-skipped .trip-options-menu {
    background: #fff;
    color: var(--ink);
    opacity: 1;
}

.route-pole-select {
    min-width: 130px;
    max-width: 190px;
}

.route-move {
    width: 27px;
    height: 28px;
    padding: 0;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    color: #344054;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
}

.route-move:hover:not(:disabled) {
    border-color: var(--blue);
    color: var(--blue);
}

.route-move:disabled {
    cursor: not-allowed;
    opacity: .35;
}

.route-row-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

.route-replace-button {
    min-height: 30px;
    padding: 4px 9px;
    border: 1px solid #cfd4dc;
    border-radius: 7px;
    background: #fff;
    color: #344054;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.route-replace-button:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.route-replace-dialog {
    width: min(650px, calc(100vw - 32px));
    overflow: visible;
    padding: 0;
    border: 0;
    border-radius: 14px;
    color: var(--ink);
    box-shadow: 0 24px 70px rgba(16, 24, 40, .28);
}

.route-replace-dialog::backdrop {
    background: rgba(16, 24, 40, .5);
}

.route-replace-form {
    display: grid;
    gap: 17px;
    padding: 24px;
}

.route-replace-form > p {
    margin: 0;
}

.route-replace-header,
.route-replace-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.route-replace-header h2,
.route-replace-header p {
    margin: 0;
}

.route-replace-close {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f2f4f7;
    color: #475467;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.route-replace-actions {
    justify-content: flex-end;
    padding-top: 5px;
}

.hidden-action-form {
    display: none;
}

.line-tools .card {
    align-content: start;
}

.line-tools .form-help {
    margin: 0;
    font-size: 13px;
}

.button:disabled,
input:disabled,
select:disabled {
    cursor: not-allowed;
    opacity: .55;
}

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

.upload-grid > * {
    min-width: 0;
}

.upload {
    min-width: 0;
    overflow: hidden;
}

.upload code {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.upload input[type="file"] {
    min-width: 0;
    max-width: 100%;
    font-size: 13px;
}

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

@media (max-width: 1080px) {
    .upload-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

main {
    max-width: none;
}

@media (min-width: 1081px) {
    .topbar {
        padding-left: 24px;
        padding-right: 24px;
    }
}

@media (max-width: 800px) {
    .line-import-grid {
        grid-template-columns: 1fr;
    }
}

.danger-zone {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-color: #fda29b;
    background: #fffafa;
}

.danger-zone h2,
.danger-zone p {
    margin-top: 0;
}

.button.danger {
    flex: 0 0 auto;
    border-color: #b42318;
    background: #b42318;
    color: #fff;
}

.stop-public-name,
.internal-stop-name {
    display: block;
}

.internal-stop-name {
    margin-top: 3px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
}

.stop-export-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
    padding: 15px 4px;
    border-top: 1px solid var(--line);
}

.stop-export-title {
    min-width: 0;
    font-size: 15px;
    line-height: 1.3;
}

.stop-export-meta {
    display: block;
    min-width: 0;
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.stop-export-actions {
    justify-content: flex-start;
    padding-top: 3px;
}

.stop-record[hidden],
.stop-export-row[hidden] {
    display: none !important;
}

.stop-edit-panel {
    margin: -5px 4px 13px;
    padding: 0 12px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafafa;
}

.stop-edit-panel summary {
    padding: 10px 0;
    color: var(--blue);
    font-size: 13px;
    font-weight: 750;
    cursor: pointer;
}

.stop-edit-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stop-edit-actions {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.stop-edit-actions small {
    color: var(--muted);
}

.route-stop-picker {
    position: relative;
}

.route-stop-picker > label > span {
    display: block;
    margin-bottom: 6px;
}

.route-stop-control {
    position: relative;
}

.route-stop-control input[type="search"] {
    padding-right: 44px;
}

.route-stop-toggle {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 40px;
    height: calc(100% - 2px);
    border: 0;
    border-left: 1px solid #d0d5dd;
    border-radius: 0 8px 8px 0;
    background: #fff;
    color: var(--muted);
    font-size: 20px;
    cursor: pointer;
}

.route-stop-toggle.is-open {
    color: var(--ink);
}

.route-stop-options {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    left: 0;
    z-index: 40;
    max-height: 260px;
    overflow: auto;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 14px 32px rgba(16, 24, 40, .16);
}

.route-stop-option {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 0;
    border-top: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.route-stop-option[hidden],
.route-stop-empty[hidden] {
    display: none;
}

.route-stop-option:first-child {
    border-top: 0;
}

.route-stop-option:hover,
.route-stop-option:focus,
.route-stop-option.is-active,
.route-stop-option.is-selected {
    outline: 0;
    background: #f2f4f7;
}

.route-stop-option > span {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.route-stop-option > span > span {
    color: var(--muted);
    font-size: 12px;
}

.route-stop-option small {
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

.route-stop-empty {
    margin: 0;
    padding: 14px 12px;
    color: var(--muted);
    font-size: 13px;
}

.stop-export-row small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.settings-menu {
    position: relative;
    display: flex;
    align-items: stretch;
}

.settings-menu > summary {
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    font-weight: 650;
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
}

.settings-menu > summary::-webkit-details-marker {
    display: none;
}

.settings-menu > summary::after {
    content: '▾';
    margin-left: 6px;
    font-size: 10px;
}

.settings-menu.active > summary,
.settings-menu[open] > summary,
.settings-menu > summary:hover {
    border-bottom-color: var(--red);
    color: var(--ink);
}

.settings-dropdown {
    position: absolute;
    top: calc(100% - 1px);
    right: 0;
    z-index: 50;
    display: grid;
    min-width: 245px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: var(--shadow);
}

.topbar nav .settings-dropdown a {
    min-height: 38px;
    padding: 9px 11px;
    border: 0;
    border-radius: 7px;
}

.topbar nav .settings-dropdown a:hover,
.topbar nav .settings-dropdown a.active {
    border: 0;
    background: #f2f4f7;
    color: var(--ink);
}

.stop-heading {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    padding-bottom: 8px;
}

.stop-list.stop-management-list {
    max-height: none;
    overflow: visible;
    margin-top: 20px;
}

.stop-filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 18px;
}

.stop-unused-filter {
    min-height: 42px;
    margin-bottom: 14px;
    padding: 0 12px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #f8fafc;
    white-space: nowrap;
}

.stop-unused-filter span {
    margin: 0;
    color: #344054;
    font-size: 13px;
}

.stop-line-usage {
    position: relative;
    justify-self: end;
    padding: 5px 9px;
    border: 1px solid #d0d5dd;
    border-radius: 999px;
    background: #f8fafc;
    color: #475467;
    font-size: 12px;
    font-weight: 750;
    cursor: help;
    white-space: nowrap;
}

.stop-line-usage:focus {
    outline: 3px solid #dbeafe;
    border-color: #2e90fa;
}

.stop-line-tooltip {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    z-index: 45;
    display: none;
    width: max-content;
    min-width: 230px;
    max-width: min(390px, 82vw);
    padding: 11px 13px;
    border-radius: 8px;
    background: #101828;
    color: #fff;
    box-shadow: 0 12px 28px rgba(16, 24, 40, .22);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.45;
    white-space: normal;
}

.stop-line-tooltip::before {
    position: absolute;
    right: 18px;
    bottom: 100%;
    border: 6px solid transparent;
    border-bottom-color: #101828;
    content: '';
}

.stop-line-tooltip ul {
    margin: 6px 0 0;
    padding-left: 19px;
}

.stop-line-usage:hover .stop-line-tooltip,
.stop-line-usage:focus .stop-line-tooltip,
.stop-line-usage:focus-within .stop-line-tooltip {
    display: block;
}

.stop-delete-form {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: 18px 16px 16px;
    padding: 15px;
    border: 1px solid #fda29b;
    border-radius: 9px;
    background: #fffafa;
}

.stop-delete-form small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

.stop-management-title {
    font-size: 17px;
    line-height: 1.3;
}

.pole-list {
    padding: 0 4px 8px 18px;
}

.pole-export-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
    padding: 10px 0 12px;
    border-top: 1px dashed var(--line);
}

.pole-schedule-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.pole-schedule-title small {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.pole-schedule-actions {
    justify-content: flex-start;
}

.stop-inline-notes {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.stop-inline-notes h3 {
    margin: 0 0 5px;
}

.pole-management {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.pole-management h3 {
    margin: 0 0 10px;
}

.pole-edit-row {
    display: flex;
    align-items: end;
    gap: 10px;
    padding: 9px 0;
    border-top: 1px dashed var(--line);
}

.pole-edit-form,
.pole-create-form {
    display: grid;
    flex: 1;
    grid-template-columns: minmax(95px, .45fr) minmax(180px, 1fr) minmax(135px, .7fr) minmax(135px, .7fr) minmax(180px, 1fr) auto;
    align-items: end;
    gap: 10px;
}

.pole-create-form {
    margin-top: 13px;
    padding-top: 13px;
    border-top: 1px solid var(--line);
}

.pdf-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}

.line-badge.is-inactive {
    background: var(--red);
}

.line-status-form {
    margin: 0;
}

.line-status-toggle {
    cursor: pointer;
    font-family: inherit;
}

.line-list-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--line);
}

.line-list-main {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: space-between;
    gap: 13px;
    min-width: 0;
    padding: 14px 4px;
    color: var(--ink);
    text-decoration: none;
}

.line-list-main > span:nth-child(2) {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
}

.line-list-main small {
    display: block;
    margin-top: 3px;
    color: var(--muted);
}

.line-list-entry:hover {
    background: #fafafa;
}

.pdf-option {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--ink);
    font-size: .84rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.pdf-option:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.restriction-edit-form {
    flex: 1;
    grid-template-columns: 150px minmax(280px, 1fr) auto;
    align-items: end;
}

.restriction-edit-form .form-actions {
    grid-column: auto;
}

@media (max-width: 680px) {
    .stop-filter-bar {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .stop-unused-filter {
        margin: 0 0 14px;
        white-space: normal;
    }

    .stop-export-row {
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .pdf-options {
        justify-content: flex-start;
    }

    .line-list-entry {
        align-items: stretch;
        flex-direction: column;
        gap: 0;
        padding-bottom: 10px;
    }

    .line-list-entry > .pdf-option {
        align-self: flex-start;
        margin-left: 4px;
    }

    .stop-edit-form {
        grid-template-columns: 1fr;
    }

    .pole-export-row,
    .pole-edit-row {
        align-items: stretch;
        flex-direction: column;
    }

    .pole-edit-form,
    .pole-create-form {
        grid-template-columns: 1fr;
    }

    .stop-edit-actions {
        grid-column: 1;
        align-items: stretch;
        flex-direction: column;
    }

    .restriction-edit-form {
        width: 100%;
        grid-template-columns: 1fr;
    }

    .restriction-edit-form .form-actions {
        grid-column: 1;
    }

    .danger-zone {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (max-width: 1080px) {
    .settings-menu > summary {
        min-height: 46px;
        padding: 0 11px;
    }

    .settings-dropdown {
        right: auto;
        left: 0;
    }
}
