:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f9fafb;
    --text: #171717;
    --muted: #667085;
    --faint: #98a2b3;
    --line: #e4e7ec;
    --line-strong: #d0d5dd;
    --primary: #14532d;
    --primary-weak: #ecfdf3;
    --danger: #b42318;
    --danger-weak: #fef3f2;
    --warn: #b54708;
    --warn-weak: #fffaeb;
    --ok: #067647;
    --ok-weak: #ecfdf3;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    letter-spacing: 0;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 17px; font-weight: 740; }
h2 { font-size: 18px; font-weight: 740; }
h3 { font-size: 15px; margin-bottom: 12px; font-weight: 720; }
p, small { color: var(--muted); }
button, input, select, textarea { font: inherit; }

.app-shell {
    display: grid;
    grid-template-columns: 230px minmax(0, 1fr);
    gap: 0;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 4px 18px;
    border-bottom: 1px solid var(--line);
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 760;
}

.brand p { margin-top: 2px; font-size: 12px; }

.side-nav {
    display: grid;
    gap: 4px;
    margin-top: 16px;
}

.nav-item {
    border: 0;
    border-radius: 7px;
    padding: 10px 11px;
    background: transparent;
    color: #344054;
    text-align: left;
    cursor: pointer;
    font-weight: 650;
}
.nav-item:hover { background: var(--surface-soft); color: var(--text); }
.nav-item.active { background: var(--primary-weak); color: var(--primary); }

.sidebar-foot small { display: block; line-height: 1.45; }
.sidebar-foot {
    margin-top: auto;
    display: grid;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
    padding: 12px 4px 0;
    border-top: 1px solid var(--line);
}

.content {
    min-width: 0;
    padding: 18px;
}

.view { display: none; }
.view.active { display: block; }

