/* ============================
   专业商务风格 - 前端H5
   配色：深蓝 +  slate + 白
   ============================ */
:root {
    --primary: #1e40af;
    --primary-light: #3b82f6;
    --primary-dark: #1e3a8a;
    --info: #0ea5e9;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --bg-page: #f1f5f9;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-xl: 0 12px 32px rgba(0,0,0,0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', 'Noto Sans SC', sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg-page);
    position: relative;
    padding-bottom: 72px;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================
   头部
   ============================ */
.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 0 0 24px;
    position: relative;
    overflow: hidden;
}

.app-header .header-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 80% 20%, rgba(255,255,255,0.08) 0%, transparent 50%),
        radial-gradient(circle at 20% 80%, rgba(255,255,255,0.05) 0%, transparent 40%);
}

.app-header.contract {
    background: linear-gradient(135deg, #0f766e 0%, #115e59 100%);
}

.header-body {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 36px 24px 16px;
}

.header-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    border: 1px solid rgba(255,255,255,0.2);
}

.header-icon i {
    font-size: 26px;
    color: #fff;
}

.app-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.app-header p {
    font-size: 13px;
    color: rgba(255,255,255,0.8);
}

/* ============================
   表单卡片
   ============================ */
.form-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    margin: -12px 12px 16px;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 2;
}

.form-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.form-title i {
    font-size: 18px;
    color: var(--primary);
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 12px;
    font-size: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    height: 44px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px 0 36px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--slate-50);
    transition: all 0.2s;
    -webkit-appearance: none;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    outline: none;
    border-color: var(--primary-light);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-group.half {
    flex: 1;
}

/* ============================
   按钮
   ============================ */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 46px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(30, 64, 175, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-primary i {
    font-size: 16px;
}

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 46px;
    flex: 1;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--slate-300);
    background: var(--slate-50);
}

.btn-secondary i {
    font-size: 16px;
}

/* ============================
   服务卡片
   ============================ */
.services-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    margin: 0 12px 16px;
    box-shadow: var(--shadow-sm);
}

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

.service-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.service-item:hover {
    background: var(--slate-50);
    border-color: var(--border);
}

.service-item:active {
    transform: scale(0.96);
}

.service-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.service-icon i {
    font-size: 20px;
    color: #fff;
}

