:root {
    --primary: #1d4ed8;
    --bg: #f4f6f9;
    --panel: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --dim: #64748b;
    --font: 'Noto Sans SC', 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.la-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 48px;
    background: #1e3a8a;
    flex-shrink: 0;
}
.la-header h1 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}
.la-header .logo {
    display: inline-flex;
    width: 22px; height: 22px;
    border-radius: 6px;
    background: rgba(255,255,255,.15);
    align-items: center; justify-content: center;
    font-size: 12px;
}
.header-actions { display: flex; gap: 8px; }
.btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.btn:hover { border-color: #cbd5e1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* 避免 .btn { display:inline-flex } 盖掉 hidden */
[hidden] { display: none !important; }
.btn-ghost {
    background: transparent;
    border-color: rgba(255,255,255,.25);
    color: #e2e8f0;
}
.btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.btn-sm { padding: 4px 8px; font-size: 12px; }
.la-main {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 260px 1fr;
    margin-top: 0;
}
.la-side {
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.side-head {
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.line-list { flex: 1; overflow: auto; padding: 8px; }
.side-empty, .work-empty {
    padding: 24px 16px;
    color: var(--dim);
    font-size: 13px;
    text-align: center;
}
.line-item {
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    margin-bottom: 4px;
}
.line-item:hover { background: #f8fafc; }
.line-item.active {
    background: #eff6ff;
    border-color: #bfdbfe;
}
.line-item .ln { font-size: 13px; font-weight: 600; }
.line-item .meta { font-size: 11px; color: var(--dim); margin-top: 2px; }
.la-work {
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}
.work-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px 8px;
    flex-shrink: 0;
}
.work-head h2 { font-size: 18px; font-weight: 700; }
.work-sub { font-size: 12px; color: var(--dim); margin-top: 4px; }
.work-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs {
    display: flex;
    gap: 4px;
    padding: 0 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.tab {
    border: none;
    background: transparent;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--dim);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.branch-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    flex-shrink: 0;
}
.branch-label {
    font-size: 12px;
    color: var(--dim);
    flex-shrink: 0;
}
.branch-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.branch-tab {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
}
.branch-tab.active {
    border-color: var(--primary);
    color: var(--primary);
    background: #eff6ff;
    font-weight: 600;
}
.tab-panels {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.tab-panel {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 12px 18px 18px;
}
.tab-panel.active { display: flex; flex-direction: column; }
#panelPath.active { min-height: 0; }
.order-toolbar {
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; }
.hint { font-size: 12px; color: var(--dim); flex: 1; min-width: 200px; line-height: 1.5; }
.station-order { display: flex; flex-direction: column; gap: 6px; }
.st-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
}
.st-row.editable { cursor: pointer; }
.st-row.editable:hover { background: #f8fafc; }
.st-row.selected {
    background: #eff6ff;
    border-color: #93c5fd;
}
.st-row .idx {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: #f1f5f9;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; color: var(--dim); flex-shrink: 0;
}
.st-row.selected .idx { background: #dbeafe; color: #1d4ed8; font-weight: 700; }
.st-row .body { flex: 1; min-width: 0; }
.st-row .name { font-size: 13px; font-weight: 600; }
.st-row .key { font-size: 11px; color: var(--dim); }
.st-row .coords { font-size: 11px; color: var(--dim); flex-shrink: 0; }
.st-row .row-moves {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.st-row .drag-handle {
    width: 22px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    cursor: grab;
    flex-shrink: 0;
    user-select: none;
    font-size: 14px;
    letter-spacing: -1px;
}
.st-row .drag-handle:active { cursor: grabbing; }
.st-row.order-editing { background: #f8fafc; }
.st-row.dragging {
    opacity: .55;
    border-style: dashed;
    border-color: #93c5fd;
}
.st-row.drag-over {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, .15);
}
.st-row .move-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--dim);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
}
.st-row .move-btn:hover:not(:disabled) {
    border-color: #93c5fd;
    color: var(--primary);
    background: #eff6ff;
}
.st-row .move-btn:disabled { opacity: .35; cursor: not-allowed; }
.hint.dirty { color: #b45309; }
.dir-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.dir-tabs {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}
.dir-tab {
    border: none;
    background: transparent;
    padding: 7px 14px;
    font-size: 13px;
    color: var(--dim);
    cursor: pointer;
}
.dir-tab + .dir-tab { border-left: 1px solid var(--border); }
.dir-tab.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}
.dir-hint { font-size: 12px; color: var(--dim); }
.path-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 12px;
}
.seg-list {
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
}
.seg-item {
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
    margin-bottom: 2px;
}
.seg-item:hover { background: #f8fafc; }
.seg-item.active { background: #eff6ff; border-color: #bfdbfe; }
.seg-item .seg-name { font-size: 13px; font-weight: 500; }
.seg-item .seg-meta { font-size: 11px; color: var(--dim); margin-top: 2px; }
.path-editor {
    min-height: 0;
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 10px;
}
.path-map {
    min-height: 280px;
    background: #e2e8f0;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.path-form {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}
.path-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.path-hint { font-size: 12px; color: var(--dim); margin-bottom: 0; }
.path-form-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.path-actions { display: flex; gap: 8px; flex-shrink: 0; }
.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--dim);
}
.field textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    resize: vertical;
    color: var(--text);
    line-height: 1.45;
    min-height: 120px;
}
.info-dl {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
    display: grid;
    gap: 12px;
    max-width: 520px;
}
.info-dl > div { display: grid; grid-template-columns: 96px 1fr; gap: 8px; font-size: 13px; }
.info-dl dt { color: var(--dim); }
.toast {
    position: fixed; top: 56px; left: 50%; transform: translateX(-50%) translateY(-8px);
    background: #fff; border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 16px; font-size: 13px; box-shadow: 0 8px 24px rgba(15,23,42,.12);
    opacity: 0; pointer-events: none; transition: .2s; z-index: 99;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: #fca5a5; }
.toast.success { border-color: #6ee7b7; }
@media (max-width: 900px) {
    .la-main { grid-template-columns: 1fr; }
    .la-side { max-height: 180px; }
    .path-layout { grid-template-columns: 1fr; }
}