.block,
.stats > div {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.block { padding: 16px; margin-bottom: 14px; }
.hero-block { min-height: 0; }

.block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.block-head.compact { margin-bottom: 12px; }
.block-head p { margin-top: 3px; font-size: 13px; }

.stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(128px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.stats > div {
    padding: 14px;
    min-height: 82px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.stats strong { display: block; font-size: 24px; font-weight: 780; line-height: 1.05; }
.stats span { color: var(--muted); font-size: 12px; }

.btn {
    border: 1px solid var(--line-strong);
    background: var(--surface);
    border-radius: 7px;
    padding: 8px 12px;
    cursor: pointer;
    color: #344054;
    transition: border-color .14s ease, background .14s ease, color .14s ease;
}
.btn:hover { border-color: #98a2b3; background: var(--surface-soft); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #0f3f24; }
.btn.ghost { background: var(--surface-soft); }


.head-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.head-actions select {
    width: auto;
    min-width: 140px;
}
.head-actions .btn {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.filters {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) repeat(6, minmax(120px, 150px));
    gap: 10px;
    margin-bottom: 12px;
}

.search-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 8px;
    align-items: center;
}

.search-control .btn {
    min-height: 38px;
    padding: 8px 12px;
    white-space: nowrap;
}
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    padding: 9px 11px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}
input[type="date"] {
    position: relative;
    cursor: pointer;
}
input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}
textarea { min-height: 82px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(20, 83, 45, .11);
}

.table-wrap, .mini-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 11px 10px; text-align: left; vertical-align: top; }
th {
    color: #475467;
    font-weight: 680;
    background: var(--surface-soft);
    white-space: nowrap;
}
tbody tr { transition: background .12s ease; }
tbody tr:hover, tbody tr.selected { background: #f6fef9; }
td small { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
.customer-status-line {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.customer-status-date {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.customer-status-product {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 360px;
}

.link-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--text);
    font-weight: 720;
    cursor: pointer;
    text-align: left;
}
.link-button:hover { color: var(--primary); text-decoration: underline; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 7px;
    border-radius: 6px;
    color: #475467;
    background: #f2f4f7;
    font-size: 12px;
    font-weight: 680;
    margin-right: 5px;
    white-space: nowrap;
}
.badge.danger { background: var(--danger-weak); color: var(--danger); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.level-A { background: #f3e8ff; color: #9333ea; font-weight: 600; }
.badge.level-B { background: #fef3c7; color: #d97706; }
.badge.level-C { background: #e0e7ff; color: #4f46e5; }
.badge.level-D { background: #f2f4f7; color: #667085; }

.software-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.software-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px 3px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface-soft);
    color: #344054;
    font-size: 13px;
    line-height: 1.6;
}
.software-tag b { font-size: 13px; font-weight: 520; }
.software-tag button {
    border: 0;
    background: transparent;
    color: var(--faint);
    cursor: pointer;
    padding: 0 4px;
    font-size: 15px;
    line-height: 1;
    border-radius: 4px;
}
.software-tag button:hover { color: var(--danger); background: var(--danger-weak); }
.tag-add-inline {
    display: inline-flex;
    align-items: center;
    gap: 0;
}
.tag-add-inline input {
    border: 1px dashed var(--line-strong);
    border-radius: 6px;
    background: transparent;
    padding: 3px 10px;
    font-size: 13px;
    color: var(--text);
    width: 110px;
    outline: none;
}
.tag-add-inline input:focus { border-style: solid; border-color: var(--primary); }
.tag-add-inline button {
    border: 1px solid var(--line);
    border-left: 0;
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    padding: 4px 10px;
    font-size: 13px;
    border-radius: 0 6px 6px 0;
}
.tag-add-inline button:hover { color: var(--primary); border-color: var(--primary); }
.badge.muted { background: #f2f4f7; color: #667085; }

.reminders {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 14px;
}

.reminder {
    min-height: 132px;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 15px 16px;
    cursor: pointer;
    transition: background .14s ease, border-color .14s ease, box-shadow .14s ease;
}
.reminder:hover { background: var(--surface-soft); border-color: var(--line-strong); box-shadow: var(--shadow); }
.reminder .title {
    display: block;
    min-height: 40px;
    margin-bottom: 10px;
    color: var(--text);
    font-size: 14px;
    font-weight: 740;
    line-height: 1.42;
    overflow-wrap: anywhere;
}
.reminder > span:not(.title) {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}
.reminder .badge { margin-right: 0; }
.reminder small {
    display: block;
    margin-top: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}
.due-alert { border-left-color: var(--danger); background: #fff; }
.resource-alert { border-left-color: var(--warn); background: #fff; }

.detail-page-head {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}
.detail-page-head h2 { font-size: 22px; }
.detail-page-head p { margin-top: 4px; }
.detail-card { margin-bottom: 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: end;
}
.form-grid label, .inline-field { color: var(--muted); font-size: 13px; }
.form-grid label input, .form-grid label textarea, .inline-field input { margin-top: 5px; }
.form-grid .wide { grid-column: 1 / -1; }
.date-time-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 118px;
    gap: 8px;
}
.customer-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.customer-maintenance {
    margin-top: 14px;
}

.followup-form {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.detail-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.detail-summary div {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}
.detail-summary span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 12px;
}
.detail-summary b {
    font-size: 14px;
    color: var(--text);
}
@media (max-width: 900px) {
    .detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.detail-level-badge {
    vertical-align: middle;
    margin-left: 6px;
    font-size: 13px;
}
.detail-fee-badge {
    vertical-align: middle;
    margin-left: 4px;
    font-size: 13px;
}

.detail-info-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}
.info-chip {
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}
.info-chip span {
    font-size: 12px;
    color: var(--muted);
}
.info-chip b {
    font-size: 14px;
    color: var(--text);
    font-weight: 620;
}
@media (max-width: 720px) {
    .info-chip { padding: 6px 10px; }
    .info-chip span, .info-chip b { font-size: 12px; }
}

.detail-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 14px;
    border-bottom: 2px solid var(--line);
}
.detail-tab {
    padding: 10px 22px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 520;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.detail-tab:hover { color: var(--text); }
.detail-tab.active {
    color: var(--primary);
    font-weight: 680;
    border-bottom-color: var(--primary);
}
.detail-tab-panel {
    display: none;
}
.detail-tab-panel.active {
    display: block;
}

.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: 14px;
    margin-bottom: 14px;
}
.detail-grid > .block { margin-bottom: 0; }

.detail-data-section {
    padding: 0;
    overflow: hidden;
}
.detail-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 52px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}
.detail-section-head h3 { margin: 0; }
.detail-data-section .mini-table { margin: 0; }
.detail-data-section .mini-table th:first-child,
.detail-data-section .mini-table td:first-child { padding-left: 16px; }
.detail-data-section .mini-table th:last-child,
.detail-data-section .mini-table td:last-child { padding-right: 16px; }
.detail-data-section .mini-table tbody tr:last-child td { border-bottom: 0; }
.detail-data-section > .empty { margin: 14px 16px 16px; }

.info-grid {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 9px 12px;
    font-size: 13px;
}
.info-grid span { color: var(--muted); }
.info-grid b { font-weight: 560; overflow-wrap: anywhere; }
.mini-table th, .mini-table td { padding: 8px 9px; font-size: 12px; }

.note { border-top: 1px solid var(--line); padding: 11px 0; }
.note:first-child { border-top: 0; padding-top: 0; }
.note p { margin-top: 5px; color: var(--text); }
.followup-next {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
}
.followup-next b { color: var(--text); font-size: 13px; }

/* === 维护记录 Tab: 快速输入 + 设置卡片 + 时间线 === */
.maintenance-card {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}
.maintenance-input-row {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}
.maintenance-input-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 14px;
}
.maintenance-input-row input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-weak);
}
.maintenance-settings-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}
.settings-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.settings-label {
    font-size: 12px;
    color: var(--muted);
}
.settings-item input,
.settings-item select {
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 13px;
    min-width: 100px;
}
.save-settings-btn {
    margin-left: auto;
}

.followup-timeline {
    margin-top: 4px;
}
.timeline-month {
    margin-bottom: 20px;
}
.timeline-month-head {
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    padding: 4px 0 10px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 10px;
}
.timeline-item {
    position: relative;
    padding-left: 22px;
    padding-bottom: 16px;
}
.timeline-item:last-child { padding-bottom: 4px; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 18px;
    bottom: -4px;
    width: 1px;
    background: var(--line);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
    position: absolute;
    left: 2px;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line);
    border: 2px solid var(--surface);
}
.timeline-item.latest .timeline-dot {
    background: var(--primary);
}
.timeline-item.latest {
    background: var(--primary-weak);
    border-radius: var(--radius);
    margin: -4px -8px 4px -8px;
    padding-left: 30px;
    padding-right: 12px;
    padding-top: 4px;
}
.timeline-item.latest::before {
    left: 13px;
}
.timeline-item.latest .timeline-dot {
    left: 10px;
}
.timeline-body { min-width: 0; }
.timeline-date {
    font-size: 12px;
    color: var(--muted);
}
.timeline-content {
    margin: 4px 0 0;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.timeline-date {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}
.timeline-actions {
    margin-left: auto;
    display: inline-flex;
    gap: 4px;
}
.timeline-action-btn {
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 1px 6px;
    font-size: 12px;
    border-radius: 4px;
    color: var(--muted);
}
.timeline-action-btn:hover { background: var(--line); }
.timeline-action-btn.edit:hover { color: var(--primary); }
.timeline-action-btn.delete { color: #dc2626; }
.timeline-action-btn.delete:hover { background: #fee2e2; color: #b91c1c; }
.timeline-next {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 2px 8px;
    background: var(--surface);
    border-radius: 12px;
    font-size: 12px;
    color: var(--muted);
}
.timeline-next b { color: var(--text); font-size: 12px; }

.empty { color: var(--muted); text-align: center; padding: 42px 16px; }
.empty.small { padding: 18px; background: var(--surface-soft); border-radius: var(--radius); }

#toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    background: #111827;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    transform: translateY(8px);
    box-shadow: 0 12px 28px rgba(16, 24, 40, .18);
}
#toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1120px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .side-nav { grid-template-columns: repeat(3, 1fr); }
    .sidebar-foot { grid-template-columns: 1fr auto; align-items: center; margin-top: 16px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .content { padding: 10px; }
    .sidebar, .block { border-radius: 0; }
    .side-nav, .filters, .form-grid { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr; }
    .detail-page-head { grid-template-columns: 1fr; }
    th, td { padding: 9px; }
}
.sync-actions {
    display: grid;
    grid-template-columns: 108px repeat(7, max-content) minmax(220px, 1fr);
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}
.sync-actions label {
    color: var(--muted);
    font-size: 12px;
}
.sync-actions label input {
    height: 32px;
    margin-top: 3px;
    padding: 5px 8px;
}
.sync-actions .btn {
    min-height: 32px;
    padding: 6px 9px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}
.sync-actions input#index_q {
    height: 34px;
    padding: 6px 10px;
    font-size: 13px;
}
.index-table {
    max-height: 430px;
}
@media (max-width: 720px) {
    .sync-actions { grid-template-columns: 1fr; }
}
.log-detail {
    margin-top: 12px;
    text-align: left;
}
.log-detail-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
}
.log-detail pre {
    margin: 0;
    max-height: 260px;
    overflow: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, "Microsoft YaHei", monospace;
    font-size: 12px;
    line-height: 1.5;
}
.log-table .log-col-time { white-space: nowrap; width: 100px; }
.log-table .log-col-source { white-space: nowrap; width: 100px; }
.log-table .log-col-result { min-width: 120px; }
.log-table .log-col-detail { max-width: 360px; }
.log-table .log-col-action { width: 64px; text-align: center; }
.log-table .log-count { color: var(--muted); font-size: 12px; }
.log-table .log-detail-cell {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.5;
    word-break: break-all;
}
.log-table .log-time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.log-table .muted-text { color: var(--muted); }
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(17, 24, 39, .42);
}
.modal-backdrop.show {
    display: flex;
}
.modal {
    width: min(640px, 100%);
    max-height: min(720px, calc(100vh - 48px));
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(16, 24, 40, .25);
    overflow: hidden;
}
.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 22px 28px 16px;
    border-bottom: 1px solid var(--line);
}
.modal-head h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}
.modal-head p {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--muted);
}