.service-icon.bg-blue {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.service-icon.bg-green {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.service-icon.bg-orange {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.service-item span {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================
   标签栏
   ============================ */
.tab-bar {
    display: flex;
    gap: 8px;
    padding: 0 12px;
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
    display: none;
}

.tab-item {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    white-space: nowrap;
}

.tab-item i {
    font-size: 15px;
}

.tab-item.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(30, 64, 175, 0.25);
}

.tab-item:hover:not(.active) {
    border-color: var(--primary-light);
    color: var(--primary);
}

/* ============================
   合同文档
   ============================ */
.document-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    margin: 0 12px 16px;
    box-shadow: var(--shadow-sm);
    max-height: 320px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.document-card::-webkit-scrollbar {
    width: 4px;
}

.document-card::-webkit-scrollbar-thumb {
    background: var(--slate-300);
    border-radius: 2px;
}

.document-card h3 {
    text-align: center;
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.document-card p {
    margin-bottom: 10px;
    text-indent: 2em;
}

.document-card strong {
    color: var(--text-primary);
}

/* ============================
   签名区域
   ============================ */
.signature-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    margin: 0 12px 16px;
    box-shadow: var(--shadow-sm);
}

.signature-area {
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    background: var(--slate-50);
    margin-bottom: 14px;
}

#signatureCanvas {
    display: block;
    margin: 0 auto;
    background: #fff;
    border-radius: var(--radius-sm);
    cursor: crosshair;
    touch-action: none;
}

.signature-tip {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.signature-tip i {
    font-size: 14px;
}

.signature-actions {
    display: flex;
    gap: 10px;
}

/* ============================
   底部导航
   ============================ */
.app-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    display: flex;
    background: rgba(255,255,255,0.96);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    padding: 6px 0 8px;
    z-index: 100;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 0;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-item i {
    font-size: 20px;
    color: var(--text-muted);
    transition: all 0.2s;
}

.nav-item span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-item.active i {
    color: var(--primary);
}

.nav-item.active span {
    color: var(--primary);
    font-weight: 600;
}

/* ============================
   弹窗
   ============================ */
.modal-mask {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal-mask.show {
    display: flex;
}

.modal-card {
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 24px 20px;
    width: 88%;
    max-width: 360px;
    animation: modalIn 0.3s ease;
    box-shadow: var(--shadow-xl);
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.modal-title i {
    font-size: 20px;
    color: var(--primary);
}

.modal-title span {
    flex: 1;
}

.modal-close {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--slate-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
}

.modal-close:hover {
    background: var(--slate-200);
    color: var(--text-primary);
}

.modal-close i {
    font-size: 16px;
}

/* ============================
   Toast
   ============================ */
.toast-msg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    z-index: 999;
    display: none;
    max-width: 80%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transition: all 0.2s;
}

.toast-msg.show {
    display: block;
    transform: translate(-50%, -50%) scale(1);
}

/* ============================
   加载状态
   ============================ */
.loading-state {
    text-align: center;
    color: var(--text-muted);
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================
   管理后台样式
   ============================ */
.admin-body {
    background: var(--slate-100);
    min-height: 100vh;
}

.admin-container {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 220px;
    background: var(--slate-800);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.admin-logo {
    padding: 20px;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.admin-menu {
    list-style: none;
    padding: 12px 10px;
}

.admin-menu li {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-menu li:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.admin-menu li.active {
    background: var(--primary);
    color: #fff;
}

.admin-main {
    flex: 1;
    margin-left: 220px;
    padding: 20px;
}

.admin-header {
    background: #fff;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.admin-header h2 {
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 600;
}

.admin-user {
    font-size: 13px;
    color: var(--text-muted);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.data-card {
    background: #fff;
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.data-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: var(--text-primary);
    font-weight: 600;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.search-bar input {
    flex: 1;
    height: 38px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    font-size: 13px;
    transition: all 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-bar .btn {
    height: 38px;
    line-height: 38px;
    padding: 0 16px;
    font-size: 13px;
}

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

table th,
table td {
    padding: 12px 10px;
    text-align: left;
    font-size: 13px;
}

table th {
    background: var(--slate-50);
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
}

table td {
    color: var(--text-muted);
    border-bottom: 1px solid var(--slate-100);
}

table tr:hover td {
    background: var(--slate-50);
}

.status-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.status-tag.pending {
    background: #fef3c7;
    color: #d97706;
}

.status-tag.done {
    background: #d1fae5;
    color: #059669;
}

.status-tag.active {
    background: #dbeafe;
    color: #2563eb;
}

.status-tag.disabled {
    background: #fee2e2;
    color: #dc2626;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.login-box {
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 40px;
    width: 380px;
    box-shadow: var(--shadow-xl);
}

.login-box h2 {
    text-align: center;
    margin-bottom: 28px;
    color: var(--text-primary);
    font-size: 22px;
    font-weight: 700;
}

.login-box .form-group input {
    height: 46px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
    font-size: 14px;
}

.login-box .form-group input:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}

.pagination button {
    padding: 6px 12px;
    border: 1.5px solid var(--border);
    background: #fff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--primary-light);
    color: var(--primary);
}

.pagination button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

.link-card {
    background: var(--slate-50);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 14px;
}

.link-card .link-url {
    font-size: 12px;
    color: var(--primary);
    word-break: break-all;
    margin-top: 8px;
    padding: 8px;
    background: #fff;
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
}

@media (max-width: 768px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .admin-sidebar {
        width: 60px;
    }
    
    .admin-logo {
        font-size: 12px;
        padding: 16px 6px;
    }
    
    .admin-menu li {
        padding: 12px 10px;
        font-size: 12px;
        text-align: center;
        justify-content: center;
    }
    
    .admin-menu li span:last-child {
        display: none;
    }
    
    .admin-main {
        margin-left: 60px;
        padding: 14px;
    }
}
