body {
    margin: 0;
    font-family: var(--wa-font-family-body, system-ui, sans-serif);
    background: var(--wa-color-surface-default, #f4f5f7);
    color: var(--wa-color-text-normal, #1b1f24);
}

.page-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--wa-color-surface-raised, #fff);
    border-bottom: 1px solid var(--wa-color-surface-border, #e2e4e8);
}

.page-header h1 {
    font-size: 1.25rem;
    margin: 0;
    flex: 1;
}

.admin-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--wa-color-text-quiet, #5b616e);
    padding: 0.25rem;
    border-radius: var(--wa-border-radius-s, 4px);
}

.admin-link:hover {
    color: var(--wa-color-text-normal, #1b1f24);
    background: var(--wa-color-surface-lowered, #eceef1);
}

.admin-login {
    max-width: 320px;
    margin: 2rem auto;
}

.admin-login form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.admin-login label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.9rem;
}

.admin-login input {
    padding: 0.5rem;
    border: 1px solid var(--wa-color-surface-border, #e2e4e8);
    border-radius: var(--wa-border-radius-s, 4px);
    font-size: 1rem;
}

.admin-breadcrumb {
    font-size: 0.8rem;
    color: var(--wa-color-text-quiet, #5b616e);
    margin-bottom: 0.4rem;
}

.admin-breadcrumb a {
    color: inherit;
}

.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.admin-page-header h2 {
    margin: 0;
}

.admin-page-header-actions {
    display: flex;
    gap: 0.6rem;
}

.field-hint {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--wa-color-text-quiet, #5b616e);
}

.sections-dialog {
    width: min(480px, 90vw);
    padding: 0;
    border: none;
    border-radius: var(--wa-border-radius-m, 8px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.sections-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

.stop-edit-dialog {
    width: min(560px, 92vw);
    max-height: 85vh;
    padding: 0;
    border: none;
    border-radius: var(--wa-border-radius-m, 8px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

/* Must be conditioned on [open] -- an unconditional "display: flex" here would override the
   browser's own "dialog:not([open]) { display: none }" rule, leaving the dialog permanently
   visible (showing its default "Loading..." placeholder) even when never actually opened. */
.stop-edit-dialog[open] {
    display: flex;
    flex-direction: column;
}

.stop-edit-dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

.stop-edit-dialog #stop-edit-dialog-body {
    padding: 1.25rem;
    overflow-y: auto;
}

.stop-edit-dialog #stop-edit-dialog-body h3 {
    margin: 0 0 1rem;
    font-size: 1.05rem;
}

.stop-edit-dialog .sections-dialog-header {
    /* Close-only header (no title -- the fragment renders its own "Add Stop"/"Edit Stop" heading) */
    justify-content: flex-end;
    padding: 0.6rem 0.75rem 0;
    border-bottom: none;
}

.sections-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--wa-color-surface-border, #e2e4e8);
}

.sections-dialog-header h3 {
    margin: 0;
    font-size: 1.05rem;
}

.sections-dialog-close {
    border: none;
    background: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--wa-color-text-quiet, #5b616e);
    border-radius: var(--wa-border-radius-s, 4px);
}

.sections-dialog-close:hover {
    background: var(--wa-color-surface-lowered, #eceef1);
    color: var(--wa-color-text-normal, #1b1f24);
}

#sections-dialog-body,
#restore-dialog-body {
    padding: 1.25rem;
}

#restore-dialog-body wa-callout {
    display: block;
    margin-bottom: 1rem;
}

.ingestion-callout-list {
    margin: 0;
    padding-left: 1.1rem;
}

.ingestion-start-form {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.restore-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sections-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.sections-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    border-radius: var(--wa-border-radius-s, 4px);
    font-size: 0.9rem;
}

.sections-row:not(.sections-row-pinned):hover {
    background: var(--wa-color-surface-lowered, #eceef1);
}

.sections-row-dragging {
    opacity: 0.4;
}

.sections-reordering,
.sections-reordering * {
    user-select: none;
    -webkit-user-select: none;
}

.sections-row-pinned {
    color: var(--wa-color-text-quiet, #5b616e);
    font-style: italic;
}

.sections-row-handle {
    display: inline-flex;
    align-items: center;
    color: var(--wa-color-text-quiet, #5b616e);
    cursor: grab;
    touch-action: none;
}

.sections-row-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sections-row-pinned .sections-row-name {
    font-weight: 400;
}

.sections-row-usage {
    font-size: 0.8rem;
    color: var(--wa-color-text-quiet, #5b616e);
    white-space: nowrap;
}

.sections-row-hint {
    grid-column: 2 / -1;
    font-size: 0.78rem;
}

.sections-edit-button,
.sections-delete-button {
    border: none;
    background: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--wa-color-text-quiet, #5b616e);
    border-radius: var(--wa-border-radius-s, 4px);
    display: inline-flex;
}

.sections-edit-button:hover {
    background: var(--wa-color-surface-lowered, #eceef1);
    color: var(--wa-color-text-normal, #1b1f24);
}

.sections-delete-button:hover:not(:disabled) {
    background: var(--wa-color-danger-10, #fee2e2);
    color: var(--wa-color-danger-60, #dc2626);
}

.sections-delete-button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.sections-form {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--wa-color-surface-border, #e2e4e8);
}

.sections-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.sections-form input {
    padding: 0.45rem;
    border: 1px solid var(--wa-color-surface-border, #e2e4e8);
    border-radius: var(--wa-border-radius-s, 4px);
    font-size: 0.95rem;
    font-weight: 400;
}

.sections-form input[name="name"] {
    width: 180px;
}

.sections-form-actions {
    display: flex;
    gap: 0.5rem;
}

.admin-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.admin-panel p {
    color: var(--wa-color-text-quiet, #5b616e);
}

.ingestion-section {
    margin-top: 1.5rem;
}

.ingestion-section h3 {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--wa-color-text-quiet, #5b616e);
    margin: 0 0 0.6rem;
}

.ingestion-run-summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.ingestion-step-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.ingestion-step {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
}

.ingestion-step-label {
    min-width: 140px;
    font-weight: 600;
}

.ingestion-step-label-disabled {
    text-decoration: line-through;
    color: var(--wa-color-text-quiet, #5b616e);
    font-weight: 400;
}

.ingestion-step-detail {
    min-width: 90px;
    color: var(--wa-color-text-quiet, #5b616e);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.ingestion-step-rows,
.ingestion-step-message {
    color: var(--wa-color-text-quiet, #5b616e);
    font-size: 0.85rem;
}

.ingestion-progress-bar-track {
    position: relative;
    background: var(--wa-color-surface-lowered, #eceef1);
    border-radius: 999px;
    height: 6px;
    width: 140px;
    flex-shrink: 0;
    overflow: hidden;
}

.ingestion-progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    border-radius: 999px;
    background: var(--wa-color-brand-60, #2563eb);
    transition: width 0.3s ease;
}

.ingestion-progress-bar-fill.status-pending {
    background: var(--wa-color-surface-border, #e2e4e8);
}

.ingestion-progress-bar-fill.status-completed {
    background: var(--wa-color-success-60, #16a34a);
}

.ingestion-progress-bar-fill.status-failed {
    background: var(--wa-color-danger-60, #dc2626);
}

.ingestion-progress-bar-fill.status-skipped {
    background: var(--wa-color-neutral-40, #9aa1ab);
}

.ingestion-progress-bar-fill.indeterminate {
    width: 35%;
    left: -35%;
    animation: ingestion-indeterminate 1.1s ease-in-out infinite;
}

@keyframes ingestion-indeterminate {
    0% {
        left: -35%;
    }
    100% {
        left: 100%;
    }
}

.ingestion-file-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.ingestion-file-table th,
.ingestion-file-table td {
    text-align: left;
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--wa-color-surface-border, #e2e4e8);
}

.ingestion-file-table th {
    color: var(--wa-color-text-quiet, #5b616e);
    font-weight: 600;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

.board-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.refresh-button::part(base) {
    padding-inline: 0.5rem;
}

.status-text {
    color: var(--wa-color-text-quiet, #5b616e);
    font-size: 0.9rem;
}

.columns {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 800px) {
    .columns {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

.column h2 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--wa-color-text-quiet, #5b616e);
    margin: 0 0 0.75rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.stop-card {
    font-size: 0.9rem;
}

.stop-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-weight: 600;
}

.stop-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pin-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    padding: 0.2rem;
    margin: 0;
    line-height: 1;
    cursor: pointer;
    color: var(--wa-color-text-quiet, #5b616e);
    border-radius: var(--wa-border-radius-s, 4px);
}

.pin-button:hover {
    color: var(--wa-color-text-normal, #1b1f24);
    background: var(--wa-color-surface-lowered, #eceef1);
}

.pin-button.pinned {
    color: var(--wa-color-brand-60, #2563eb);
}

.pinned-section h2 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--wa-color-text-quiet, #5b616e);
    margin: 0 0 0.75rem;
}

.pinned-section {
    margin-bottom: 1.5rem;
}

.departure-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.departure-list li {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.departure-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.departure-gps {
    font-size: 0.72rem;
    font-weight: 300;
    color: var(--wa-color-text-quiet, #5b616e);
}

.departure-list .destination {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.departure-list .due {
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.departure-list .source-icon {
    font-size: 0.8rem;
    color: var(--wa-color-text-quiet, #5b616e);
    width: 1em;
    flex-shrink: 0;
    text-align: center;
}

.empty-hint {
    color: var(--wa-color-text-quiet, #5b616e);
    font-size: 0.85rem;
    grid-column: 1 / -1;
}

.panel-stop + .panel-divider,
.panel-divider {
    border: none;
    border-top: 1px solid var(--wa-color-surface-border, #e2e4e8);
    margin: 0.6rem 0;
}

.panel-stop-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--wa-color-text-quiet, #5b616e);
    margin-bottom: 0.4rem;
}

.unavailable-hint {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--wa-color-warning-60, #b45309);
    font-weight: 600;
}

.stop-sections {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stop-section-details::part(base) {
    border-radius: var(--wa-border-radius-m, 0.5rem);
}

.stop-section-details::part(summary) {
    font-weight: 600;
}

.stop-section-count {
    color: var(--wa-color-text-quiet, #5b616e);
    font-weight: 400;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.stop-table-wrap {
    overflow-x: auto;
}

.stop-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.stop-table th,
.stop-table td {
    text-align: left;
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid var(--wa-color-surface-border, #e2e4e8);
    white-space: nowrap;
}

.stop-table th {
    color: var(--wa-color-text-quiet, #5b616e);
    font-weight: 600;
}

.stop-table-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.stop-table-actions form {
    display: inline-flex;
}

.stop-edit-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 480px;
}

.stop-edit-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.stop-edit-form input,
.stop-edit-form select {
    padding: 0.5rem;
    border: 1px solid var(--wa-color-surface-border, #e2e4e8);
    border-radius: var(--wa-border-radius-s, 4px);
    font-size: 1rem;
    font-weight: 400;
}

.stop-edit-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.stop-lookup {
    padding: 0.75rem;
    background: var(--wa-color-surface-lowered, #eceef1);
    border-radius: var(--wa-border-radius-s, 4px);
}

.stop-lookup-results {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    max-height: 220px;
    overflow-y: auto;
}

.stop-lookup-result {
    width: 100%;
    text-align: left;
    padding: 0.4rem 0.5rem;
    border: none;
    background: var(--wa-color-surface-raised, #fff);
    border-radius: var(--wa-border-radius-s, 4px);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 400;
}

.stop-lookup-result:hover {
    background: var(--wa-color-brand-10, #dbeafe);
}