.sync-confirm {
    width: min(480px, 100%);
}
.recharge-modal {
    width: min(440px, 100%);
}
.recharge-form {
    padding: 16px;
}
.input-with-unit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    margin-top: 8px;
}
.input-with-unit input {
    border-radius: var(--radius) 0 0 var(--radius);
}
.input-with-unit span {
    align-self: stretch;
    display: flex;
    align-items: center;
    min-width: 52px;
    justify-content: center;
    border: 1px solid var(--line);
    border-left: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: var(--surface-soft);
    color: var(--muted);
}
.confirm-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 14px;
    color: var(--text);
    font-size: 14px;
}
.confirm-option input {
    width: auto;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 28px 22px;
    border-top: 1px solid var(--line);
    background: var(--surface-soft, #fafbfc);
    border-radius: 0 0 14px 14px;
}

#log-modal-body {
    margin: 0;
    padding: 16px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, "Microsoft YaHei", monospace;
    font-size: 12px;
    line-height: 1.55;
    background: var(--surface-soft);
}
@media (max-width: 720px) {
    .modal-backdrop { padding: 10px; }
    .modal { max-height: calc(100vh - 20px); }
}

.sync-status {
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 13px;
}
.sync-status.running {
    border-color: rgba(181, 71, 8, .25);
    background: var(--warn-weak);
    color: var(--warn);
}
button[disabled] {
    cursor: not-allowed;
    opacity: .58;
}

.hidden { display: none !important; }

.auth-password-modal { width: min(460px, 100%); }
.auth-password-fields {
    display: grid;
    gap: 12px;
    padding: 18px 28px;
}
.auth-password-fields label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
.auth-password-fields input { margin-top: 6px; }
.form-error,
.form-message {
    margin: 0;
    padding: 10px 12px;
    border: 1px solid;
    border-radius: 7px;
    font-size: 13px;
    line-height: 1.5;
}
.form-error {
    border-color: #f2b8b5;
    color: var(--danger);
    background: var(--danger-weak);
}
.form-message {
    border-color: #a7e1bf;
    color: var(--ok);
    background: var(--ok-weak);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 18px 46px rgba(16, 24, 40, .12);
}
.login-card .brand { padding: 0 0 20px; }
.login-copy { margin: 20px 0; }
.login-copy h2 { margin-bottom: 6px; }
.login-form { display: grid; gap: 14px; }
.login-form label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
.login-form input { margin-top: 6px; }
.login-form .btn { min-height: 42px; }
.login-note { margin-top: 18px; font-size: 12px; line-height: 1.6; }


.sync-job-panel {
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
}
.sync-job-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}
.sync-job-panel strong { font-size: 14px; }
.sync-job-panel span,
.sync-job-panel small { color: var(--muted); }
.sync-job-panel.running {
    border-color: rgba(181, 71, 8, .25);
    background: var(--warn-weak);
}

.sync-job-progress {
    height: 7px;
    overflow: hidden;
    margin-bottom: 10px;
    border-radius: 999px;
    background: var(--line);
}
.sync-job-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.sync-job-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}
.sync-job-grid span {
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255,255,255,.72);
    font-size: 12px;
}
@media (max-width: 720px) {
    .sync-job-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


.dashboard-table table { table-layout: fixed; }
.dashboard-table .dashboard-customer-head { width: 28%; }
.dashboard-table .dashboard-status-head { width: 9%; }
.dashboard-table .dashboard-due-head { width: 12%; }
.dashboard-table .dashboard-level-head { width: 6%; }
.dashboard-table .dashboard-desc-head { width: 37%; }
.dashboard-table .dashboard-action-head { width: 8%; text-align: right; }
.dashboard-row { cursor: pointer; }
.dashboard-status-cell,
.dashboard-due-cell,
.dashboard-level-cell { white-space: nowrap; }
.dashboard-desc-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dashboard-action-cell { text-align: right; }
.dashboard-row td { padding: 13px 12px; }
.dashboard-row small { margin-top: 5px; line-height: 1.45; }
.dashboard-row.alert { box-shadow: inset 3px 0 0 var(--danger); }
.dashboard-row.warn { box-shadow: inset 3px 0 0 var(--warn); }
.dashboard-row .badge + .badge { margin-left: 5px; }

.mini-action { padding: 5px 9px; font-size: 12px; min-height: 28px; }
.stats .stat-card {
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.stats .stat-card:hover {
    border-color: var(--primary);
    background: var(--primary-weak);
}
.stats .stat-card.active {
    border-color: var(--primary);
    background: var(--primary-weak);
    box-shadow: inset 0 0 0 1px rgba(20, 83, 45, .18);
}
.dashboard-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    align-items: center;
    white-space: nowrap;
}

.group-cell-line {
    min-height: 34px;
    display: flex;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
}
.group-cell-line:last-child {
    border-bottom: 0;
}
.group-alert-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid var(--line);
}
.group-alert-line:last-child {
    border-bottom: 0;
}
.group-alert-line .dashboard-actions {
    flex-shrink: 0;
}

.dashboard-actions .mini-action {
    padding: 5px 8px;
}
.dashboard-head {
    align-items: center;
}
.dashboard-head select {
    width: 150px;
    min-height: 34px;
}
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin: 8px 0 10px;
    color: var(--muted);
    font-size: 13px;
}
.pagination-bar label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.pagination-bar select {
    min-height: 30px;
    padding: 4px 7px;
}

.level-select {
    min-height: 30px;
    padding: 4px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 7px;
    background: var(--surface);
    font-weight: 700;
}




#sync-view.view.active {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 36px);
}
#sync-view > .block {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 36px);
    margin-bottom: 0;
}
#sync-view .index-table {
    flex: 1;
    min-height: calc(100vh - 330px);
    max-height: none;
    overflow: auto;
}
#sync-view .pagination-bar {
    margin-top: 10px;
}

.manual-modal { max-width: 680px; }
.manual-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.manual-form label {
    color: var(--muted);
    font-size: 13px;
}
.manual-form input,
.manual-form select,
.manual-form textarea {
    margin-top: 5px;
}
.manual-form .wide { grid-column: 1 / -1; }
.manual-form textarea { min-height: 86px; }
.manual-actions { margin-bottom: 10px; }
@media (max-width: 760px) {
    .manual-form { grid-template-columns: 1fr; }
}

