/* 渤景湾物业管理系统 样式 */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { background: var(--bg); }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}
.header-title { font-size: 18px; font-weight: 600; }
.header-back {
    display: flex; align-items: center; gap: 6px;
    color: #fff; text-decoration: none; font-size: 15px;
    cursor: pointer; background: none; border: none;
}
.header-back svg { width: 20px; height: 20px; }

/* Container */
.container { max-width: 640px; margin: 0 auto; padding: 16px; }

/* Card */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.card-title {
    font-size: 16px; font-weight: 600;
    margin-bottom: 16px; color: var(--text);
    display: flex; align-items: center; gap: 8px;
}
.card-title .icon { width: 24px; height: 24px; }

/* Form */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: 14px; font-weight: 500;
    color: var(--text); margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px; color: var(--text);
    background: #f8fafc;
    transition: all 0.2s;
    outline: none;
    -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-input::placeholder { color: var(--text-light); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* Button */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 12px 24px; border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 500; border: none;
    cursor: pointer; transition: all 0.2s;
    text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline {
    background: #fff; color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; pointer-events: none; }

/* Loading */
.loading-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8); z-index: 999;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 12px;
}
.spinner {
    width: 40px; height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    padding: 12px 24px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; z-index: 1000;
    animation: slideDown 0.3s ease;
    box-shadow: var(--shadow-lg); max-width: 90%;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Badge */
.badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 20px; font-size: 12px; font-weight: 500;
}
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-processing { background: #dbeafe; color: #1e40af; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #f1f5f9; color: #64748b; }
.badge-urgent { background: #fee2e2; color: #991b1b; }

/* Empty State */
.empty-state {
    text-align: center; padding: 48px 20px; color: var(--text-secondary);
}
.empty-state svg { width: 80px; height: 80px; margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 15px; }

/* Repair List */
#repairList { min-height: 120px; }
.repair-item {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 16px; margin-bottom: 12px;
    box-shadow: var(--shadow);
    cursor: pointer; transition: all 0.2s;
    display: flex; gap: 12px; align-items: flex-start;
}
.repair-item:active { background: #f8fafc; }
.repair-item-left { flex: 1; min-width: 0; }
.repair-no { font-size: 12px; color: var(--text-light); margin-bottom: 4px; }
.repair-type {
    font-size: 15px; font-weight: 600; color: var(--text);
    margin-bottom: 4px;
}
.repair-desc {
    font-size: 13px; color: var(--text-secondary);
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.repair-meta {
    display: flex; align-items: center; gap: 8px;
    margin-top: 8px; font-size: 12px; color: var(--text-light);
    flex-wrap: wrap;
}
.repair-item-right {
    display: flex; flex-direction: column;
    align-items: flex-end; gap: 4px; flex-shrink: 0;
}
.repair-time { font-size: 12px; color: var(--text-light); }

/* Stats Grid */
.stats-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 12px; margin-bottom: 16px;
}
.stats-card {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow);
    text-align: center;
}
.stats-number { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.stats-label { font-size: 13px; color: var(--text-secondary); }
.stats-blue { color: var(--primary); }
.stats-green { color: var(--success); }
.stats-orange { color: var(--warning); }
.stats-red { color: var(--danger); }

/* Profile */
.profile-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    border: 3px solid #fff; box-shadow: var(--shadow);
    object-fit: cover;
}
.profile-header {
    display: flex; align-items: center; gap: 16px;
    margin-bottom: 24px;
}
.profile-name { font-size: 18px; font-weight: 600; }

/* Homepage actions */
.action-grid {
    display: grid; grid-template-columns: repeat(2, 1fr);
    gap: 12px; margin-bottom: 20px;
}
.action-card {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 20px 16px; box-shadow: var(--shadow);
    text-align: center; cursor: pointer;
    transition: all 0.2s; text-decoration: none; color: var(--text);
}
.action-card:active { transform: scale(0.97); background: #f8fafc; }
.action-card-icon { margin-bottom: 10px; }
.action-card-icon svg { width: 36px; height: 36px; }
.action-card-text { font-size: 14px; font-weight: 500; }

/* Image upload */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 24px; text-align: center;
    cursor: pointer; transition: border-color 0.2s;
    margin-bottom: 12px;
}
.upload-area:hover { border-color: var(--primary); }
.upload-area svg { width: 40px; height: 40px; color: var(--text-light); margin-bottom: 8px; }
.upload-area p { font-size: 13px; color: var(--text-light); }
.upload-preview {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px;
}
.upload-preview-item {
    width: 80px; height: 80px; border-radius: 8px;
    object-fit: cover; position: relative;
}
.upload-preview-wrap {
    position: relative; display: inline-block;
}
.upload-remove {
    position: absolute; top: -6px; right: -6px;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--danger); color: #fff;
    border: none; font-size: 14px; line-height: 22px;
    cursor: pointer; text-align: center;
}

/* Tab */
.tabs {
    display: flex; gap: 0; border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}
.tab-item {
    flex: 1; text-align: center; padding: 12px 8px;
    font-size: 14px; font-weight: 500; color: var(--text-secondary);
    cursor: pointer; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all 0.2s;
    background: none; border-top: none; border-left: none; border-right: none;
}
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Search bar */
.search-bar {
    display: flex; gap: 8px; margin-bottom: 16px;
}
.search-bar .form-input { flex: 1; }
.search-bar .btn { flex-shrink: 0; }

/* Date range */
.date-range {
    display: flex; gap: 8px; align-items: center; margin-bottom: 16px;
}
.date-range .form-input { flex: 1; }
.date-range span { color: var(--text-light); font-size: 14px; }

/* Pagination */
.pagination {
    display: flex; justify-content: center; align-items: center;
    gap: 8px; padding: 16px 0;
}
.pagination .btn { min-width: 80px; }

/* Detail page */
.detail-section { margin-bottom: 20px; }
.detail-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.detail-value { font-size: 15px; color: var(--text); }
.detail-images {
    display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
.detail-images img {
    width: calc(33.33% - 6px); border-radius: 8px;
    object-fit: cover; aspect-ratio: 1;
}

/* Admin Table */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
    background: #f8fafc; padding: 10px 8px; text-align: left;
    font-weight: 600; color: var(--text-secondary); white-space: nowrap;
}
.admin-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.admin-table tr:hover { background: #f8fafc; }
.admin-table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin: 0 -4px; padding: 0 4px;
}

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 500;
    display: flex; align-items: flex-end; justify-content: center;
}
.modal-overlay.hidden { display: none !important; }
.modal-content {
    background: var(--card-bg); border-radius: 16px 16px 0 0;
    width: 100%; max-width: 640px; max-height: 85vh;
    overflow-y: auto; padding: 24px 20px; animation: slideUp 0.3s ease;
    min-height: 200px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
}
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 20px; }
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* Repair Grid (for admin) */
.repair-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

