:root {
    --primary: #1677ff;
    --primary-dark: #0958d9;
    --success: #52c41a;
    --warning: #faad14;
    --danger: #ff4d4f;
    --text: #1f1f1f;
    --text-secondary: #666;
    --border: #e8e8e8;
    --bg: #f5f7fa;
    --card-bg: #fff;
    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
}

.header {
    text-align: center;
    padding: 24px 0 16px;
}

.header h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 6px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text);
}

.required {
    color: var(--danger);
}

input[type="text"],
input[type="tel"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

select {
    min-height: 48px;
    line-height: 1.4;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

select option {
    color: #1f1f1f;
    background: #fff;
}

.sales-person-custom {
    margin-top: 10px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.radio-item {
    flex: 1;
    min-width: 100px;
}

.radio-item input {
    display: none;
}

.radio-item label {
    display: block;
    padding: 10px 12px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.radio-item input:checked + label {
    border-color: var(--primary);
    background: #e6f4ff;
    color: var(--primary);
    font-weight: 500;
}

.category-tabs {
    display: flex;
    gap: 10px;
}

.category-tab {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 10px;
    background: #fff;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.category-tab.active {
    border-color: var(--primary);
    background: #e6f4ff;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 0 0 1px var(--primary);
}

.upload-area {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    position: relative;
}

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-hint {
    color: var(--text-secondary);
    font-size: 14px;
}

.preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.preview-item {
    width: 72px;
    height: 72px;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-item .remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    line-height: 20px;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: #91caff;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f0f0f0;
    color: var(--text);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.query-link {
    text-align: center;
    margin-top: 16px;
}

.query-link a {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}

.success-panel {
    text-align: center;
    padding: 40px 20px;
}

.success-icon {
    width: 64px;
    height: 64px;
    background: var(--success);
    color: #fff;
    border-radius: 50%;
    font-size: 32px;
    line-height: 64px;
    margin: 0 auto 16px;
}

.success-panel h2 {
    margin-bottom: 12px;
}

.success-panel .hint {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 8px 0 24px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.result-row:last-child {
    border-bottom: none;
}

.result-row .label {
    color: var(--text-secondary);
}

.status-badge {
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 13px;
}

.status-pending { background: #fff7e6; color: #d46b08; }
.status-processing { background: #e6f4ff; color: #1677ff; }
.status-completed { background: #f6ffed; color: #389e0d; }
.status-cancelled { background: #fff1f0; color: #cf1322; }

.error-msg {
    background: #fff2f0;
    color: var(--danger);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 16px;
}

/* Admin styles */
.admin-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-header h1 {
    font-size: 24px;
}

.admin-nav {
    display: flex;
    gap: 8px;
}

.admin-nav a, .admin-nav button {
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 14px;
}

.admin-nav a.active, .admin-nav a:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.stat-card .number {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .label {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.chart-section {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.chart-section h3 {
    margin-bottom: 16px;
    font-size: 16px;
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bar-label {
    width: 100px;
    font-size: 13px;
    text-align: right;
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    height: 24px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    min-width: 2px;
    transition: width 0.3s;
}

.bar-value {
    width: 40px;
    font-size: 13px;
    text-align: right;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
}

.filter-bar input, .filter-bar select {
    width: auto;
    min-width: 120px;
    padding: 8px 12px;
    font-size: 14px;
}

.table-wrap {
    overflow-x: auto;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #fafafa;
    font-weight: 600;
    white-space: nowrap;
}

tr:hover td {
    background: #fafafa;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.pagination button {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.login-box {
    max-width: 400px;
    margin: 80px auto;
    background: #fff;
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.login-box h1 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 22px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 {
    margin-bottom: 16px;
    font-size: 18px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.detail-grid {
    display: grid;
    gap: 12px;
}

.detail-item {
    display: flex;
    gap: 8px;
}

.detail-item .label {
    color: var(--text-secondary);
    min-width: 80px;
}

.detail-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.detail-images img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
}

.qr-section {
    text-align: center;
    padding: 40px 20px;
}

.qr-section img {
    max-width: 280px;
    margin: 20px auto;
    display: block;
}

.qr-url {
    word-break: break-all;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 12px;
}

@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-bar input, .filter-bar select {
        width: 100%;
    }

    table {
        font-size: 12px;
    }

    th, td {
        padding: 8px;
    }
}