.paste-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, .9fr);
    gap: 14px;
    align-items: start;
}
.paste-textarea {
    width: 100%;
    min-height: 520px;
    resize: vertical;
    font-family: Consolas, 'Microsoft YaHei', monospace;
    line-height: 1.6;
}
.paste-preview {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    min-height: 520px;
    background: var(--surface);
}
.paste-preview h3 { margin-bottom: 12px; }
.paste-preview h4 { margin: 16px 0 8px; }
@media (max-width: 980px) {
    .paste-grid { grid-template-columns: 1fr; }
    .paste-textarea, .paste-preview { min-height: 360px; }
}

.index-import-modal { max-width: 900px; }
.index-import-content { padding: 16px; display: grid; gap: 12px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.index-import-content .paste-textarea { min-height: 260px; }
.index-import-content .paste-preview { min-height: 120px; }
.dashboard-table td.merged-customer {
    vertical-align: top;
    background: rgba(255,255,255,.54);
}
.dashboard-table td[rowspan] {
    border-right: 1px solid var(--line);
}
.dashboard-row td {
    vertical-align: middle;
}
.col-sort-btn, .col-filter-btn {
    cursor: pointer;
    margin-left: 4px;
    font-size: 12px;
    color: var(--muted);
    user-select: none;
    padding: 2px 4px;
    border-radius: 4px;
    vertical-align: middle;
}
.col-sort-btn:hover, .col-filter-btn:hover { color: var(--text); background: var(--surface-soft); }
.col-sort-btn.active { color: var(--primary); background: var(--primary-weak); }
.col-filter-btn.active { color: var(--primary); }
.col-filter-dropdown {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow), 0 4px 12px rgba(16,24,40,.1);
    z-index: 20;
    min-width: 130px;
    padding: 4px 0;
}
.col-filter-dropdown div {
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
}
.col-filter-dropdown div:hover { background: var(--primary-weak); }
.col-filter-dropdown div.active { color: var(--primary); font-weight: 600; }
.dashboard-table th { position: relative; }

/* ======================================================================
 * 培训列表 Training — 卡片布局
 * ====================================================================== */