/* Bottom Tab Bar */
.tabbar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff; border-top: 1px solid var(--border);
    display: flex; justify-content: space-around; align-items: center;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 200; box-shadow: 0 -1px 6px rgba(0,0,0,.04);
    min-height: 56px;
}
.tabbar-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 6px 0; gap: 2px;
    color: var(--text-secondary); text-decoration: none;
    font-size: 11px; cursor: pointer; transition: all .15s;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px; user-select: none;
}
.tabbar-item svg { width: 24px; height: 24px; stroke-width: 1.8; }
.tabbar-item.active { color: var(--primary); font-weight: 600; }
.tabbar-item.active svg { stroke: var(--primary); fill: none; }

/* Notice card (admin) */
.notice-card:active { background: #f8fafc !important; }

/* Banner */
.banner {
    width: 100%; height: 160px; border-radius: var(--radius);
    overflow: hidden; position: relative; margin-bottom: 16px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}
.banner img { width: 100%; height: 100%; object-fit: cover; }
.banner-text {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 16px 20px;
    background: linear-gradient(transparent, rgba(0,0,0,0.5));
    color: #fff;
}
.banner-text h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.banner-text p { font-size: 13px; opacity: 0.9; }

/* Icon grid (4-col) */
.icon-grid {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
    margin-bottom: 16px;
}
.icon-grid-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 6px; padding: 12px 4px; border-radius: var(--radius-sm);
    cursor: pointer; text-decoration: none; color: var(--text);
    transition: background .2s; -webkit-tap-highlight-color: transparent;
}
.icon-grid-item:active { background: #f1f5f9; }
.icon-grid-item .icon-wrap {
    width: 48px; height: 48px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
}
.icon-grid-item .icon-wrap svg { width: 26px; height: 26px; }
.icon-grid-item .icon-label { font-size: 12px; color: var(--text); }

/* Section title */
.section-title {
    font-size: 16px; font-weight: 700; color: var(--text);
    margin-bottom: 12px; display: flex; align-items: center; gap: 6px;
}

/* User mini card on homepage */
.user-mini {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; background: var(--card-bg);
    border-radius: var(--radius); margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.user-mini-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    object-fit: cover; border: 2px solid var(--primary-light);
}
.user-mini-info { flex: 1; min-width: 0; }
.user-mini-name { font-size: 15px; font-weight: 600; color: var(--text); }
.user-mini-addr { font-size: 12px; color: var(--text-secondary); }

/* Body padding for fixed tabbar */
body.has-tabbar { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0)); }

/* Responsive: make admin pages scrollable on phone */
@media (min-width: 768px) {
    .admin-table-wrap { overflow-x: auto; }
}

/* Inline flex */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); font-size: 13px; }
