:root {
    --navy: #17457a;
    --navy-deep: #10335c;
    --ink: #1a2330;
    --muted: #6b7686;
    --line: #e3e8ef;
    --bg: #f4f6f8;
    --card: #ffffff;
    --ok: #167c4a;
    --warn: #b4541a;
    --danger: #b3261e;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.55;
}

a {
    color: var(--navy);
    text-decoration: none;
}

button {
    font-family: inherit;
}

/* 顶部加载条 */
.loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    z-index: 90;
}

.loading-bar.loading-active {
    background: linear-gradient(90deg, transparent, var(--navy), transparent);
    background-size: 40% 100%;
    animation: bar 1.1s linear infinite;
}

@keyframes bar {
    from {
        background-position: -40% 0;
    }
    to {
        background-position: 140% 0;
    }
}

/* 布局 */
.shell {
    display: grid;
    grid-template-columns: 216px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--card);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 22px 14px 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px 22px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: var(--navy);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 13px;
    letter-spacing: 1px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.brand-text strong {
    font-size: 15px;
}

.brand-text span {
    color: var(--muted);
    font-size: 12px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    padding: 9px 12px;
    border-radius: 8px;
    color: #38455a;
    font-size: 14px;
}

.nav-item:hover {
    background: #eef2f8;
}

.nav-item.active {
    background: var(--navy);
    color: #fff;
}

.sidebar-foot {
    border-top: 1px solid var(--line);
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.who {
    display: flex;
    flex-direction: column;
    line-height: 1.4;
    padding: 0 6px;
}

.who span {
    font-weight: 600;
}

.who em {
    font-style: normal;
    color: var(--muted);
    font-size: 12px;
}

.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 58px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.topbar h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.topbar-right .hint {
    color: var(--muted);
    font-size: 13px;
}

.view {
    padding: 20px 24px 40px;
}

/* 通用控件 */
.btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    background: #eef2f8;
    color: var(--ink);
    transition: background 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
    opacity: 0.92;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--navy);
    color: #fff;
}

.btn-ghost {
    background: #fff;
    border-color: var(--line);
}

.btn-danger {
    background: #fdeceb;
    color: var(--danger);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--navy);
    padding: 0;
    font-size: 13px;
    cursor: pointer;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="url"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(23, 69, 122, 0.08);
}

textarea {
    min-height: 78px;
    resize: vertical;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 12px;
    color: var(--muted);
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
}

.card + .card {
    margin-top: 16px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 18px;
}

/* 统计卡 */
.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.stat-label {
    color: var(--muted);
    font-size: 12px;
}

.stat-value {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-top: 4px;
}

.stat-value.alarm {
    color: var(--danger);
}

.stat-sub {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 22px 0 12px;
}

.section-head h2 {
    font-size: 14px;
    margin: 0;
    font-weight: 600;
}

/* 表格 */
.table-wrap {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

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

th,
td {
    text-align: left;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    vertical-align: middle;
}

th {
    background: #f8fafc;
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #fafcff;
}

td.mono,
.mono {
    font-variant-numeric: tabular-nums;
    color: #4a5668;
}

.cell-title {
    font-weight: 500;
}

.cell-sub {
    color: var(--muted);
    font-size: 12px;
}

.row-overdue td {
    background: #fff6f5;
}

/* 标签 */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.6;
    white-space: nowrap;
    background: #eef2f8;
    color: #4a5668;
}

.tag-published,
.tag-dealt {
    background: #e7f5ec;
    color: var(--ok);
}

.tag-pending {
    background: #fdf2e4;
    color: var(--warn);
}

.tag-booked,
.tag-processing {
    background: #e8f0fb;
    color: var(--navy);
}

.tag-visited {
    background: #e6f4f4;
    color: #14706e;
}

.tag-offline,
.tag-draft,
.tag-invalid {
    background: #f0f1f3;
    color: #77828f;
}

/* 工具栏 */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.toolbar .field {
    min-width: 150px;
}

.toolbar .spacer {
    flex: 1;
}

.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.tab {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    color: #455061;
}

.tab.active {
    background: var(--navy);
    border-color: var(--navy);
    color: #fff;
}

/* 分页 */
.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 14px;
    color: var(--muted);
    font-size: 12px;
}

/* 空态 */
.empty {
    padding: 48px 0;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* 登录 */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 20% 20%, #e8eef8, var(--bg) 60%);
    padding: 24px;
}