/* 意向客户 */
.lead-stats .stat-card { cursor: pointer; }
.lead-filters { display: grid; grid-template-columns: minmax(280px, 1.4fr) repeat(5, minmax(110px, .7fr)); gap: 8px; margin-bottom: 12px; }
.lead-table { min-width: 920px; table-layout: fixed; }
.lead-table th:nth-child(1) { width: 18%; }
.lead-table th:nth-child(2) { width: 7%; }
.lead-table th:nth-child(3) { width: 11%; }
.lead-table th:nth-child(4) { width: 13%; }
.lead-table th:nth-child(5) { width: 14%; }
.lead-table th:nth-child(6) { width: 29%; }
.lead-table th:nth-child(7) { width: 8%; }
.lead-name-link { font-weight: 700; text-align: left; }
.lead-summary-cell { word-break: break-word; }
.badge.lead-high { background: var(--danger-weak); color: var(--danger); }
.badge.lead-medium { background: var(--warn-weak); color: var(--warn); }
.badge.lead-low { background: #eef2f6; color: #475467; }
.lead-form-modal { width: min(820px, 100%); }
.lead-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 18px 28px; overflow-y: auto; }
.lead-form-grid label, .lead-followup-grid label { color: var(--muted); font-size: 13px; font-weight: 600; }
.lead-form-grid input, .lead-form-grid select, .lead-form-grid textarea, .lead-followup-grid input, .lead-followup-grid select, .lead-followup-grid textarea { margin-top: 6px; }
.lead-form-grid .wide, .lead-followup-grid .wide { grid-column: 1 / -1; }
.lead-form-grid textarea { min-height: 74px; }
.lead-detail-modal { width: min(920px, 100%); }
.lead-detail-body { padding: 18px 28px 24px; overflow-y: auto; }
.lead-detail-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.lead-overview { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -28px 18px; padding: 14px 28px; background: var(--surface-soft); }
.lead-overview > div { min-width: 0; padding: 8px 12px 8px 0; }
.lead-overview span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.lead-overview strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.lead-detail-section { margin-top: 18px; }
.lead-detail-section h3 { margin-bottom: 10px; }
.lead-long-text, .lead-note-text, .lead-lost-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.lead-note-text { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.lead-lost-text { margin-top: 8px; color: var(--danger); }
.lead-followup-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.lead-followup-actions { display: flex; justify-content: flex-end; margin-top: 10px; }
.lead-timeline { border-left: 2px solid var(--line); margin-left: 5px; padding-left: 16px; }
.lead-timeline-item { position: relative; padding: 0 0 16px; }
.lead-timeline-item::before { content: ''; position: absolute; left: -22px; top: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.lead-timeline-item > div { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.lead-timeline-item span, .lead-timeline-item small { color: var(--muted); font-size: 12px; }
.lead-timeline-item p { margin: 6px 0 4px; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
@media (max-width: 980px) {
    .lead-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .lead-filters .search-control { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .lead-filters { grid-template-columns: 1fr 1fr; }
    .lead-form-grid, .lead-followup-grid { grid-template-columns: 1fr; padding-left: 14px; padding-right: 14px; }
    .lead-form-grid .wide, .lead-followup-grid .wide { grid-column: auto; }
    .lead-detail-body { padding: 14px; }
    .lead-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-left: -14px; margin-right: -14px; padding-left: 14px; padding-right: 14px; }
    .lead-detail-actions .btn { flex: 1 1 auto; }
}
/* 筛选栏 */
.training-filter-bar { margin-bottom: 12px; }
.training-filter-row {
    display: flex; gap: 8px; align-items: center; flex-wrap: nowrap;
    overflow-x: auto;
}

.tr-search-group {
    display: flex; gap: 0; flex: 0 0 240px; min-width: 0; max-width: 240px;
}
.tr-search-group input {
    flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-right: 0; border-radius: var(--radius) 0 0 var(--radius);
    font-size: 13px; background: var(--surface); color: var(--text); box-sizing: border-box;
}
.tr-search-group .btn {
    border-radius: 0 var(--radius) var(--radius) 0; padding: 7px 14px; font-size: 13px; white-space: nowrap;
}

#tr-filter-product {
    flex: 0 0 160px; min-width: 0; max-width: 200px;
    padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius);
    font-size: 13px; background: var(--surface); color: var(--text); box-sizing: border-box;
}

.tr-date-group {
    display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0;
    border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px; background: var(--surface);
    cursor: pointer;
    position: relative;
}
.tr-date-group input {
    border: 0; padding: 4px 4px; font-size: 13px; background: transparent; color: var(--text);
    flex: 1; min-width: 0; box-sizing: border-box; cursor: pointer;
    font-family: inherit;
}
.tr-date-group input::placeholder { color: var(--muted); }
.tr-date-group::after {
    content: '📅'; font-size: 14px; opacity: 0.5; padding-right: 4px;
}
.tr-date-sep { color: var(--muted); font-size: 12px; margin: 0 2px; flex-shrink: 0; }

/* Litepicker 主题覆盖 */
:root {
    --litepicker-day-width: 32px;
    --litepicker-day-height: 32px;
    --litepicker-day-font-size: 13px;
    --litepicker-month-width: calc(var(--litepicker-day-width) * 7 + 12px);
    --litepicker-container-width: calc(var(--litepicker-month-width) * 2 + 4px + 160px);
    --litepicker-container-background-color: var(--surface);
    --litepicker-header-background-color: var(--surface);
    --litepicker-day-color: var(--text);
    --litepicker-day-color-hover: #fff;
    --litepicker-day-color-hover-background: var(--primary);
    --litepicker-is-today-color: var(--primary);
    --litepicker-is-in-range-color: #c7e0ff;
    --litepicker-is-in-range-background-color: rgba(59, 130, 246, 0.18);
    --litepicker-is-start-color: #fff;
    --litepicker-is-start-background-color: var(--primary);
    --litepicker-is-end-color: #fff;
    --litepicker-is-end-background-color: var(--primary);
    --litepicker-button-next-month-color: var(--muted);
    --litepicker-button-prev-month-color: var(--muted);
    --litepicker-button-next-month-color-hover: var(--primary);
    --litepicker-button-prev-month-color-hover: var(--primary);
    --litepicker-footer-background-color: var(--surface);
}
.litepicker[data-plugins~="ranges"] .container__main,
.litepicker[data-plugins~="ranges"] .container__months {
    background: var(--surface);
    border-color: var(--line);
}
.litepicker [data-range="customRanges"] {
    border-color: var(--line);
}
.litepicker .container__days .day-item,
.litepicker .container__months .month-item {
    font-family: inherit;
}
@media (max-width: 768px) {
    .litepicker { --litepicker-container-width: 100vw; }
}

/* 培训列表表格 */
.training-table { width: 100%; min-width: 900px; border-collapse: collapse; }
.training-table th {
    text-align: left; padding: 10px 10px; font-size: 12px; font-weight: 600;
    color: var(--muted); background: var(--surface-soft); border-bottom: 2px solid var(--line);
    white-space: nowrap;
}
.training-table td {
    padding: 10px 10px; font-size: 13px; border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.training-table tbody tr:hover { background: var(--surface-soft); }
.tr-col-store { width: 16%; }
.tr-col-product { width: 12%; }
.tr-col-method { width: 8%; }
.tr-col-status { width: 8%; }
.tr-col-form { width: 8%; }
.tr-col-date { width: 12%; }
.tr-col-settle-date { width: 12%; }
.tr-col-settle-fee { width: 8%; }
.tr-col-actions { width: 16%; }

.tr-store-link { color: var(--text); font-weight: 600; text-decoration: none; font-size: 13px; }
.tr-store-link:hover { color: var(--primary); }
.tr-settle-empty { color: var(--muted); font-size: 12px; }
.tr-settle-done { color: #1a7a1a; font-size: 12px; font-weight: 500; }
.tr-actions-cell { display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.tr-actions-cell .btn { font-size: 12px; padding: 3px 8px; }

/* badge 复用 */
.badge.badge-green { background: #e6f7e6; color: #1a7a1a; }
.badge.badge-orange { background: #fff3e0; color: #bf6d00; }
.badge.badge-gray { background: #eee; color: #666; }
.badge.badge-red { background: #fde8e8; color: #b91c1c; }
.badge.badge-blue { background: #e6f0ff; color: #1a56b0; }
.badge.badge-purple { background: #f0e6ff; color: #7c3aed; }

/* 培训弹窗 - 大气布局 */
.tr-form { padding: 20px 28px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.tr-form .form-row { margin-bottom: 16px; }
.tr-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); letter-spacing: 0.2px; }
.tr-form input, .tr-form select, .tr-form textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius);
    font-size: 14px; background: var(--surface); color: var(--text); box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.tr-form input:focus, .tr-form select:focus, .tr-form textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-weak, rgba(59, 130, 246, 0.15));
}
.tr-form textarea { resize: vertical; min-height: 72px; }
.tr-form .form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.btn.btn-outline { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn.btn-success { background: #e6f7e6; color: #1a7a1a; border-color: #c5e6c5; }

/* 搜索下拉 */
.search-select-wrap { position: relative; }
.search-select-wrap input { width: 100%; box-sizing: border-box; }
.search-select-drop {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    max-height: 180px; overflow-y: auto;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); box-shadow: 0 4px 16px rgba(0,0,0,.1);
    display: none;
}
.search-select-wrap input:focus + .search-select-drop,
.search-select-drop:hover { display: block; }
.search-select-drop .drop-item {
    padding: 6px 10px; cursor: pointer; font-size: 13px;
    display: flex; gap: 8px; align-items: baseline;
}
.search-select-drop .drop-item:hover { background: var(--primary-weak); }
.search-select-drop .drop-item span { color: var(--muted); font-size: 11px; }
.search-select-drop .drop-empty { padding: 10px; color: var(--muted); font-size: 12px; text-align: center; }

/* 培训列表统计卡片 - 紧凑横向 */
#tr-stats { grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
#tr-stats > div { padding: 10px 14px; min-height: 0; flex-direction: row; align-items: baseline; gap: 8px; }
#tr-stats strong { font-size: 18px; font-weight: 700; }
#tr-stats span { font-size: 12px; }

/* 移动端 */
@media (max-width: 768px) {
    .training-filter-row { gap: 6px; flex-wrap: wrap; }
    .tr-search-group { min-width: 0; max-width: 100%; flex: 1 1 100%; }
    #tr-filter-product { flex: 1 1 100%; max-width: 100%; }
    .tr-date-group { flex: 1 1 auto; min-width: 180px; }
    .tr-date-group input { flex: 1; min-width: 0; }
    .tr-card-body { padding: 8px 10px; flex-wrap: wrap; }
    .tr-store-link { font-size: 13px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    #tr-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .tr-form .form-row-2 { grid-template-columns: 1fr; }
    .training-filter-row { flex-direction: column; }
    .tr-date-group { width: 100%; }
    .tr-card-body { flex-wrap: wrap; }
}

/* ======================================================================
 * MOBILE RESPONSIVE — 手机端适配
 * ====================================================================== */

/* ---------- 平板 / 小屏 (≤768px) ---------- */
@media (max-width: 768px) {
  .content { padding: 8px; }
  .block { padding: 10px; margin-bottom: 10px; border-radius: 6px; }

  /* Sidebar: 紧凑水平 nav */
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line);
    padding: 10px 8px 8px;
  }
  .brand { padding: 0 4px 10px; gap: 8px; }
  .brand-mark { width: 32px; height: 32px; font-size: 11px; }
  .brand h1 { font-size: 15px; }
  .brand p { font-size: 11px; }
  .side-nav {
    display: flex;
    gap: 4px;
    margin-top: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .nav-item {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 7px 12px;
    font-size: 13px;
    border-radius: 20px;
    border: 1px solid var(--line);
  }
  .nav-item.active { border-color: var(--primary); }
  .sidebar-foot {
    display: none;
  }

  /* Stats: 2 per row */
  .stats { grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 10px; }
  .stats > div { padding: 10px; min-height: 64px; }
  .stats strong { font-size: 20px; }

  /* Block head */
  .block-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .block-head.compact { flex-direction: row; align-items: center; }

  /* Filters: stack */
  .filters { grid-template-columns: 1fr; gap: 6px; }

  /* All tables: horizontal scroll */
  .table-wrap, .mini-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Dashboard table: keep fixed layout but enable scroll */
  .dashboard-table { overflow-x: auto; }
  .dashboard-table table { min-width: 600px; }
  .dashboard-table th, .dashboard-table td { padding: 8px 6px; font-size: 12px; }
  .dashboard-table td small { font-size: 11px; margin-top: 2px; }

  /* Sync actions */
  .sync-actions {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .sync-actions .search-control { grid-column: 1 / -1; }

  /* Detail page */
  .detail-page-head { padding: 10px; }
  .detail-page-head h2 { font-size: 17px; }
  .detail-summary { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .detail-summary div { padding: 8px 10px; }
  .detail-grid { grid-template-columns: 1fr; gap: 10px; }
  .detail-info-strip { gap: 6px; }
  .info-chip { padding: 6px 10px; font-size: 12px; }
  .info-chip span { font-size: 11px; }
  .info-chip b { font-size: 12px; }
  .detail-tab { padding: 8px 14px; font-size: 13px; }

  /* Maintenance card */
  .maintenance-card { padding: 12px; }
  .maintenance-input-row { flex-direction: column; }
  .maintenance-settings-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .save-settings-btn { margin-left: 0; align-self: flex-end; }
  .timeline-item { padding-left: 18px; }
  .timeline-item.latest { padding-left: 26px; padding-right: 10px; }
  .timeline-content { font-size: 13px; }

  /* Paste import */
  .paste-grid { grid-template-columns: 1fr; gap: 10px; }
  .paste-textarea, .paste-preview { min-height: 280px; }

  /* Export buttons */
  .head-actions { width: 100%; }
  .head-actions .btn { font-size: 12px; padding: 6px 8px; }

  /* Log table */
  .log-table { min-width: 500px; }
  .log-table .log-col-detail { max-width: 180px; }
  .log-table th, .log-table td { padding: 8px 6px; font-size: 12px; }

  /* Form grids */
  .form-grid { grid-template-columns: 1fr; }
  .customer-fields { grid-template-columns: 1fr; }

  /* Sync job */
  .sync-job-grid { grid-template-columns: repeat(2, 1fr); }

  /* Customer table */
  #customer-table { min-width: 600px; }
  #customer-table th, #customer-table td { padding: 8px 6px; font-size: 11px; }

  /* Pagination */
  .pagination-bar { flex-wrap: wrap; gap: 6px; font-size: 12px; }

  /* Group cells */
  .group-cell-line { padding: 3px 0; min-height: 28px; font-size: 12px; }
  .group-alert-line { flex-wrap: wrap; gap: 4px; }
}

/* ---------- 手机 (≤480px) ---------- */
@media (max-width: 480px) {
  body { font-size: 14px; }

  .content { padding: 6px; }
  .block { padding: 8px; margin-bottom: 8px; border-radius: 4px; }

  /* Sidebar: even tighter */
  .sidebar { padding: 6px 4px 6px; }
  .brand { padding: 0 4px 6px; }
  .brand-mark { width: 26px; height: 26px; font-size: 10px; border-radius: 6px; }
  .brand h1 { font-size: 14px; }
  .nav-item { padding: 6px 10px; font-size: 12px; }

  /* Stats: 1 per row for very small screens */
  .stats { grid-template-columns: 1fr 1fr; gap: 5px; }
  .stats > div { padding: 8px; min-height: 56px; }
  .stats strong { font-size: 18px; }

  /* Dashboard table */
  .dashboard-table table { min-width: 540px; }
  .dashboard-table th, .dashboard-table td { padding: 6px 4px; font-size: 11px; }
  .dashboard-table td small { font-size: 10px; }
  .dashboard-table .badge { padding: 2px 5px; font-size: 10px; }

  /* Block headings */
  h2 { font-size: 15px; }
  h3 { font-size: 14px; }

  /* Sync actions: full stack */
  .sync-actions { grid-template-columns: 1fr; }

  /* Detail */
  .detail-page-head h2 { font-size: 16px; }
  .detail-tab { padding: 6px 10px; font-size: 12px; }
  .detail-summary { grid-template-columns: 1fr; }
  .info-chip { width: 100%; }

  /* Maintenance */
  .timeline-item { padding-left: 14px; }
  .timeline-item.latest { padding-left: 22px; }
  .timeline-dot { width: 6px; height: 6px; }
  .timeline-date { font-size: 11px; }
  .timeline-content { font-size: 13px; }

  /* Modals */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .modal-head { padding: 12px; }
  .modal-head h3 { font-size: 14px; }
  #log-modal-body { padding: 10px; font-size: 11px; }

  /* Manual modal */
  .manual-form { grid-template-columns: 1fr; gap: 8px; }

  /* Index import modal */
  .index-import-content { padding: 10px; }
  .index-import-content .paste-textarea { min-height: 180px; }

  /* Buttons */
  .btn { padding: 7px 10px; font-size: 12px; }

  /* Badge */
  .badge { padding: 2px 5px; font-size: 10px; margin-right: 3px; }

  /* Log table */
  .log-table { min-width: 420px; }

  /* Customer table */
  #customer-table { min-width: 520px; }

  /* Toast */
  #toast { right: 10px; bottom: 10px; left: 10px; font-size: 12px; text-align: center; }

  /* Sync job panel */
  .sync-job-grid { grid-template-columns: 1fr; }

  /* Dashboard head */
  .dashboard-head { flex-wrap: wrap; }
  .dashboard-head select { width: 100%; }
}
@media (max-width: 768px) {
    .sidebar, .content, .view, .block { min-width: 0; width: 100%; max-width: 100%; }
    .side-nav { width: 100%; max-width: 100%; }
    #leads-view .block-head { flex-wrap: wrap; }
    #leads-view .block-head > div:first-child { min-width: 0; }
    #leads-view .head-actions { width: 100%; justify-content: space-between; }
    .lead-detail-modal .modal-head > div { min-width: 0; }
    .lead-detail-modal .modal-head .btn { flex: 0 0 auto; }
}

/* 2026-08-13 workbench refresh: action-first dashboard with a classic fallback. */
#dashboard-view {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

#dashboard-view .workbench-page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin: 4px 2px 20px;
}

#dashboard-view .workbench-title-wrap {
    min-width: 0;
}

#dashboard-view .workbench-kicker,
#dashboard-view .workbench-section-label {
    display: block;
    margin-bottom: 6px;
    color: #667085;
    font-size: 11px;
    font-weight: 760;
    letter-spacing: .09em;
    text-transform: uppercase;
}

#dashboard-view .workbench-page-head h1 {
    color: #18181b;
    font-size: 28px;
    font-weight: 780;
    line-height: 1.2;
    letter-spacing: -.02em;
}

#dashboard-view .workbench-page-head p {
    margin-top: 7px;
    color: #667085;
    font-size: 13px;
    line-height: 1.5;
}

#dashboard-view .workbench-page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
}

#dashboard-view .workbench-page-actions .btn {
    min-height: 38px;
}

#dashboard-view .workbench-date {
    margin-right: 4px;
    color: #475467;
    font-size: 13px;
    font-weight: 680;
    white-space: nowrap;
}

#dashboard-view .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

#dashboard-view .stats > .stat-card {
    --card-accent: #166534;
    position: relative;
    min-width: 0;
    min-height: 112px;
    padding: 15px 16px 14px;
    overflow: hidden;
    appearance: none;
    border: 1px solid #e4e7ec;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
    color: #18181b;
    text-align: left;
}

#dashboard-view .stats > .stat-card::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--card-accent);
    content: "";
    opacity: 0;
    transition: opacity .15s ease;
}

