*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif; background: #f5f5f5; -webkit-text-size-adjust: 100%; }
.header { background: #333; color: white; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; }
.header h1 { font-size: 18px; }
.container { max-width: 800px; margin: 20px auto; padding: 0 20px; }
.section { display: none; }
.section.active { display: block; }
.toolbar { margin-bottom: 15px; display: flex; flex-wrap: wrap; gap: 5px; }
.btn { padding: 8px 15px; background: #28a745; color: white; border: none; cursor: pointer; border-radius: 4px; display: inline-block; text-align: center; }
.btn-danger { background: #dc3545; }
.alert { background: #fff3cd; border: 1px solid #ffc107; padding: 15px; margin-bottom: 15px; border-radius: 5px; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 10px; border: 1px solid #ddd; text-align: left; }
th { background: #f8f9fa; }
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; }
.modal.active { display: flex; align-items: center; justify-content: center; }
.modal-content { background: white; padding: 20px; width: 400px; max-width: 95%; max-height: 90vh; overflow-y: auto; border-radius: 12px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.form-group { margin-bottom: 10px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 14px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 15px; }
.tab-btn { background: transparent; border: 1px solid transparent; color: white; padding: 8px 15px; cursor: pointer; border-radius: 4px; font-size: 14px; }
.tab-btn.active { background: rgba(255,255,255,0.2); border-color: white; }
.contract-card { background: white; border: 1px solid #ddd; border-radius: 8px; padding: 15px; margin-bottom: 15px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.contract-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.contract-title { font-size: 16px; font-weight: bold; }
.payment-status { padding: 5px 10px; border-radius: 4px; font-size: 12px; display: inline-block; }
.payment-status.debt { background: #f8d7da; color: #721c24; }
.payment-status.overpay { background: #d4edda; color: #155724; }
.payment-status.paid { background: #cce5ff; color: #004085; }
.contract-details { display: flex; justify-content: space-between; margin-top: 10px; }
.contract-info { font-size: 14px; color: #666; }
.qr-image { max-width: 150px; height: auto; margin-top: 10px; }

.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #f5f5f5; padding: 20px; }
.login-box { text-align: center; padding: 40px; background: white; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); width: 100%; max-width: 350px; }
.login-box h1 { margin-bottom: 10px; font-size: 22px; }
.login-box p { margin-bottom: 15px; color: #666; }
.login-box input { padding: 12px; width: 100%; margin-bottom: 10px; border: 1px solid #ddd; border-radius: 6px; font-size: 16px; }
.login-box button { padding: 12px 30px; background: #007bff; color: white; border: none; cursor: pointer; border-radius: 6px; font-size: 16px; width: 100%; }

.user-name { color: #aaa; margin-right: 10px; }
.user-name.active { color: #fff; }

.settlement-filter { padding: 5px; border-radius: 4px; border: 1px solid #555; background: #444; color: white; font-size: 14px; }

.toolbar input, .toolbar select { padding: 8px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; }

.header-btn { background: none; border: 1px solid #888; color: #ccc; padding: 5px 10px; cursor: pointer; border-radius: 4px; font-size: 13px; }
.header-btn-logout { background: none; border: 1px solid white; color: white; padding: 5px 10px; cursor: pointer; border-radius: 4px; font-size: 13px; }
.header-btn:hover, .header-btn-logout:hover { opacity: 0.8; }

.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; padding: 5px 10px; line-height: 1; }

.info-box { background: #e7f3ff; padding: 10px; margin-bottom: 15px; border-radius: 6px; font-size: 13px; line-height: 1.4; }

@media (max-width: 768px) {
    .header { flex-wrap: wrap; gap: 8px; padding: 12px; }
    .header h1 { width: 100%; font-size: 15px; }
    .header > div { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
    .header .tab-btn { flex: 1 1 auto; min-width: 0; font-size: 13px; padding: 10px 8px; min-height: 44px; }
    .header select { font-size: 13px; padding: 10px 8px; min-height: 44px; }
    .container { padding: 0 12px; margin: 12px auto; }
    .toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
    .toolbar input, .toolbar select { flex: 1 1 auto; min-width: 0; font-size: 16px; padding: 10px 8px; }
    .section { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { font-size: 12px; }
    th, td { padding: 8px 6px; white-space: nowrap; }
    .modal-content { width: 95%; max-width: 400px; margin: 10px; }
    .form-group input, .form-group select, .form-group textarea { font-size: 16px; padding: 12px 10px; }
    .btn { padding: 12px 16px; font-size: 15px; min-height: 44px; }
    .btn-danger { padding: 12px 16px; font-size: 15px; min-height: 44px; }
    .contract-card { padding: 12px; }
    .contract-header { flex-wrap: wrap; gap: 8px; }
    .contract-details { flex-wrap: wrap; gap: 5px; }
    .login-box { padding: 30px 20px; }
    .login-box input { padding: 14px; }
    .login-box button { padding: 14px; }
    .header-btn, .header-btn-logout { padding: 8px 12px; min-height: 44px; font-size: 13px; }
}

@media (max-width: 480px) {
    .header { padding: 10px; }
    .header h1 { font-size: 14px; }
    .header .tab-btn, .header select { font-size: 12px; padding: 8px 6px; }
    .header-btn, .header-btn-logout { font-size: 12px; padding: 8px 10px; }
    table { font-size: 11px; }
    th, td { padding: 6px 4px; }
    .modal-content { padding: 15px; }
    .contract-title { font-size: 14px; }
    .container { padding: 0 8px; margin: 8px auto; }
    .btn { padding: 10px 12px; font-size: 14px; }
}

@media (hover: none) and (pointer: coarse) {
    input, select, textarea, button { font-size: 16px; }
    .btn:active, .tab-btn:active, .header-btn:active, .header-btn-logout:active { opacity: 0.7; }
}