.login-card {
    width: 380px;
    max-width: 100%;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 28px 26px 24px;
    box-shadow: 0 18px 50px rgba(20, 40, 70, 0.08);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.login-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px;
}

.login-sub {
    color: var(--muted);
    font-size: 12px;
    margin: 0 0 20px;
}

.login-card .field + .field {
    margin-top: 12px;
}

.code-row {
    display: flex;
    gap: 8px;
}

.code-row input {
    flex: 1;
}

.login-actions {
    margin-top: 18px;
}

.login-actions .btn {
    width: 100%;
    padding: 10px;
    font-size: 14px;
}

.login-error {
    margin-top: 12px;
    color: var(--danger);
    font-size: 12px;
    min-height: 16px;
}

.login-foot {
    margin-top: 16px;
    color: #98a2b0;
    font-size: 12px;
    text-align: center;
}

/* 详情页 */
.detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.detail-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.detail-meta {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px 18px;
}

.info-item label {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.info-item div {
    font-size: 13px;
}

.info-full {
    grid-column: 1 / -1;
}

.timeline {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tl-item {
    display: grid;
    grid-template-columns: 14px 1fr;
    gap: 12px;
}

.tl-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--navy);
    margin-top: 6px;
}

.tl-body {
    border-bottom: 1px dashed var(--line);
    padding-bottom: 12px;
}

.tl-head {
    display: flex;
    gap: 10px;
    align-items: baseline;
    color: var(--muted);
    font-size: 12px;
}

.tl-content {
    margin-top: 4px;
}

/* 图片 */
.thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.thumb {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
}

.thumb img {
    width: 100%;
    height: 96px;
    object-fit: cover;
    display: block;
}

.thumb-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    font-size: 12px;
    color: var(--muted);
}

.cover-flag {
    color: var(--navy);
    font-weight: 600;
}

/* 弹窗 */
.modal-wrap {
    position: fixed;
    inset: 0;
    background: rgba(16, 26, 40, 0.42);
    display: grid;
    place-items: center;
    z-index: 80;
    padding: 20px;
}

.modal {
    width: 380px;
    max-width: 100%;
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 24px 60px rgba(16, 32, 56, 0.22);
}

.modal-wide {
    width: 460px;
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
}

.modal-body {
    color: #46536a;
    font-size: 13px;
    white-space: pre-wrap;
}

.modal-body-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

/* 提示条 */
.toast {
    position: fixed;
    left: 50%;
    bottom: 36px;
    transform: translate(-50%, 12px);
    background: #24303f;
    color: #fff;
    padding: 9px 18px;
    border-radius: 999px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 95;
}

.toast-show {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast-error {
    background: #8f2b25;
}

/* 来源分布 */
.bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: grid;
    grid-template-columns: 74px 1fr 40px;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--muted);
}

.bar-track {
    height: 8px;
    border-radius: 999px;
    background: #eef2f8;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--navy);
}

.quick-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.quick-link {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    background: #fff;
    font-size: 13px;
    color: var(--ink);
    display: flex;
    gap: 8px;
    align-items: center;
}

.quick-link b {
    color: var(--navy);
}

.muted {
    color: var(--muted);
}

.right {
    text-align: right;
}

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

@media (max-width: 760px) {
    .shell {
        grid-template-columns: 1fr;
    }
    .sidebar {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        border-right: none;
        border-bottom: 1px solid var(--line);
        padding: 12px 14px;
    }
    .brand {
        padding: 0;
    }
    .brand-text,
    .sidebar-foot .who {
        display: none;
    }
    .nav {
        flex-direction: row;
    }
    .sidebar-foot {
        border: none;
        padding: 0;
        margin-left: auto;
    }
    .grid-2,
    .grid-3,
    .info-grid,
    .stats {
        grid-template-columns: 1fr;
    }
}

/* 客户与员工管理 */

.row-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    white-space: nowrap;
}

.code-chip {
    display: inline-block;
    padding: 3px 8px;
    border: 1px dashed var(--line);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    letter-spacing: 0.4px;
    cursor: pointer;
    color: var(--ink);
    background: var(--bg);
}

.code-chip:hover {
    border-color: var(--navy);
    color: var(--navy);
}

.role-select {
    width: 122px;
    padding: 5px 8px;
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}

tr.row-off td {
    opacity: 0.55;
}

.card-title .copy-inline {
    float: right;
    margin-left: 8px;
}

.btn-link.danger {
    color: var(--danger);
}

.btn-link.danger:hover {
    text-decoration: underline;
}