#dashboard-view .stats > .tone-due { --card-accent: #b42318; }
#dashboard-view .stats > .tone-resource { --card-accent: #9a3412; }
#dashboard-view .stats > .tone-contact { --card-accent: #175cd3; }

#dashboard-view .stats > .stat-card:hover {
    border-color: #98a2b3;
    background: #fff;
    transform: translateY(-1px);
}

#dashboard-view .stats > .stat-card.active {
    border-color: var(--card-accent);
    background: #fff;
    box-shadow: 0 0 0 1px var(--card-accent), 0 2px 5px rgba(16, 24, 40, .08);
}

#dashboard-view .stats > .stat-card.active::after {
    opacity: 1;
}

#dashboard-view .stat-card-top,
#dashboard-view .stat-card-value {
    display: flex;
    align-items: center;
}

#dashboard-view .stat-card-top {
    gap: 9px;
}

#dashboard-view .stat-icon {
    display: grid;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    place-items: center;
    border-radius: 8px;
    background: #f2f4f7;
    color: var(--card-accent);
    font-size: 12px;
    font-weight: 800;
}

#dashboard-view .stat-label {
    color: #475467;
    font-size: 13px;
    font-weight: 680;
}

#dashboard-view .stat-card-value {
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
}

#dashboard-view .stats .stat-card-value strong {
    color: #18181b;
    font-size: 29px;
    font-weight: 780;
    line-height: 1;
}

