:root {
    --primary: #4A90E2;
    --primary-light: #E8F4FD;
    --primary-dark: #357ABD;
    --success: #52C41A;
    --success-light: #F6FFED;
    --success-border: #B7EB8F;
    --danger: #FF4D4F;
    --danger-light: #FFF1F0;
    --danger-border: #FFCCC7;
    --warning: #FAAD14;
    --warning-light: #FFFBE6;
    --warning-border: #FFE58F;
    --info: #1890FF;
    --info-light: #E6F7FF;
    --orange: #FA8C16;
    --bg: #F5F7FA;
    --card-bg: #FFFFFF;
    --text-main: #303133;
    --text-sub: #909399;
    --text-light: #C0C4CC;
    --border: #EBEEF5;
    --border-dark: #DCDFE6;
    --shadow: 0 2px 12px 0 rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 16px 0 rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text-main);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

.container { width: 100%; max-width: 100%; margin: 0 auto; padding: 0; }

.header {
    background: var(--card-bg);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--primary);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.sync-status {
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-dark);
    background: #F5F7FA;
}
.sync-status.synced  { color: var(--success); background: var(--success-light); border-color: var(--success-border); }
.sync-status.local   { color: var(--text-sub); background: #F5F7FA; border-color: var(--border-dark); }
.sync-status.jsonbin { color: var(--info); background: var(--info-light); border-color: #91D5FF; }

.sync-dot          { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.sync-dot.active   { background: var(--success); animation: pulse 2s infinite; }
.sync-dot.inactive { background: var(--text-light); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

.nav-bar {
    background: var(--card-bg);
    padding: 12px 20px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}
.nav-bar::-webkit-scrollbar       { height: 3px; }
.nav-bar::-webkit-scrollbar-thumb { background: #DCDFE6; border-radius: 2px; }

.nav-btn {
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}
.nav-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}
.nav-btn:active   { transform: scale(0.96); opacity: 0.9; }
.nav-btn:disabled { opacity: 0.5; cursor: not-allowed; }

#welcome-screen {
    text-align: center;
    padding: 80px 20px;
    background: var(--card-bg);
    margin: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
}

.welcome-icon { font-size: 4rem; margin-bottom: 20px; }

.input-field {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 12px;
    transition: all 0.2s;
    background: #FAFAFA;
}
.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
    background: white;
}
textarea.input-field { min-height: 80px; resize: vertical; font-family: monospace; font-size: 12px; }

.btn-block {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}
.btn-block:active    { transform: translateY(0); }
.btn-block.secondary { background: #909399; box-shadow: none; }
.btn-block.success   { background: linear-gradient(135deg, var(--success), #67C23A); box-shadow: 0 4px 12px rgba(82, 196, 26, 0.3); }
.btn-block.danger    { background: linear-gradient(135deg, var(--danger), #F56C6C); box-shadow: 0 4px 12px rgba(255, 77, 79, 0.3); }

#main-app { display: none; padding: 20px; width: 100%; }

.house-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    width: 100%;
}

.house-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 0;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
    border: 1px solid var(--border);
    overflow: hidden;
}
.house-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }

.house-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: linear-gradient(135deg, #FAFAFA, #FFFFFF);
}

.house-info { flex: 1; min-width: 0; }

.house-title {
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--text-main);
    word-break: break-all;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.house-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.house-sub   { color: var(--text-sub); font-size: 0.9rem; word-break: break-all; line-height: 1.5; }
.house-price { font-weight: 700; color: var(--primary); font-size: 1.5rem; white-space: nowrap; margin-left: 15px; }
.house-price small { font-size: 0.8rem; font-weight: 500; color: var(--text-sub); }

.house-tags {
    padding: 15px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    background: #FAFAFA;
}

.tag {
    font-size: 0.8rem;
    padding: 5px 12px;
    border-radius: 15px;
    background: white;
    color: var(--text-sub);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 5px;
}
.tag.facility { background: var(--primary-light); color: var(--primary); border: none; font-weight: 500; }

.rent-info-card {
    margin: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #F8F9FA, #FFFFFF);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.rent-info-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.rent-info-title  { font-weight: 600; font-size: 1rem; color: var(--text-main); }
.rent-info-date   { font-weight: 600; font-size: 1rem; color: var(--info); }

.rent-days-row   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.rent-days-label { color: var(--text-sub); font-size: 0.9rem; }
.rent-days-value { font-weight: 700; font-size: 1.2rem; color: var(--success); }
.rent-days-value.warning { color: var(--warning); }
.rent-days-value.danger  { color: var(--danger); }

.rent-progress     { height: 6px; background: #EBEEF5; border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.rent-progress-bar { height: 100%; background: linear-gradient(90deg, var(--primary), var(--info)); border-radius: 3px; transition: width 0.3s; }
.rent-progress-bar.warning { background: linear-gradient(90deg, var(--warning), var(--orange)); }
.rent-progress-bar.danger  { background: linear-gradient(90deg, var(--danger), #F56C6C); }
.rent-progress-info { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--text-sub); }

.utility-section { padding: 0 20px 20px; }
.utility-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.utility-grid-display { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.utility-item-card {
    background: #FAFAFA;
    border-radius: var(--radius-sm);
    padding: 15px 10px;
    text-align: center;
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.utility-item-card:hover { background: white; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.utility-icon  { font-size: 1.5rem; margin-bottom: 8px; display: block; }
.utility-label { font-size: 0.8rem; color: var(--text-sub); margin-bottom: 5px; }
.utility-value { font-weight: 600; font-size: 0.95rem; color: var(--text-main); word-break: break-all; }

.house-actions { padding: 15px 20px 20px; display: flex; gap: 12px; border-top: 1px solid var(--border); }
.action-btn {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn-edit       { background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary); }
.btn-edit:hover { background: var(--primary); color: white; }
.btn-del        { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }
.btn-del:hover  { background: var(--danger); color: white; }

.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-end;
    backdrop-filter: blur(3px);
}
@media (min-width: 600px) { .modal { align-items: center; } }
.modal.open { display: flex; }

.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 24px;
    position: relative;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@media (min-width: 600px) { .modal-content { border-radius: 20px; } }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.3rem; font-weight: 600; color: var(--text-main); }

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
}
.close-btn:hover { color: var(--text-main); }

.form-section { margin-bottom: 18px; }
.form-label   { display: block; font-size: 0.85rem; color: var(--text-sub); margin-bottom: 6px; font-weight: 500; }
.form-row     { display: flex; gap: 15px; }
.form-col     { flex: 1; min-width: 0; }

.deposit-calc {
    background: var(--primary-light);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
    border-left: 4px solid var(--primary);
}
.deposit-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(74, 144, 226, 0.1);
    font-size: 0.9rem;
}
.deposit-item:last-child { border-bottom: none; padding-bottom: 0; }
.deposit-label           { color: var(--text-sub); }
.deposit-value           { font-weight: 600; color: var(--text-main); }
.deposit-value.total     { color: var(--danger); font-size: 1.1rem; }

.rent-input-large {
    font-size: 28px !important;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    background: var(--primary-light) !important;
    border: 2px solid var(--primary) !important;
    padding: 10px !important;
}

.utility-input-grid  { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 8px; }
.utility-input-item  { display: flex; flex-direction: column; gap: 6px; }
.utility-input-label { font-size: 0.8rem; color: var(--text-sub); font-weight: 600; text-align: center; }
.utility-input-field { padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.85rem; text-align: center; }
.utility-input-field:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px var(--primary-light); }

.facility-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.facility-item {
    border: 1px solid var(--border);
    padding: 10px 5px;
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.8rem;
    cursor: pointer;
    background: white;
    transition: all 0.2s;
    user-select: none;
}
.facility-item.selected { background: var(--primary); color: white; border-color: var(--primary); transform: scale(1.05); }

.stats-box { display: flex; justify-content: space-around; gap: 15px; margin-bottom: 20px; }
.stat-item  { flex: 1; background: linear-gradient(135deg, #FAFAFA, #FFFFFF); padding: 25px; border-radius: var(--radius); text-align: center; border: 1px solid var(--border); }
.stat-val       { font-size: 2rem; font-weight: 700; color: var(--primary); display: block; margin-bottom: 8px; }
.stat-val.green { color: var(--success); }
.stat-label     { font-size: 0.85rem; color: var(--text-sub); }

.notify-channel        { border: 1px solid var(--border); padding: 15px; border-radius: var(--radius-sm); margin-bottom: 15px; }
.notify-channel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.notify-channel-title  { font-weight: 600; font-size: 1rem; }

.notify-switch {
    width: 50px;
    height: 26px;
    background: #DCDFE6;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: 0.3s;
}
.notify-switch.on { background: var(--success); }
.notify-switch::after {
    content: '';
    position: absolute;
    width: 22px; height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px; left: 2px;
    transition: 0.3s;
}
.notify-switch.on::after { left: 26px; }

.notify-config      { display: none; margin-top: 10px; }
.notify-config.show { display: block; }
.notify-timing      { display: flex; gap: 10px; margin-top: 10px; }

.timing-btn        { flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 6px; background: white; font-size: 0.85rem; cursor: pointer; }
.timing-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

#admin-panel {
    display: none;
    background: var(--card-bg);
    padding: 0;
    border-radius: var(--radius);
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.admin-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #FAFAFA, #FFFFFF);
}
.admin-panel-title { font-size: 1.2rem; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 10px; }
.admin-panel-desc  { font-size: 0.85rem; color: var(--text-sub); margin-top: 4px; }

.admin-logout-btn { padding: 8px 16px; background: var(--danger); color: white; border: none; border-radius: var(--radius-sm); font-size: 0.9rem; cursor: pointer; font-weight: 500; transition: all 0.2s; }
.admin-logout-btn:hover { background: #F56C6C; transform: translateY(-1px); }

.admin-table-container { overflow-x: auto; padding: 0; }
.admin-table           { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.admin-table thead     { background: #FAFAFA; border-bottom: 1px solid var(--border); }
.admin-table th        { padding: 16px 20px; text-align: left; font-weight: 600; color: var(--text-main); font-size: 0.9rem; white-space: nowrap; }
.admin-table td        { padding: 16px 20px; border-bottom: 1px solid var(--border); color: var(--text-main); }
.admin-table tbody tr              { transition: all 0.2s; }
.admin-table tbody tr:hover        { background: #FAFAFA; }
.admin-table tbody tr:last-child td{ border-bottom: none; }

.user-id-cell     { font-family: monospace; color: var(--text-sub); font-size: 0.85rem; }
.user-name-cell   { font-weight: 500; color: var(--text-main); }
.house-count-cell { text-align: center; font-weight: 600; }
.last-update-cell { color: var(--text-sub); font-size: 0.9rem; }

.status-badge          { display: inline-block; padding: 4px 12px; border-radius: 12px; font-size: 0.8rem; font-weight: 500; }
.status-badge.normal   { background: var(--success-light); color: var(--success); border: 1px solid var(--success-border); }
.status-badge.inactive { background: #F5F7FA; color: var(--text-sub); border: 1px solid var(--border-dark); }
.status-badge.warning  { background: var(--warning-light); color: var(--warning); border: 1px solid var(--warning-border); }

.action-btn-group { display: flex; gap: 8px; justify-content: flex-end; }
.table-btn { padding: 6px 14px; border-radius: 6px; font-size: 0.85rem; cursor: pointer; border: 1px solid; transition: all 0.2s; font-weight: 500; }
.table-btn-view         { background: white; color: var(--text-main); border-color: var(--border-dark); }
.table-btn-view:hover   { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.table-btn-delete       { background: white; color: var(--danger); border-color: var(--danger-border); }
.table-btn-delete:hover { background: var(--danger); color: white; border-color: var(--danger); }

.admin-empty-state { text-align: center; padding: 60px 20px; color: var(--text-sub); }
.admin-empty-icon  { font-size: 3rem; margin-bottom: 15px; opacity: 0.5; }

.btn-group            { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.btn-group .btn-block { flex: 1; min-width: 120px; }

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

.empty-state       { grid-column: 1/-1; text-align: center; padding: 80px 20px; background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-state-icon  { font-size: 4rem; margin-bottom: 20px; opacity: 0.5; }
.empty-state-title { font-size: 1.2rem; font-weight: 600; color: var(--text-main); margin-bottom: 10px; }
.empty-state-desc  { color: var(--text-sub); font-size: 0.95rem; }

.admin-badge        { display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: 0.75rem; font-weight: 600; margin-left: 10px; }
.admin-badge.super  { background: linear-gradient(135deg, #FFD700, #FFA500); color: white; }
.admin-badge.normal { background: var(--primary-light); color: var(--primary); }

.password-hint { background: var(--warning-light); border: 1px solid var(--warning); border-radius: var(--radius-sm); padding: 15px; margin-bottom: 20px; font-size: 0.9rem; }

.help-text      { font-size: 0.75rem; color: var(--text-sub); margin-top: 6px; line-height: 1.4; }
.help-text code { background: #F5F5F5; padding: 2px 6px; border-radius: 4px; font-family: monospace; }

.notify-error      { border: 1px solid var(--danger-border); background: var(--danger-light); color: var(--danger); padding: 10px 15px; border-radius: var(--radius-sm); margin-top: 10px; font-size: 0.85rem; display: none; }
.notify-error.show { display: block; }

.input-error { border-color: var(--danger) !important; box-shadow: 0 0 0 2px var(--danger-light) !important; }

/* ===== 手机端 ===== */
@media (max-width: 480px) {
    .house-grid           { grid-template-columns: 1fr; }
    .utility-input-grid   { grid-template-columns: 1fr; }
    .utility-grid-display { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .utility-item-card    { padding: 8px 4px; }
    .utility-icon         { font-size: 1.2rem; margin-bottom: 4px; }
    .utility-label        { font-size: 0.7rem; margin-bottom: 3px; }
    .utility-value        { font-size: 0.8rem; }
    .utility-section      { padding: 0 15px 15px; }
    .utility-title        { font-size: 0.85rem; margin-bottom: 10px; }
    .form-row             { flex-direction: column; gap: 15px; }
    .house-actions        { flex-direction: column; }
    .nav-bar              { padding: 10px 15px; }
    #main-app             { padding: 15px; }
    .house-header         { flex-direction: column; gap: 15px; }
    .house-price          { margin-left: 0; }
    .admin-table th,
    .admin-table td       { padding: 12px 10px; font-size: 0.85rem; }
    .action-btn-group     { flex-direction: column; }
    .table-btn            { width: 100%; }
}

/* ===== 平板端 ===== */
@media (min-width: 481px) and (max-width: 768px) {
    .utility-grid-display { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .utility-item-card    { padding: 10px 6px; }
    .utility-icon         { font-size: 1.3rem; margin-bottom: 5px; }
    .utility-label        { font-size: 0.75rem; margin-bottom: 4px; }
    .utility-value        { font-size: 0.85rem; }
}
