:root {
    --primary: #4f7cff;
    --primary-dark: #3a67e6;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --sidebar-bg: #2c3e50;
    --sidebar-text: #ecf0f1;
    --sidebar-active: #4f7cff;
    --header-bg: #ffffff;
    --body-bg: #f4f6f9;
    --card-bg: #ffffff;
    --border: #e4e7ed;
    --text-primary: #303133;
    --text-secondary: #606266;
    --text-muted: #909399;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--body-bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: #fff;
    color: var(--text-primary);
    z-index: 100;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.topbar-inner {
    display: flex;
    align-items: center;
    height: 50px;
    padding: 0 16px;
    gap: 16px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: #1677ff;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.brand-logo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1677ff, #4096ff);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.topnav {
    flex: 1;
    min-width: 0;
    align-self: stretch;
    display: flex;
    align-items: stretch;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 4px;
    align-items: stretch;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: stretch;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0 18px;
    color: #262626;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
    user-select: none;
}

.nav-link:hover {
    color: #1677ff;
    text-decoration: none;
}

.nav-link.active {
    color: #1677ff;
    border-bottom-color: #1677ff;
    font-weight: 500;
}

.dropdown {
    list-style: none;
    padding: 6px;
    margin: 0;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 172px;
    background: #fff;
    color: var(--text-primary);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12), 0 2px 4px rgba(0, 0, 0, 0.06);
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    display: none;
    z-index: 200;
}

.nav-item.has-dropdown:hover .dropdown,
.nav-item.has-dropdown.open .dropdown {
    display: block;
}

.dropdown li a {
    display: block;
    padding: 9px 12px;
    font-size: 14px;
    color: #262626;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}

.dropdown li a:hover {
    background: #f5f7fa;
    color: #1677ff;
    text-decoration: none;
}

.dropdown li a.active {
    color: #1677ff;
    background: #e6f0ff;
    font-weight: 500;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #262626;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 13px;
}

.nav-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #262626;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
}

.tab-strip {
    background: #f5f6f8;
    border-bottom: 1px solid var(--border);
    padding: 6px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    z-index: 50;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
}

.page-tab {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 16px;
    font-size: 13px;
    border-radius: 4px;
    background: #fff;
    color: #595959;
    border: 1px solid var(--border);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s;
}

.page-tab:hover {
    color: #1677ff;
    text-decoration: none;
}

.page-tab.active {
    background: #1677ff;
    border-color: #1677ff;
    color: #fff;
    font-weight: 500;
}

.content {
    padding: 20px;
    flex: 1;
}

.tab-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--body-bg);
}

.tab-content iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--body-bg);
}

.tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    border-radius: 50%;
    font-size: 10px;
    line-height: 1;
    opacity: 0.7;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.tab-close:hover {
    background: rgba(0, 0, 0, 0.15);
    opacity: 1;
}

.page-tab.active .tab-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid transparent;
    font-size: 14px;
    cursor: pointer;
    background: #fff;
    color: var(--text-primary);
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.5;
}

.btn:hover {
    text-decoration: none;
    opacity: 0.9;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-warning {
    background: var(--warning);
    color: #333;
    border-color: var(--warning);
}

.btn-default {
    background: #fff;
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-default:hover {
    background: #f5f7fa;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn-xs {
    padding: 2px 6px;
    font-size: 12px;
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-group {
    display: inline-flex;
    gap: 4px;
}

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.table th,
table.table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

table.table th {
    background: #fafbfc;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

table.table tr:hover td {
    background: #f9fafc;
}

table.table .num {
    text-align: right;
    font-family: Consolas, monospace;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control,
select.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #fff;
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 124, 255, 0.15);
}

textarea.form-control {
    resize: vertical;
}

.form-inline {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.form-inline .form-group {
    margin-bottom: 0;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

/* 客户 / 联系人 / 联系电话 / 地址 同一行：客户与地址列稍宽 */
.form-row-4contact {
    grid-template-columns: minmax(220px, 1.6fr) minmax(150px, 1fr) minmax(140px, 1fr) minmax(220px, 1.6fr);
}

@media (max-width: 1100px) {
    .form-row-4contact {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

.form-check {
    display: flex;
    align-items: center;
    gap: 6px;
}

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.alert-warning {
    background: #fff3cd;
    border-color: #ffeeba;
    color: #856404;
}

.alert-info {
    background: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-primary {
    background: #cfe2ff;
    color: #084298;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    position: relative;
    overflow: hidden;
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 36px;
    opacity: 0.15;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.show {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h5 {
    margin: 0;
    font-size: 16px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    margin: 0;
    font-size: 20px;
}

.search-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .nav-toggle {
        display: inline-block;
    }

    .topnav {
        display: none;
        position: absolute;
        top: 50px;
        left: 0;
        right: 0;
        background: #fff;
        max-height: 70vh;
        overflow-y: auto;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
        border-top: 1px solid var(--border);
    }

    .topnav.show {
        display: block;
    }

    .nav-menu {
        flex-direction: column;
        gap: 0;
    }

    .nav-item {
        width: 100%;
        display: block;
    }

    .nav-link {
        padding: 12px 20px;
        border-bottom: 1px solid transparent;
    }

    .nav-link.active {
        border-bottom-color: transparent;
        background: #e6f0ff;
    }

    .dropdown {
        position: static;
        display: block;
        box-shadow: none;
        border: none;
        background: #fafbfc;
        padding: 0;
        border-radius: 0;
        min-width: 0;
    }

    .dropdown li a {
        color: #262626;
        padding-left: 36px;
        border-radius: 0;
    }

    .dropdown li a:hover,
    .dropdown li a.active {
        background: #e6f0ff;
        color: #1677ff;
    }

    .topbar-right {
        gap: 6px;
    }

    .user-info span.nowrap {
        display: none;
    }

    .content {
        padding: 12px;
    }

    .card {
        padding: 14px;
    }

    table.table {
        font-size: 13px;
    }

    table.table th,
    table.table td {
        padding: 8px 6px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .page-header .btn {
        text-align: center;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .tab-strip {
        padding: 6px 12px;
    }
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f7cff 0%, #6a11cb 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.login-card h2 {
    text-align: center;
    margin: 0 0 8px;
    font-size: 22px;
}

.login-card .login-sub {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 13px;
}

.detail-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
    gap: 12px;
}

.detail-row .label {
    color: var(--text-muted);
    min-width: 90px;
}

.detail-row .value {
    color: var(--text-primary);
    flex: 1;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.d-none {
    display: none !important;
}

.text-muted {
    color: var(--text-muted);
}

.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

.nowrap {
    white-space: nowrap;
}