#dashboard-view .stat-card-value small {
    overflow: hidden;
    color: #667085;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#dashboard-view .workbench-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 304px;
    align-items: start;
    gap: 16px;
}

#dashboard-view .workbench-focus-panel {
    min-width: 0;
    margin-bottom: 0;
    padding: 18px;
    border-radius: 10px;
}

#dashboard-view .workbench-queue-head {
    align-items: flex-end;
    margin-bottom: 16px;
}

#dashboard-view .workbench-queue-head h2,
#dashboard-view .workbench-rail-head h2 {
    color: #18181b;
    font-size: 17px;
    line-height: 1.35;
}

#dashboard-view .workbench-queue-head p {
    margin-top: 5px;
    color: #667085;
    font-size: 12px;
}

#dashboard-view .workbench-controls {
    gap: 8px;
}

#dashboard-view .workbench-select-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#dashboard-view .dashboard-head select {
    min-width: 142px;
    min-height: 36px;
    border-color: #b7c0cc;
    background: #fff;
}

#dashboard-view .workbench-view-switch {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #f7f8fa;
}

#dashboard-view .workbench-view-btn {
    min-height: 30px;
    padding: 5px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #667085;
    cursor: pointer;
    font-size: 12px;
    font-weight: 680;
}

#dashboard-view .workbench-view-btn:hover {
    color: #18181b;
}

#dashboard-view .workbench-view-btn.active {
    background: #fff;
    color: #18181b;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .10);
}

#dashboard-view .workbench-task-list {
    display: grid;
    gap: 10px;
}

#dashboard-view .workbench-customer-card {
    overflow: hidden;
    border: 1px solid #e4e7ec;
    border-left: 3px solid #98a2b3;
    border-radius: 10px;
    background: #fff;
}

#dashboard-view .workbench-customer-card.alert { border-left-color: #b42318; }
#dashboard-view .workbench-customer-card.warn { border-left-color: #9a3412; }

#dashboard-view .workbench-customer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 14px;
    border-bottom: 1px solid #eaecf0;
    background: #fcfcfd;
}

#dashboard-view .workbench-customer-copy {
    min-width: 0;
}

#dashboard-view .workbench-customer-link {
    display: block;
    max-width: 100%;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: transparent;
    color: #18181b;
    cursor: pointer;
    font-size: 14px;
    font-weight: 750;
    line-height: 1.4;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#dashboard-view .workbench-customer-link:hover {
    color: #166534;
    text-decoration: underline;
    text-underline-offset: 3px;
}

#dashboard-view .workbench-customer-copy small {
    display: block;
    margin-top: 3px;
    overflow: hidden;
    color: #667085;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#dashboard-view .workbench-customer-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

#dashboard-view .workbench-customer-meta > span {
    color: #667085;
    font-size: 12px;
    white-space: nowrap;
}

#dashboard-view .workbench-task-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 138px max-content;
    align-items: center;
    gap: 16px;
    min-height: 68px;
    padding: 12px 14px;
    border-bottom: 1px solid #eaecf0;
}

#dashboard-view .workbench-task-row:last-child {
    border-bottom: 0;
}

#dashboard-view .workbench-task-copy {
    min-width: 0;
}

#dashboard-view .workbench-task-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 7px;
}

#dashboard-view .workbench-task-kind {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #f2f4f7;
    color: #475467;
    font-size: 11px;
    font-weight: 720;
}

#dashboard-view .workbench-task-kind.kind-due {
    background: #fef3f2;
    color: #b42318;
}

#dashboard-view .workbench-task-kind.kind-resource {
    background: #fff7ed;
    color: #9a3412;
}

#dashboard-view .workbench-task-kind.kind-contact {
    background: #eff6ff;
    color: #175cd3;
}

#dashboard-view .workbench-task-copy > strong {
    display: block;
    color: #344054;
    font-size: 13px;
    font-weight: 640;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

#dashboard-view .workbench-task-date {
    color: #667085;
    font-size: 12px;
    line-height: 1.5;
}

#dashboard-view .workbench-task-date time {
    display: block;
}

#dashboard-view .workbench-task-action .mini-action {
    min-width: 68px;
    min-height: 36px;
    padding: 7px 11px;
    font-weight: 680;
}

#dashboard-view .workbench-empty {
    display: grid;
    justify-items: center;
    min-height: 300px;
    padding: 54px 20px;
    place-content: center;
    border: 1px dashed #d0d5dd;
    border-radius: 10px;
    background: #fcfcfd;
    text-align: center;
}

#dashboard-view .workbench-empty > span {
    display: grid;
    width: 42px;
    height: 42px;
    margin-bottom: 13px;
    place-items: center;
    border-radius: 50%;
    background: #ecfdf3;
    color: #067647;
    font-size: 20px;
    font-weight: 800;
}

#dashboard-view .workbench-empty h3 {
    margin: 0;
    color: #18181b;
    font-size: 15px;
}

#dashboard-view .workbench-empty p {
    max-width: 360px;
    margin-top: 6px;
    color: #667085;
    font-size: 13px;
    line-height: 1.5;
}

#dashboard-view .workbench-empty > div {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

#dashboard-view .workbench-pagination {
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px solid #eaecf0;
}

#dashboard-view .workbench-rail {
    position: sticky;
    top: 18px;
    display: grid;
    gap: 12px;
}

#dashboard-view .workbench-rail .block {
    margin-bottom: 0;
    border-radius: 10px;
}

#dashboard-view .workbench-rail-head {
    margin-bottom: 14px;
}

#dashboard-view .workbench-quick-list {
    display: grid;
    gap: 4px;
}

#dashboard-view .workbench-quick-list > button {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 54px;
    padding: 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #344054;
    cursor: pointer;
    text-align: left;
}

#dashboard-view .workbench-quick-list > button:hover {
    background: #f7f8fa;
}

#dashboard-view .quick-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #fff;
    color: #166534;
    font-size: 12px;
    font-weight: 780;
}

#dashboard-view .workbench-quick-list strong,
#dashboard-view .workbench-quick-list small {
    display: block;
}

#dashboard-view .workbench-quick-list strong {
    color: #344054;
    font-size: 13px;
    font-weight: 690;
}

#dashboard-view .workbench-quick-list small {
    margin-top: 2px;
    color: #667085;
    font-size: 11px;
}

#dashboard-view .workbench-quick-list b {
    color: #98a2b3;
    font-size: 18px;
    font-weight: 500;
}

#dashboard-view .workbench-brief {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

#dashboard-view .workbench-brief > div {
    min-width: 0;
    padding: 11px;
    border: 1px solid #eaecf0;
    border-radius: 8px;
    background: #fcfcfd;
}

#dashboard-view .workbench-brief span,
#dashboard-view .workbench-brief strong {
    display: block;
}

#dashboard-view .workbench-brief span {
    overflow: hidden;
    color: #667085;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#dashboard-view .workbench-brief strong {
    margin-top: 8px;
    color: #18181b;
    font-size: 21px;
    font-weight: 760;
}

#dashboard-view .workbench-scope-note {
    padding: 14px 16px;
    border-color: #d1fadf;
    background: #f6fef9;
}

#dashboard-view .workbench-scope-note strong {
    color: #166534;
    font-size: 12px;
}

#dashboard-view .workbench-scope-note p {
    margin-top: 5px;
    color: #475467;
    font-size: 11px;
    line-height: 1.55;
}

#dashboard-view .col-sort-btn,
#dashboard-view .col-filter-btn {
    min-width: 24px;
    min-height: 24px;
    border: 0;
    background: transparent;
    line-height: 1;
}

#dashboard-view :where(button, select, [tabindex="0"]):focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

@media (max-width: 1260px) {
    #dashboard-view .workbench-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    #dashboard-view .workbench-rail {
        position: static;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #dashboard-view .workbench-scope-note {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    #dashboard-view .workbench-page-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 14px;
    }

    #dashboard-view .workbench-page-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    #dashboard-view .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #dashboard-view .workbench-queue-head {
        align-items: flex-start;
        flex-direction: column;
    }

    #dashboard-view .workbench-controls {
        width: 100%;
        justify-content: space-between;
    }

    #dashboard-view .workbench-rail {
        grid-template-columns: minmax(0, 1fr);
    }

    #dashboard-view .workbench-scope-note {
        grid-column: auto;
    }
}

@media (max-width: 640px) {
    #dashboard-view .workbench-page-head {
        margin-bottom: 14px;
    }

    #dashboard-view .workbench-page-head h1 {
        font-size: 22px;
    }

    #dashboard-view .workbench-date {
        width: 100%;
        margin: 0 0 2px;
    }

    #dashboard-view .workbench-page-actions .btn {
        flex: 1;
        min-height: 44px;
    }

    #dashboard-view .stats {
        gap: 8px;
    }

    #dashboard-view .stats > .stat-card {
        min-height: 98px;
        padding: 12px;
    }

    #dashboard-view .stats .stat-card-value strong {
        font-size: 24px;
    }

    #dashboard-view .stat-card-value small {
        display: none;
    }

    #dashboard-view .workbench-focus-panel {
        padding: 12px;
    }

    #dashboard-view .workbench-controls {
        align-items: stretch;
        flex-direction: column;
    }

    #dashboard-view .dashboard-head select,
    #dashboard-view .workbench-view-switch {
        width: 100%;
    }

    #dashboard-view .workbench-view-btn {
        flex: 1;
        min-height: 40px;
    }

    #dashboard-view .workbench-customer-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 9px;
        padding: 12px;
    }

    #dashboard-view .workbench-customer-copy,
    #dashboard-view .workbench-customer-link {
        width: 100%;
    }

    #dashboard-view .workbench-customer-meta {
        width: 100%;
        justify-content: space-between;
    }

    #dashboard-view .workbench-task-row {
        grid-template-columns: minmax(0, 1fr);
        gap: 10px;
        padding: 12px;
    }

    #dashboard-view .workbench-task-date br {
        display: none;
    }

    #dashboard-view .workbench-task-date br::after {
        content: " · ";
    }

    #dashboard-view .workbench-task-action,
    #dashboard-view .workbench-task-action .btn {
        width: 100%;
    }

    #dashboard-view .workbench-task-action .btn {
        min-height: 44px;
    }

    #dashboard-view .workbench-pagination {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    #dashboard-view .workbench-pagination > span {
        width: 100%;
    }

    #dashboard-view .workbench-empty > div {
        align-items: stretch;
        flex-direction: column;
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    #dashboard-view *,
    #dashboard-view *::before,
    #dashboard-view *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
